Repository navigation
fix(datadog): stop attributing GTM-injected vendor tag errors to Studio through the DOM guard frame #1811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dawsontoth
merged 1 commit into
claude/1690-drop-dead-endpoint-gate
from
claude/1696-gtm-guard-frame-attribution
Oct 12, 2026
Merged
fix(datadog): stop attributing GTM-injected vendor tag errors to Studio through the DOM guard frame #1811
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import path from 'node:path'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import viteConfig from './vite.config'; | ||
|
|
||
| function buildOutput() { | ||
| const config = viteConfig({ mode: 'prod', command: 'build', isSsrBuild: false, isPreview: false }); | ||
| if (typeof config === 'function' || config instanceof Promise) { | ||
| throw new Error('vite.config.ts no longer returns a plain config object'); | ||
| } | ||
| return config.build?.rollupOptions?.output as { manualChunks?: unknown; chunkFileNames?: unknown }; | ||
| } | ||
|
|
||
| // `shouldKeepEvent` reads a `vendor-datadog` frame as neutral instrumentation (#1696). | ||
| describe('manualChunks', () => { | ||
| it('builds the translation DOM guard into the Datadog chunk', () => { | ||
| const { manualChunks, chunkFileNames } = buildOutput(); | ||
| const guard = path.resolve(__dirname, 'src/lib/installBrowserTranslationDomGuard.ts'); | ||
| const chunkOf = manualChunks as (id: string) => string | undefined; | ||
|
|
||
| expect(chunkOf(guard)).toBe('vendor-datadog'); | ||
| expect(chunkOf(path.resolve(__dirname, 'node_modules/@datadog/browser-rum/esm/index.js'))).toBe('vendor-datadog'); | ||
| expect(chunkFileNames).toBe('assets/[name]-[hash].js'); | ||
| }); | ||
|
|
||
| it('leaves the rest of Studio to the automatic split', () => { | ||
| const chunkOf = buildOutput().manualChunks as (id: string) => string | undefined; | ||
|
|
||
| expect(chunkOf(path.resolve(__dirname, 'src/main.tsx'))).toBeUndefined(); | ||
| expect(chunkOf(path.resolve(__dirname, 'src/lib/installStaleDeployReload.ts'))).toBeUndefined(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vite/Rollup can append query parameters to module IDs during resolution or transformation (e.g.,
?worker,?commonjs-entry, or other plugin-specific flags). If a query parameter is appended,endsWithon the rawidwill fail to match, causing the translation DOM guard to be bundled into the main chunk instead ofvendor-datadog. Stripping any query parameters before performing the path check ensures the bundling logic remains robust.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declining. The id this rule has to match never has a query. The guard is imported in exactly one place, a plain
import … from '@/lib/installBrowserTranslationDomGuard'atsrc/main.tsx:5, so its module id is the bare file path. I checked that in a real build (described under Verification in the PR body):vite build --mode prodputNode.prototype.insertBefore=function(e,t){…}invendor-datadog-*.js, andindex-*.jscontained no copy of it.A query-suffixed id like
?raw,?urlor?workerbelongs to a different module that never runs the patch, so stripping the query would only pull that copy into the Datadog chunk.vite.config.test.tspins how the real file path is placed.🤖 Generated by Claude Code (Claude Opus 5.5); posted via @dawsontoth.