Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
187 lines
9.5 KiB
Plaintext
187 lines
9.5 KiB
Plaintext
|
|
"use client";
|
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
const core = require('@sentry/core');
|
|
const react = require('@sentry/react');
|
|
const debugBuild = require('../common/debug-build.js');
|
|
const devErrorSymbolicationEventProcessor = require('../common/devErrorSymbolicationEventProcessor.js');
|
|
const getVercelEnv = require('../common/getVercelEnv.js');
|
|
const nextNavigationErrorUtils = require('../common/nextNavigationErrorUtils.js');
|
|
const browserTracingIntegration = require('./browserTracingIntegration.js');
|
|
const clientNormalizationIntegration = require('./clientNormalizationIntegration.js');
|
|
const appRouterRoutingInstrumentation = require('./routing/appRouterRoutingInstrumentation.js');
|
|
const isrRoutingTracing = require('./routing/isrRoutingTracing.js');
|
|
const tunnelRoute = require('./tunnelRoute.js');
|
|
const wrapGetStaticPropsWithSentry = require('../common/pages-router-instrumentation/wrapGetStaticPropsWithSentry.js');
|
|
const wrapGetInitialPropsWithSentry = require('../common/pages-router-instrumentation/wrapGetInitialPropsWithSentry.js');
|
|
const wrapAppGetInitialPropsWithSentry = require('../common/pages-router-instrumentation/wrapAppGetInitialPropsWithSentry.js');
|
|
const wrapDocumentGetInitialPropsWithSentry = require('../common/pages-router-instrumentation/wrapDocumentGetInitialPropsWithSentry.js');
|
|
const wrapErrorGetInitialPropsWithSentry = require('../common/pages-router-instrumentation/wrapErrorGetInitialPropsWithSentry.js');
|
|
const wrapGetServerSidePropsWithSentry = require('../common/pages-router-instrumentation/wrapGetServerSidePropsWithSentry.js');
|
|
const wrapServerComponentWithSentry = require('../common/wrapServerComponentWithSentry.js');
|
|
const wrapRouteHandlerWithSentry = require('../common/wrapRouteHandlerWithSentry.js');
|
|
const wrapApiHandlerWithSentryVercelCrons = require('../common/pages-router-instrumentation/wrapApiHandlerWithSentryVercelCrons.js');
|
|
const wrapMiddlewareWithSentry = require('../common/wrapMiddlewareWithSentry.js');
|
|
const wrapPageComponentWithSentry = require('../common/pages-router-instrumentation/wrapPageComponentWithSentry.js');
|
|
const wrapGenerationFunctionWithSentry = require('../common/wrapGenerationFunctionWithSentry.js');
|
|
const withServerActionInstrumentation = require('../common/withServerActionInstrumentation.js');
|
|
const captureRequestError = require('../common/captureRequestError.js');
|
|
const _error = require('../common/pages-router-instrumentation/_error.js');
|
|
const nextSpan = require('../common/utils/nextSpan.js');
|
|
|
|
let clientIsInitialized = false;
|
|
|
|
const globalWithInjectedValues = core.GLOBAL_OBJ
|
|
|
|
;
|
|
|
|
// Treeshakable guard to remove all code related to tracing
|
|
|
|
/** Inits the Sentry NextJS SDK on the browser with the React SDK. */
|
|
function init(options) {
|
|
if (clientIsInitialized) {
|
|
core.consoleSandbox(() => {
|
|
// eslint-disable-next-line no-console
|
|
console.warn(
|
|
'[@sentry/nextjs] You are calling `Sentry.init()` more than once on the client. This can happen if you have both a `sentry.client.config.ts` and a `instrumentation-client.ts` file with `Sentry.init()` calls. It is recommended to call `Sentry.init()` once in `instrumentation-client.ts`.',
|
|
);
|
|
});
|
|
}
|
|
clientIsInitialized = true;
|
|
|
|
if (!debugBuild.DEBUG_BUILD && options.debug) {
|
|
core.consoleSandbox(() => {
|
|
// eslint-disable-next-line no-console
|
|
console.warn(
|
|
'[@sentry/nextjs] You have enabled `debug: true`, but Sentry debug logging was removed from your bundle (likely via `withSentryConfig({ disableLogger: true })` / `webpack.treeshake.removeDebugLogging: true`). Set that option to `false` to see Sentry debug output.',
|
|
);
|
|
});
|
|
}
|
|
|
|
// Remove cached trace meta tags for ISR/SSG pages before initializing
|
|
// This prevents the browser tracing integration from using stale trace IDs
|
|
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
|
|
isrRoutingTracing.removeIsrSsgTraceMetaTags();
|
|
}
|
|
|
|
const opts = {
|
|
environment: getVercelEnv.getVercelEnv(true) || process.env.NODE_ENV,
|
|
defaultIntegrations: getDefaultIntegrations(options),
|
|
release: process.env._sentryRelease || globalWithInjectedValues._sentryRelease,
|
|
...options,
|
|
} ;
|
|
|
|
tunnelRoute.applyTunnelRouteOption(opts);
|
|
core.applySdkMetadata(opts, 'nextjs', ['nextjs', 'react']);
|
|
|
|
const client = react.init(opts);
|
|
|
|
const filterTransactions = event =>
|
|
event.type === 'transaction' && event.transaction === '/404' ? null : event;
|
|
filterTransactions.id = 'NextClient404Filter';
|
|
core.addEventProcessor(filterTransactions);
|
|
|
|
const filterIncompleteNavigationTransactions = event =>
|
|
event.type === 'transaction' && event.transaction === appRouterRoutingInstrumentation.INCOMPLETE_APP_ROUTER_INSTRUMENTATION_TRANSACTION_NAME
|
|
? null
|
|
: event;
|
|
filterIncompleteNavigationTransactions.id = 'IncompleteTransactionFilter';
|
|
core.addEventProcessor(filterIncompleteNavigationTransactions);
|
|
|
|
const filterNextRedirectError = (event, hint) =>
|
|
nextNavigationErrorUtils.isRedirectNavigationError(hint?.originalException) || event.exception?.values?.[0]?.value === 'NEXT_REDIRECT'
|
|
? null
|
|
: event;
|
|
filterNextRedirectError.id = 'NextRedirectErrorFilter';
|
|
core.addEventProcessor(filterNextRedirectError);
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
core.addEventProcessor(devErrorSymbolicationEventProcessor.devErrorSymbolicationEventProcessor);
|
|
}
|
|
|
|
try {
|
|
// @ts-expect-error `process.turbopack` is a magic string that will be replaced by Next.js
|
|
if (process.turbopack) {
|
|
core.getGlobalScope().setTag('turbopack', true);
|
|
}
|
|
} catch {
|
|
// Noop
|
|
// The statement above can throw because process is not defined on the client
|
|
}
|
|
|
|
return client;
|
|
}
|
|
|
|
function getDefaultIntegrations(options) {
|
|
const customDefaultIntegrations = react.getDefaultIntegrations(options);
|
|
// This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false",
|
|
// in which case everything inside will get tree-shaken away
|
|
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
|
|
customDefaultIntegrations.push(browserTracingIntegration.browserTracingIntegration());
|
|
}
|
|
|
|
// These values are injected at build time, based on the output directory specified in the build config. Though a default
|
|
// is set there, we set it here as well, just in case something has gone wrong with the injection.
|
|
const rewriteFramesAssetPrefixPath =
|
|
process.env._sentryRewriteFramesAssetPrefixPath ||
|
|
globalWithInjectedValues._sentryRewriteFramesAssetPrefixPath ||
|
|
'';
|
|
const assetPrefix = process.env._sentryAssetPrefix || globalWithInjectedValues._sentryAssetPrefix;
|
|
const basePath = process.env._sentryBasePath || globalWithInjectedValues._sentryBasePath;
|
|
const experimentalThirdPartyOriginStackFrames =
|
|
process.env._experimentalThirdPartyOriginStackFrames === 'true' ||
|
|
globalWithInjectedValues._experimentalThirdPartyOriginStackFrames === 'true';
|
|
customDefaultIntegrations.push(
|
|
clientNormalizationIntegration.nextjsClientStackFrameNormalizationIntegration({
|
|
assetPrefix,
|
|
basePath,
|
|
rewriteFramesAssetPrefixPath,
|
|
experimentalThirdPartyOriginStackFrames,
|
|
}),
|
|
);
|
|
|
|
return customDefaultIntegrations;
|
|
}
|
|
|
|
/**
|
|
* Just a passthrough in case this is imported from the client.
|
|
*/
|
|
function withSentryConfig(exportedUserNextConfig) {
|
|
return exportedUserNextConfig;
|
|
}
|
|
|
|
exports.browserTracingIntegration = browserTracingIntegration.browserTracingIntegration;
|
|
exports.captureRouterTransitionStart = appRouterRoutingInstrumentation.captureRouterTransitionStart;
|
|
exports.wrapGetStaticPropsWithSentry = wrapGetStaticPropsWithSentry.wrapGetStaticPropsWithSentry;
|
|
exports.wrapGetInitialPropsWithSentry = wrapGetInitialPropsWithSentry.wrapGetInitialPropsWithSentry;
|
|
exports.wrapAppGetInitialPropsWithSentry = wrapAppGetInitialPropsWithSentry.wrapAppGetInitialPropsWithSentry;
|
|
exports.wrapDocumentGetInitialPropsWithSentry = wrapDocumentGetInitialPropsWithSentry.wrapDocumentGetInitialPropsWithSentry;
|
|
exports.wrapErrorGetInitialPropsWithSentry = wrapErrorGetInitialPropsWithSentry.wrapErrorGetInitialPropsWithSentry;
|
|
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.captureRequestError = captureRequestError.captureRequestError;
|
|
exports.captureUnderscoreErrorException = _error.captureUnderscoreErrorException;
|
|
exports.startInactiveSpan = nextSpan.startInactiveSpan;
|
|
exports.startSpan = nextSpan.startSpan;
|
|
exports.startSpanManual = nextSpan.startSpanManual;
|
|
exports.init = init;
|
|
exports.withSentryConfig = withSentryConfig;
|
|
Object.prototype.hasOwnProperty.call(react, '__proto__') &&
|
|
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
Object.defineProperty(exports, '__proto__', {
|
|
enumerable: true,
|
|
value: react['__proto__']
|
|
});
|
|
|
|
Object.keys(react).forEach(k => {
|
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = react[k];
|
|
});
|
|
//# sourceMappingURL=index.js.map
|