Object.defineProperty(exports, '__esModule', { value: true }); const core = require('@sentry/core'); const react = require('@sentry/react'); const devErrorSymbolicationEventProcessor = require('../common/devErrorSymbolicationEventProcessor.js'); const getVercelEnv = require('../common/getVercelEnv.js'); const browserTracingIntegration = require('./browserTracingIntegration.js'); const rewriteFramesIntegration = require('./rewriteFramesIntegration.js'); const tunnelRoute = require('./tunnelRoute.js'); const nextRoutingInstrumentation = require('./routing/nextRoutingInstrumentation.js'); const _error = require('../common/_error.js'); const wrapGetStaticPropsWithSentry = require('../common/wrapGetStaticPropsWithSentry.js'); const wrapGetInitialPropsWithSentry = require('../common/wrapGetInitialPropsWithSentry.js'); const wrapAppGetInitialPropsWithSentry = require('../common/wrapAppGetInitialPropsWithSentry.js'); const wrapDocumentGetInitialPropsWithSentry = require('../common/wrapDocumentGetInitialPropsWithSentry.js'); const wrapErrorGetInitialPropsWithSentry = require('../common/wrapErrorGetInitialPropsWithSentry.js'); const wrapGetServerSidePropsWithSentry = require('../common/wrapGetServerSidePropsWithSentry.js'); const wrapServerComponentWithSentry = require('../common/wrapServerComponentWithSentry.js'); const wrapRouteHandlerWithSentry = require('../common/wrapRouteHandlerWithSentry.js'); const wrapApiHandlerWithSentryVercelCrons = require('../common/wrapApiHandlerWithSentryVercelCrons.js'); const wrapMiddlewareWithSentry = require('../common/wrapMiddlewareWithSentry.js'); const wrapPageComponentWithSentry = require('../common/wrapPageComponentWithSentry.js'); const wrapGenerationFunctionWithSentry = require('../common/wrapGenerationFunctionWithSentry.js'); const withServerActionInstrumentation = require('../common/withServerActionInstrumentation.js'); /** @deprecated Import the integration function directly, e.g. `inboundFiltersIntegration()` instead of `new Integrations.InboundFilter(). */ const Integrations = { // eslint-disable-next-line deprecation/deprecation ...react.Integrations, BrowserTracing: browserTracingIntegration.BrowserTracing, }; // Treeshakable guard to remove all code related to tracing /** Inits the Sentry NextJS SDK on the browser with the React SDK. */ function init(options) { const opts = { environment: getVercelEnv.getVercelEnv(true) || process.env.NODE_ENV, defaultIntegrations: getDefaultIntegrations(options), ...options, }; fixBrowserTracingIntegration(opts); tunnelRoute.applyTunnelRouteOption(opts); core.applySdkMetadata(opts, 'nextjs', ['nextjs', 'react']); react.init(opts); const scope = react.getCurrentScope(); scope.setTag('runtime', 'browser'); const filterTransactions = event => event.type === 'transaction' && event.transaction === '/404' ? null : event; filterTransactions.id = 'NextClient404Filter'; scope.addEventProcessor(filterTransactions); if (process.env.NODE_ENV === 'development') { scope.addEventProcessor(devErrorSymbolicationEventProcessor.devErrorSymbolicationEventProcessor); } } // TODO v8: Remove this again // We need to handle BrowserTracing passed to `integrations` that comes from `@sentry/tracing`, not `@sentry/nextjs` :( function fixBrowserTracingIntegration(options) { const { integrations } = options; if (!integrations) { return; } if (Array.isArray(integrations)) { options.integrations = maybeUpdateBrowserTracingIntegration(integrations); } else { options.integrations = defaultIntegrations => { const userFinalIntegrations = integrations(defaultIntegrations); return maybeUpdateBrowserTracingIntegration(userFinalIntegrations); }; } } function isNewBrowserTracingIntegration( integration, ) { // eslint-disable-next-line deprecation/deprecation return !!integration.afterAllSetup && !!(integration ).options; } function maybeUpdateBrowserTracingIntegration(integrations) { const browserTracing = integrations.find(integration => integration.name === 'BrowserTracing'); if (!browserTracing) { return integrations; } // If `browserTracingIntegration()` was added, we need to force-convert it to our custom one if (isNewBrowserTracingIntegration(browserTracing)) { const { options } = browserTracing; // eslint-disable-next-line deprecation/deprecation integrations[integrations.indexOf(browserTracing)] = new browserTracingIntegration.BrowserTracing(options); } // If BrowserTracing was added, but it is not our forked version, // replace it with our forked version with the same options // eslint-disable-next-line deprecation/deprecation if (!(browserTracing instanceof browserTracingIntegration.BrowserTracing)) { // eslint-disable-next-line deprecation/deprecation const options = (browserTracing ).options; // This option is overwritten by the custom integration delete options.routingInstrumentation; // eslint-disable-next-line deprecation/deprecation delete options.tracingOrigins; // eslint-disable-next-line deprecation/deprecation integrations[integrations.indexOf(browserTracing)] = new browserTracingIntegration.BrowserTracing(options); } return integrations; } function getDefaultIntegrations(options) { const customDefaultIntegrations = [...react.getDefaultIntegrations(options), rewriteFramesIntegration.rewriteFramesIntegration()]; // This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false", in which case everything inside // will get treeshaken away if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) { if (core.hasTracingEnabled(options)) { customDefaultIntegrations.push(browserTracingIntegration.browserTracingIntegration()); } } return customDefaultIntegrations; } /** * Just a passthrough in case this is imported from the client. */ function withSentryConfig(exportedUserNextConfig) { return exportedUserNextConfig; } exports.BrowserTracing = browserTracingIntegration.BrowserTracing; exports.browserTracingIntegration = browserTracingIntegration.browserTracingIntegration; exports.rewriteFramesIntegration = rewriteFramesIntegration.rewriteFramesIntegration; exports.nextRouterInstrumentation = nextRoutingInstrumentation.nextRouterInstrumentation; exports.captureUnderscoreErrorException = _error.captureUnderscoreErrorException; exports.withSentryGetStaticProps = wrapGetStaticPropsWithSentry.withSentryGetStaticProps; exports.wrapGetStaticPropsWithSentry = wrapGetStaticPropsWithSentry.wrapGetStaticPropsWithSentry; exports.withSentryServerSideGetInitialProps = wrapGetInitialPropsWithSentry.withSentryServerSideGetInitialProps; exports.wrapGetInitialPropsWithSentry = wrapGetInitialPropsWithSentry.wrapGetInitialPropsWithSentry; exports.withSentryServerSideAppGetInitialProps = wrapAppGetInitialPropsWithSentry.withSentryServerSideAppGetInitialProps; exports.wrapAppGetInitialPropsWithSentry = wrapAppGetInitialPropsWithSentry.wrapAppGetInitialPropsWithSentry; exports.withSentryServerSideDocumentGetInitialProps = wrapDocumentGetInitialPropsWithSentry.withSentryServerSideDocumentGetInitialProps; exports.wrapDocumentGetInitialPropsWithSentry = wrapDocumentGetInitialPropsWithSentry.wrapDocumentGetInitialPropsWithSentry; exports.withSentryServerSideErrorGetInitialProps = wrapErrorGetInitialPropsWithSentry.withSentryServerSideErrorGetInitialProps; exports.wrapErrorGetInitialPropsWithSentry = wrapErrorGetInitialPropsWithSentry.wrapErrorGetInitialPropsWithSentry; exports.withSentryGetServerSideProps = wrapGetServerSidePropsWithSentry.withSentryGetServerSideProps; exports.wrapGetServerSidePropsWithSentry = wrapGetServerSidePropsWithSentry.wrapGetServerSidePropsWithSentry; exports.wrapServerComponentWithSentry = wrapServerComponentWithSentry.wrapServerComponentWithSentry; exports.wrapRouteHandlerWithSentry = wrapRouteHandlerWithSentry.wrapRouteHandlerWithSentry; exports.wrapApiHandlerWithSentryVercelCrons = wrapApiHandlerWithSentryVercelCrons.wrapApiHandlerWithSentryVercelCrons; exports.wrapMiddlewareWithSentry = wrapMiddlewareWithSentry.wrapMiddlewareWithSentry; exports.wrapPageComponentWithSentry = wrapPageComponentWithSentry.wrapPageComponentWithSentry; exports.wrapGenerationFunctionWithSentry = wrapGenerationFunctionWithSentry.wrapGenerationFunctionWithSentry; exports.withServerActionInstrumentation = withServerActionInstrumentation.withServerActionInstrumentation; exports.Integrations = Integrations; exports.init = init; exports.withSentryConfig = withSentryConfig; for (const k in react) { if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = react[k]; } //# sourceMappingURL=index.js.map