Skip to content

feat(embedded): Add setDataMask API method - #35754

Merged
rusackas merged 9 commits into
apache:masterfrom
gerbermichi:set-data-mask
Aug 15, 2026
Merged

rusackas merged 9 commits into
apache:masterfrom
gerbermichi:set-data-mask

Conversation

@gerbermichi

@gerbermichi gerbermichi commented Oct 21, 2025 •

Copy link
Copy Markdown
Contributor

User description

SUMMARY

Adds a new setDataMask method to the embedded dashboard API, allowing parent applications to programmatically set filter data masks in embedded dashboards.

This complements the existing getDataMask method and enables bidirectional data mask control - parent applications can now both read and write data masks to control embedded dashboard filters.

The implementation dispatches updateDataMask actions for each filter in the provided data mask, updating the Redux store and triggering filter changes in the embedded dashboard.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A - API change only

TESTING INSTRUCTIONS

  1. Set up an embedded dashboard with native filters
  2. From the parent application, call embedDashboard.setDataMask({ filterId: { filterState: { value: [...] } } })
  3. Verify that the embedded dashboard filters update accordingly
  4. Call embedDashboard.getDataMask() to confirm the data mask was set correctly

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

CodeAnt-AI Description

Add setDataMask API to embedded dashboard for programmatic filter updates

What Changed

  • The embedded SDK exposes setDataMask so parent applications can programmatically set dashboard filter values on an embedded dashboard.
  • The embedded page accepts setDataMask calls and applies the provided data mask to dashboard filters in a single batched update, causing associated charts to refresh with the new filter values.
  • Unit tests and Jest configuration were added to validate setDataMask behavior (empty, single, and multiple-filter masks) and to enable testing in a jsdom environment.

Impact

✅ Can set embedded dashboard filters from parent applications
✅ Charts refresh after external filter updates
✅ Easier embedding integration testing

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@bito-code-review

bito-code-review Bot commented Oct 21, 2025 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f9a9a8

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: b82c4e6..b82c4e6
    • superset-frontend/src/embedded/api.tsx
    • superset-frontend/src/embedded/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added the embedded label Oct 21, 2025

@korbit-ai korbit-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Performance Lack of batched updates for data mask ▹ view ✅ Fix detected
Files scanned ​
File Path Reviewed
superset-frontend/src/embedded/api.tsx ✅
superset-frontend/src/embedded/index.tsx ✅

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Comment thread superset-frontend/src/embedded/api.tsx Resolved
@sadpandajoe

Copy link
Copy Markdown
Member

@gerbermichi mind adding tests? or do you think the existing tests already cover all the use cases?

@sadpandajoe sadpandajoe added the review:checkpoint Last PR reviewed during the daily review standup label Oct 21, 2025
@pull-request-size pull-request-size Bot added size/L and removed size/S labels Oct 22, 2025
@sadpandajoe sadpandajoe removed the review:checkpoint Last PR reviewed during the daily review standup label Oct 22, 2025
@rusackas
rusackas requested review from myrle-krantz and removed request for myrle-krantz November 17, 2025 23:11
@rusackas

Copy link
Copy Markdown
Member

looks like this needs some conflicts resolved. Holler when those are cleared, and we'll go from there! Thanks!

@rusackas

Copy link
Copy Markdown
Member

Thanks for updating! Pinging @villebro and adding a couple more reviewers for good measure.

@codeant-ai-for-open-source codeant-ai-for-open-source Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Mar 17, 2026
@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

Sequence Diagram

This PR adds a new setDataMask method to the embedded dashboard API so parent applications can programmatically update native filter states. The flow sends data mask updates from the SDK into the embedded page, batches Redux updates, and applies filter changes to the dashboard.

sequenceDiagram
    participant ParentApp
    participant EmbeddedSDK
    participant EmbeddedPage
    participant ReduxStore
    participant Dashboard

    ParentApp->>EmbeddedSDK: Call setDataMask with filter values
    EmbeddedSDK->>EmbeddedPage: Send setDataMask message
    EmbeddedPage->>ReduxStore: Batch update data mask for each filter
    ReduxStore->>Dashboard: Apply updated filter states
    Dashboard-->>ParentApp: Filters and charts reflect new mask
Loading

Generated by CodeAnt AI

