import { _optionalChain } from '@sentry/utils'; import { BrowserTracing as BrowserTracing$1, defaultRequestInstrumentationOptions, browserTracingIntegration as browserTracingIntegration$1, startBrowserTracingPageLoadSpan, startBrowserTracingNavigationSpan } from '@sentry/react'; import { nextRouterInstrumentation } from './routing/nextRoutingInstrumentation.js'; /** * A custom BrowserTracing integration for Next.js. * * @deprecated Use `browserTracingIntegration` instead. */ // eslint-disable-next-line deprecation/deprecation class BrowserTracing extends BrowserTracing$1 { // eslint-disable-next-line deprecation/deprecation constructor(options) { super({ // eslint-disable-next-line deprecation/deprecation tracingOrigins: process.env.NODE_ENV === 'development' ? [ // Will match any URL that contains "localhost" but not "webpack.hot-update.json" - The webpack dev-server // has cors and it doesn't like extra headers when it's accessed from a different URL. // TODO(v8): Ideally we rework our tracePropagationTargets logic so this hack won't be necessary anymore (see issue #9764) /^(?=.*localhost)(?!.*webpack\.hot-update\.json).*/, /^\/(?!\/)/, ] : // eslint-disable-next-line deprecation/deprecation [...defaultRequestInstrumentationOptions.tracingOrigins, /^(api\/)/], // eslint-disable-next-line deprecation/deprecation routingInstrumentation: nextRouterInstrumentation, ...options, }); } } /** * A custom BrowserTracing integration for Next.js. */ function browserTracingIntegration( options, ) { const browserTracingIntegrationInstance = browserTracingIntegration$1({ // eslint-disable-next-line deprecation/deprecation tracingOrigins: process.env.NODE_ENV === 'development' ? [ // Will match any URL that contains "localhost" but not "webpack.hot-update.json" - The webpack dev-server // has cors and it doesn't like extra headers when it's accessed from a different URL. // TODO(v8): Ideally we rework our tracePropagationTargets logic so this hack won't be necessary anymore (see issue #9764) /^(?=.*localhost)(?!.*webpack\.hot-update\.json).*/, /^\/(?!\/)/, ] : // eslint-disable-next-line deprecation/deprecation [...defaultRequestInstrumentationOptions.tracingOrigins, /^(api\/)/], ...options, instrumentNavigation: false, instrumentPageLoad: false, }); return { ...browserTracingIntegrationInstance, afterAllSetup(client) { const startPageloadCallback = (startSpanOptions) => { startBrowserTracingPageLoadSpan(client, startSpanOptions); }; const startNavigationCallback = (startSpanOptions) => { startBrowserTracingNavigationSpan(client, startSpanOptions); }; // We need to run the navigation span instrumentation before the `afterAllSetup` hook on the normal browser // tracing integration because we need to ensure the order of execution is as follows: // Instrumentation to start span on RSC fetch request runs -> Instrumentation to put tracing headers from active span on fetch runs // If it were the other way around, the RSC fetch request would not receive the tracing headers from the navigation transaction. // eslint-disable-next-line deprecation/deprecation nextRouterInstrumentation( () => undefined, false, _optionalChain([options, 'optionalAccess', _ => _.instrumentNavigation]), startPageloadCallback, startNavigationCallback, ); browserTracingIntegrationInstance.afterAllSetup(client); // eslint-disable-next-line deprecation/deprecation nextRouterInstrumentation( () => undefined, _optionalChain([options, 'optionalAccess', _2 => _2.instrumentPageLoad]), false, startPageloadCallback, startNavigationCallback, ); }, }; } export { BrowserTracing, browserTracingIntegration }; //# sourceMappingURL=browserTracingIntegration.js.map