123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- Object.defineProperty(exports, '__esModule', { value: true });
- const core = require('@sentry/core');
- const node = require('@sentry/node');
- const utils = require('@sentry/utils');
- const debugBuild = require('../common/debug-build.js');
- const devErrorSymbolicationEventProcessor = require('../common/devErrorSymbolicationEventProcessor.js');
- const getVercelEnv = require('../common/getVercelEnv.js');
- const isBuild = require('../common/utils/isBuild.js');
- const httpIntegration = require('./httpIntegration.js');
- const onUncaughtExceptionIntegration = require('./onUncaughtExceptionIntegration.js');
- const rewriteFramesIntegration = require('./rewriteFramesIntegration.js');
- const react = require('@sentry/react');
- 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');
- const wrapApiHandlerWithSentry = require('../common/wrapApiHandlerWithSentry.js');
- const Integrations = {
- ...node.Integrations,
- Http: httpIntegration.Http,
- OnUncaughtException: onUncaughtExceptionIntegration.OnUncaughtException,
- };
- /**
- * A passthrough error boundary for the server that doesn't depend on any react. Error boundaries don't catch SSR errors
- * so they should simply be a passthrough.
- */
- const ErrorBoundary = (props) => {
- if (!props.children) {
- return null;
- }
- if (typeof props.children === 'function') {
- return (props.children )();
- }
- // since Next.js >= 10 requires React ^16.6.0 we are allowed to return children like this here
- return props.children ;
- };
- /**
- * A passthrough error boundary wrapper for the server that doesn't depend on any react. Error boundaries don't catch
- * SSR errors so they should simply be a passthrough.
- */
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- function withErrorBoundary(
- WrappedComponent,
- ) {
- return WrappedComponent ;
- }
- /**
- * Just a passthrough since we're on the server and showing the report dialog on the server doesn't make any sense.
- */
- function showReportDialog() {
- return;
- }
- // TODO (v8): Remove this
- /**
- * @deprecated This constant will be removed in the next major update.
- */
- const IS_BUILD = isBuild.isBuild();
- const IS_VERCEL = !!process.env.VERCEL;
- /** Inits the Sentry NextJS SDK on node. */
- function init(options) {
- core.addTracingExtensions();
- if (isBuild.isBuild()) {
- return;
- }
- const customDefaultIntegrations = [
- ...node.getDefaultIntegrations(options).filter(
- integration => !['Http', 'OnUncaughtException'].includes(integration.name),
- ),
- rewriteFramesIntegration.rewriteFramesIntegration(),
- new httpIntegration.Http(),
- new onUncaughtExceptionIntegration.OnUncaughtException(),
- ];
- const opts = {
- environment: process.env.SENTRY_ENVIRONMENT || getVercelEnv.getVercelEnv(false) || process.env.NODE_ENV,
- defaultIntegrations: customDefaultIntegrations,
- ...options,
- // Right now we only capture frontend sessions for Next.js
- autoSessionTracking: false,
- };
- if (debugBuild.DEBUG_BUILD && opts.debug) {
- utils.logger.enable();
- }
- debugBuild.DEBUG_BUILD && utils.logger.log('Initializing SDK...');
- if (sdkAlreadyInitialized()) {
- debugBuild.DEBUG_BUILD && utils.logger.log('SDK already initialized');
- return;
- }
- core.applySdkMetadata(opts, 'nextjs', ['nextjs', 'node']);
- node.init(opts);
- const filterTransactions = event => {
- return event.type === 'transaction' && event.transaction === '/404' ? null : event;
- };
- filterTransactions.id = 'NextServer404TransactionFilter';
- const scope = node.getCurrentScope();
- scope.setTag('runtime', 'node');
- if (IS_VERCEL) {
- scope.setTag('vercel', true);
- }
- scope.addEventProcessor(filterTransactions);
- if (process.env.NODE_ENV === 'development') {
- scope.addEventProcessor(devErrorSymbolicationEventProcessor.devErrorSymbolicationEventProcessor);
- }
- debugBuild.DEBUG_BUILD && utils.logger.log('SDK successfully initialized');
- }
- function sdkAlreadyInitialized() {
- return !!core.getClient();
- }
- // TODO (v8): Remove this
- /**
- * @deprecated This constant will be removed in the next major update.
- */
- const deprecatedIsBuild = () => isBuild.isBuild();
- exports.rewriteFramesIntegration = rewriteFramesIntegration.rewriteFramesIntegration;
- exports.createReduxEnhancer = react.createReduxEnhancer;
- 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.withSentry = wrapApiHandlerWithSentry.withSentry;
- exports.withSentryAPI = wrapApiHandlerWithSentry.withSentryAPI;
- exports.wrapApiHandlerWithSentry = wrapApiHandlerWithSentry.wrapApiHandlerWithSentry;
- exports.ErrorBoundary = ErrorBoundary;
- exports.IS_BUILD = IS_BUILD;
- exports.Integrations = Integrations;
- exports.init = init;
- exports.isBuild = deprecatedIsBuild;
- exports.showReportDialog = showReportDialog;
- exports.withErrorBoundary = withErrorBoundary;
- for (const k in node) {
- if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = node[k];
- }
- //# sourceMappingURL=index.js.map
|