Comment thread superset-embedded-sdk/jest.config.js Resolved
Comment thread superset-embedded-sdk/src/index.ts Resolved
Comment thread superset-frontend/src/embedded/api.tsx Resolved
@bito-code-review

bito-code-review Bot commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #220848

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: 389c01c..fa71d88
    • superset-embedded-sdk/jest.config.js
    • superset-embedded-sdk/src/index.test.ts
    • superset-embedded-sdk/src/index.ts
    • superset-frontend/src/embedded/api.tsx
    • superset-frontend/src/embedded/index.tsx
  • Files skipped - 1
    • superset-embedded-sdk/package.json - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codeant-ai-for-open-source codeant-ai-for-open-source Bot added size:L This PR changes 100-499 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Mar 18, 2026
@netlify

netlify Bot commented Mar 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit dd4a13d
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a7fb5fe6bccf90008e96838
😎 Deploy Preview https://deploy-preview-35754--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

bito-code-review Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #c4b822

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: fa71d88..d84b871
    • superset-embedded-sdk/jest.config.js
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas

Copy link
Copy Markdown
Member

@gerbermichi this looks like a nice complement to getDataMask, but the embedded-sdk-test job is red. Mind getting that green so we can take a proper look? A rebase MIGHT help.

gerbermichi added a commit to gerbermichi/superset that referenced this pull request Jul 29, 2026
Addresses review feedback on apache#35754. The observeDataMask payload carries
the crossFiltersChanged/nativeFiltersChanged flags alongside the mask, so
feeding it straight back into setDataMask pushed those flags through as
filter ids. Filter ids from a different dashboard had the same problem:
updateDataMask inserted them into the store, where the active-filter
derivation treats them as globally scoped and applies them to charts.

The SDK now drops non-object entries before emitting, and the embedded
API only dispatches ids the dashboard already knows about, warning about
the rest instead of applying them silently.
@gerbermichi

Copy link
Copy Markdown
Contributor Author

Thanks for the nudge @rusackas — rebased onto master, and the embedded-sdk-test job is green again.

What the red job actually was: master migrated superset-embedded-sdk to vitest while this branch was adding a Jest setup, so the job's npm test (now vitest --run --dir src) never ran the new tests, and the Jest devDeps weren't in the committed lockfile either. I dropped jest.config.js along with the jest/ts-jest/jest-environment-jsdom deps and ported src/index.test.ts to vitest instead, which is consistent with the sibling tests in that package.

While I was in here, I also worked through the review feedback:

  • @korbit-ai's batching point was already covered by 61b5042 (batch from react-redux).
  • The note about the SDK forwarding its payload unchanged was a real bug. observeDataMask emits crossFiltersChanged/nativeFiltersChanged alongside the mask (src/embedded/index.tsx), so the natural "observe on one dashboard, set on another" sync pattern pushed those flags through as if they were filter ids. setDataMask now keeps only entries whose value is a non-null object before emitting.
  • Same class of problem for unknown filter ids on the embedded side: embeddedApi.setDataMask now dispatches only for ids the dashboard already has in its own data mask — which covers every native filter and every cross-filter-capable chart — and logging.warns about the rest instead of inserting them, where the active-filter derivation would treat them as globally scoped and apply them to charts.
  • The allowJs suggestion on jest.config.js is moot now that the file is gone.
  • I did not gate setDataMask behind dashboard hydration (the race-condition suggestion). Every other embedded setter has the same exposure, so a one-off guard on just this method seemed inconsistent — happy to add it if you'd rather, and the new warning at least makes that window visible instead of silent.

Tests: 4 new tests in superset-frontend/src/embedded/api.test.ts covering the filtering behavior, plus 4 in superset-embedded-sdk/src/index.test.ts. pre-commit run is clean on the changed files, including frontend type-checking.

Ready for another look — @villebro whenever you have a moment.

@codecov

codecov Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.35%. Comparing base (673f928) to head (088103b).
⚠️ Report is 268 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #35754      +/-   ##
==========================================
+ Coverage   65.33%   65.35%   +0.01%     
==========================================
  Files        2803     2803              
  Lines      158490   158515      +25     
  Branches    36178    36182       +4     
==========================================
+ Hits       103557   103590      +33     
+ Misses      52922    52914       -8     
  Partials     2011     2011              
