File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
packages/nextjs/src/client/routing Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -45,18 +45,23 @@ export function removeIsrSsgTraceMetaTags(): void {
4545 return ;
4646 }
4747
48+ // Helper function to remove a meta tag
49+ const removeMetaTag = ( metaName : string ) => {
50+ try {
51+ const meta = document . querySelector ( `meta[name="${ metaName } "]` ) ;
52+ if ( meta ) {
53+ meta . remove ( ) ;
54+ }
55+ } catch {
56+ // ignore errors when removing the meta tag
57+ }
58+ } ;
59+
4860 if ( ! isIsrSsgRoute ( window . location . pathname ) ) {
4961 return ;
5062 }
5163
5264 // Remove the meta tags so browserTracingIntegration won't pick them up
53- const sentryTraceMeta = document . querySelector ( 'meta[name="sentry-trace"]' ) ;
54- if ( sentryTraceMeta ) {
55- sentryTraceMeta . remove ( ) ;
56- }
57-
58- const baggageMeta = document . querySelector ( 'meta[name="baggage"]' ) ;
59- if ( baggageMeta ) {
60- baggageMeta . remove ( ) ;
61- }
65+ removeMetaTag ( 'sentry-trace' ) ;
66+ removeMetaTag ( 'baggage' ) ;
6267}
You can’t perform that action at this time.
0 commit comments