fix(event-log): add event logging for embedded Superset#41938
Conversation
|
Bito Automatic Review Skipped - Branch Excluded |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The flagged issue is correct. Using To resolve this, you should use a more precise check that validates the URL structure. You can use a regular expression or check for the specific path segments to ensure it only matches actual embedded routes. Here is a concise fix using a regex to ensure const isEmbedded = /\/(embedded|dashboard\/.*\/embedded)\//.test(path || '');
if (dashboardInfo?.id && (path?.includes('/dashboard/') || isEmbedded)) {
logMetadata = {
source: isEmbedded ? 'embedded_dashboard' : 'dashboard',
source_id: dashboardInfo.id,
dashboard_id: dashboardInfo.id,
...logMetadata,
};
}There are no other comments on this PR to address. Would you like me to help with anything else? superset-frontend/src/middleware/loggerMiddleware.ts |
b73902c to
e3b924f
Compare
Cherry-picks the AI-suggested fix from apache#41942. The embedded-dashboard detection classified events by checking whether the URL contained the substring `/embedded/`, which misclassified a regular dashboard whose slug is literally `embedded` (URL `/dashboard/embedded/`). Replace the generic substring check with a regex that matches only the actual embedded route shapes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
React Router matches the embedded routes without a trailing slash too, so `/dashboard/:idOrSlug/embedded` and `/embedded/:uuid` are valid embedded URLs. The regex required a trailing slash, misclassifying those events with the wrong source. Make the trailing slash optional in both branches and add test coverage for the no-slash variants. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
SUMMARY
Cherry-picks #40083 (add event logging for embedded Superset) into the 6.1 branch.
This also includes the follow-up fix from #41942, which refines the embedded-dashboard detection in
loggerMiddleware. The original check classified events by testing whether the URL contained the substring/embedded/, which was too broad: a regular dashboard whose slug is literallyembedded(URL/dashboard/embedded/) also contains/embedded/, so its events were incorrectly tagged withsource: 'embedded_dashboard'instead ofsource: 'dashboard'.The substring check is replaced with a regular expression that matches only the actual embedded route shapes:
/dashboard/:idOrSlug/embedded//embedded/:uuid/As a result, regular dashboard events are no longer misclassified as embedded, while genuine embedded routes continue to be detected correctly.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — internal event-logging metadata change only.
TESTING INSTRUCTIONS
Unit tests in
superset-frontend/src/middleware/logger.test.tscover source classification across paths:/dashboard/123/embedded/->embedded_dashboard/embedded/abc-def-uuid/->embedded_dashboard/dashboard/123/->dashboard/dashboard/embedded/(slug is literallyembedded) ->dashboardRun:
ADDITIONAL INFORMATION