bito-code-review[bot] commented on PR #41938:
URL: https://github.com/apache/superset/pull/41938#issuecomment-4937951922
<!-- Bito Reply -->
The flagged issue is correct. Using `path?.includes('/embedded/')` is indeed
too broad, as it will incorrectly match any URL containing the string
'embedded', including regular dashboard URLs like `/dashboard/embedded/`.
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 `/embedded/` is part of the
expected path structure:
```typescript
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**
```
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,
};
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]