123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- import { applySdkMetadata, hasTracingEnabled } from '@sentry/core';
- import { Integrations as Integrations$1, init as init$1, getCurrentScope, getDefaultIntegrations as getDefaultIntegrations$1 } from '@sentry/react';
- export * from '@sentry/react';
- import { devErrorSymbolicationEventProcessor } from '../common/devErrorSymbolicationEventProcessor.js';
- import { getVercelEnv } from '../common/getVercelEnv.js';
- import { BrowserTracing, browserTracingIntegration } from './browserTracingIntegration.js';
- export { BrowserTracing, browserTracingIntegration } from './browserTracingIntegration.js';
- import { rewriteFramesIntegration } from './rewriteFramesIntegration.js';
- export { rewriteFramesIntegration } from './rewriteFramesIntegration.js';
- import { applyTunnelRouteOption } from './tunnelRoute.js';
- export { nextRouterInstrumentation } from './routing/nextRoutingInstrumentation.js';
- export { captureUnderscoreErrorException } from '../common/_error.js';
- export { withSentryGetStaticProps, wrapGetStaticPropsWithSentry } from '../common/wrapGetStaticPropsWithSentry.js';
- export { withSentryServerSideGetInitialProps, wrapGetInitialPropsWithSentry } from '../common/wrapGetInitialPropsWithSentry.js';
- export { withSentryServerSideAppGetInitialProps, wrapAppGetInitialPropsWithSentry } from '../common/wrapAppGetInitialPropsWithSentry.js';
- export { withSentryServerSideDocumentGetInitialProps, wrapDocumentGetInitialPropsWithSentry } from '../common/wrapDocumentGetInitialPropsWithSentry.js';
- export { withSentryServerSideErrorGetInitialProps, wrapErrorGetInitialPropsWithSentry } from '../common/wrapErrorGetInitialPropsWithSentry.js';
- export { withSentryGetServerSideProps, wrapGetServerSidePropsWithSentry } from '../common/wrapGetServerSidePropsWithSentry.js';
- export { wrapServerComponentWithSentry } from '../common/wrapServerComponentWithSentry.js';
- export { wrapRouteHandlerWithSentry } from '../common/wrapRouteHandlerWithSentry.js';
- export { wrapApiHandlerWithSentryVercelCrons } from '../common/wrapApiHandlerWithSentryVercelCrons.js';
- export { wrapMiddlewareWithSentry } from '../common/wrapMiddlewareWithSentry.js';
- export { wrapPageComponentWithSentry } from '../common/wrapPageComponentWithSentry.js';
- export { wrapGenerationFunctionWithSentry } from '../common/wrapGenerationFunctionWithSentry.js';
- export { withServerActionInstrumentation } from '../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
- ...Integrations$1,
- 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(true) || process.env.NODE_ENV,
- defaultIntegrations: getDefaultIntegrations(options),
- ...options,
- };
- fixBrowserTracingIntegration(opts);
- applyTunnelRouteOption(opts);
- applySdkMetadata(opts, 'nextjs', ['nextjs', 'react']);
- init$1(opts);
- const scope = 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);
- }
- }
- // 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 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 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 BrowserTracing(options);
- }
- return integrations;
- }
- function getDefaultIntegrations(options) {
- const customDefaultIntegrations = [...getDefaultIntegrations$1(options), 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 (hasTracingEnabled(options)) {
- customDefaultIntegrations.push(browserTracingIntegration());
- }
- }
- return customDefaultIntegrations;
- }
- /**
- * Just a passthrough in case this is imported from the client.
- */
- function withSentryConfig(exportedUserNextConfig) {
- return exportedUserNextConfig;
- }
- export { Integrations, init, withSentryConfig };
- //# sourceMappingURL=index.js.map
|