Flag Coverage Δ
javascript 71.49% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bito-code-review

bito-code-review Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #cee052

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: e6f600b..ce54e3a
    • superset-embedded-sdk/src/index.test.ts
    • superset-embedded-sdk/src/index.ts
    • superset-frontend/src/embedded/api.test.ts
    • superset-frontend/src/embedded/api.tsx
    • superset-frontend/src/embedded/index.tsx
  • Files skipped - 2
    • superset-embedded-sdk/package-lock.json - Reason: Filter setting
    • superset-embedded-sdk/package.json - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this handles the batched updates plus unknown-filter-id case cleanly, with tests to match. Approving. Thanks!

Comment thread superset-embedded-sdk/src/index.ts Resolved
Comment thread superset-frontend/src/embedded/api.tsx Resolved
@rusackas

rusackas commented Aug 3, 2026

Copy link
Copy Markdown
Member

Let us know if you have time to look into the latest bot review comments @gerbermichi, or if you want a hand.

@gerbermichi

Copy link
Copy Markdown
Contributor Author

@rusackas Thanks — already on it. I pushed fixes for two of them just now (aad2835):

Addresses review feedback on apache#35754. The observeDataMask payload carries
the crossFiltersChanged/nativeFiltersChanged flags alongside the mask, so
feeding it straight back into setDataMask pushed those flags through as
filter ids. Filter ids from a different dashboard had the same problem:
updateDataMask inserted them into the store, where the active-filter
derivation treats them as globally scoped and applies them to charts.

The SDK now drops non-object entries before emitting, and the embedded
API only dispatches ids the dashboard already knows about, warning about
the rest instead of applying them silently.
Send setDataMask over switchboard's get instead of emit, so an embedded
page that predates the method rejects the call instead of dropping it
silently.

On the iframe side, hold a mask requested before HYDRATE_DASHBOARD and
replay it once hydration lands, instead of discarding every filter id as
unknown against a store that has no filter entries yet.
@bito-code-review

bito-code-review Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #9625a9

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset-frontend/src/embedded/api.tsx - 1
    • Missing mock for batch · Line 92-116
      The `applyDataMask` function uses `batch` from react-redux to group dispatches (line 111), but the test file does not mock or verify `batch` is invoked. While existing tests confirm dispatch calls are correct, they don't guarantee the batching optimization is preserved if `batch` is refactored or removed. Add a test that mocks `react-redux` and asserts `batch` was called with a callback containing the expected dispatches.
  • superset-embedded-sdk/src/index.ts - 1
    • Array entries not filtered in setDataMask · Line 371-371
      The filter `typeof mask === "object"` lets arrays through since `typeof [] === "object"` in JavaScript. While no test exercises this path, it creates a divergence between the stated goal ("entries that look like a filter's mask") and the actual behavior. The array value would be forwarded to the dashboard as a "filter id".
Review Details
  • Files reviewed - 5 · Commit Range: 58abd75..ff41296
    • superset-embedded-sdk/src/index.test.ts
    • superset-embedded-sdk/src/index.ts
    • superset-frontend/src/embedded/api.test.ts
    • superset-frontend/src/embedded/api.tsx
    • superset-frontend/src/embedded/index.tsx
  • Files skipped - 2
    • superset-embedded-sdk/package-lock.json - Reason: Filter setting
    • superset-embedded-sdk/package.json - Reason: Filter setting
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas
rusackas requested a review from Vitor-Avila August 15, 2026 04:57
@apache apache deleted a comment from bito-code-review Bot Aug 15, 2026
@rusackas

Copy link
Copy Markdown
Member

Went back through this before merging. All the CodeAnt threads that were still open turned out to already be fixed in code, the pre-hydration race, unknown-filter-id handling, change-trigger-flag stripping, and the emit vs get version-skew gap, so I replied and resolved them. Each has its own test on both the SDK and frontend side, plus the jest-config thread is moot now that the SDK's on Vitest. The one open design question (partial-update vs full-replace on setDataMask) is intentional, matches updateDataMask's merge semantics everywhere else.

LGTM, merging.

@rusackas
rusackas merged commit 69c4011 into apache:master Aug 15, 2026
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies:npm embedded size/L size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants