var { _optionalChain } = require('@sentry/utils'); Object.defineProperty(exports, '__esModule', { value: true }); const react = require('@sentry/react'); const nextRoutingInstrumentation = require('./routing/nextRoutingInstrumentation.js'); /** * A custom BrowserTracing integration for Next.js. * * @deprecated Use `browserTracingIntegration` instead. */ // eslint-disable-next-line deprecation/deprecation class BrowserTracing extends react.BrowserTracing { // 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 [...react.defaultRequestInstrumentationOptions.tracingOrigins, /^(api\/)/], // eslint-disable-next-line deprecation/deprecation routingInstrumentation: nextRoutingInstrumentation.nextRouterInstrumentation, ...options, }); } } /** * A custom BrowserTracing integration for Next.js. */ function browserTracingIntegration( options, ) { const browserTracingIntegrationInstance = react.browserTracingIntegration({ // 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 [...react.defaultRequestInstrumentationOptions.tracingOrigins, /^(api\/)/], ...options, instrumentNavigation: false, instrumentPageLoad: false, }); return { ...browserTracingIntegrationInstance, afterAllSetup(client) { const startPageloadCallback = (startSpanOptions) => { react.startBrowserTracingPageLoadSpan(client, startSpanOptions); }; const startNavigationCallback = (startSpanOptions) => { react.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 nextRoutingInstrumentation.nextRouterInstrumentation( () => undefined, false, _optionalChain([options, 'optionalAccess', _ => _.instrumentNavigation]), startPageloadCallback, startNavigationCallback, ); browserTracingIntegrationInstance.afterAllSetup(client); // eslint-disable-next-line deprecation/deprecation nextRoutingInstrumentation.nextRouterInstrumentation( () => undefined, _optionalChain([options, 'optionalAccess', _2 => _2.instrumentPageLoad]), false, startPageloadCallback, startNavigationCallback, ); }, }; } exports.BrowserTracing = BrowserTracing; exports.browserTracingIntegration = browserTracingIntegration; //# sourceMappingURL=browserTracingIntegration.js.map