Object.defineProperty(exports, '__esModule', { value: true }); const utils = require('@sentry/utils'); const debugBuild = require('../common/debug-build.js'); const globalWithInjectedValues = global ; /** * Applies the `tunnel` option to the Next.js SDK options based on `withSentryConfig`'s `tunnelRoute` option. */ function applyTunnelRouteOption(options) { const tunnelRouteOption = globalWithInjectedValues.__sentryRewritesTunnelPath__; if (tunnelRouteOption && options.dsn) { const dsnComponents = utils.dsnFromString(options.dsn); if (!dsnComponents) { return; } const sentrySaasDsnMatch = dsnComponents.host.match(/^o(\d+)\.ingest\.sentry\.io$/); if (sentrySaasDsnMatch) { const orgId = sentrySaasDsnMatch[1]; const tunnelPath = `${tunnelRouteOption}?o=${orgId}&p=${dsnComponents.projectId}`; options.tunnel = tunnelPath; debugBuild.DEBUG_BUILD && utils.logger.info(`Tunneling events to "${tunnelPath}"`); } else { debugBuild.DEBUG_BUILD && utils.logger.warn('Provided DSN is not a Sentry SaaS DSN. Will not tunnel events.'); } } } exports.applyTunnelRouteOption = applyTunnelRouteOption; //# sourceMappingURL=tunnelRoute.js.map