1 |
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import {\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n} from '@sentry/core';\nimport type { Integration, Options } from '@sentry/types';\nimport { GLOBAL_OBJ, createStackParser, nodeStackLineParser, stackParserFromStackParserOptions } from '@sentry/utils';\n\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport { VercelEdgeClient } from './client';\nimport { winterCGFetchIntegration } from './integrations/wintercg-fetch';\nimport { makeEdgeTransport } from './transports';\nimport type { VercelEdgeClientOptions, VercelEdgeOptions } from './types';\nimport { getVercelEnv } from './utils/vercel';\n\ndeclare const process: {\n env: Record<string, string>;\n};\n\nconst nodeStackParser = createStackParser(nodeStackLineParser());\n\n/** @deprecated Use `getDefaultIntegrations(options)` instead. */\nexport const defaultIntegrations = [\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n linkedErrorsIntegration(),\n winterCGFetchIntegration(),\n];\n\n/** Get the default integrations for the browser SDK. */\nexport function getDefaultIntegrations(options: Options): Integration[] {\n return [\n // eslint-disable-next-line deprecation/deprecation\n ...defaultIntegrations,\n ...(options.sendDefaultPii ? [requestDataIntegration()] : []),\n ];\n}\n\n/** Inits the Sentry NextJS SDK on the Edge Runtime. */\nexport function init(options: VercelEdgeOptions = {}): void {\n setAsyncLocalStorageAsyncContextStrategy();\n\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n if (options.dsn === undefined && process.env.SENTRY_DSN) {\n options.dsn = process.env.SENTRY_DSN;\n }\n\n if (options.tracesSampleRate === undefined && process.env.SENTRY_TRACES_SAMPLE_RATE) {\n const tracesSampleRate = parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE);\n if (isFinite(tracesSampleRate)) {\n options.tracesSampleRate = tracesSampleRate;\n }\n }\n\n if (options.release === undefined) {\n const detectedRelease = getSentryRelease();\n if (detectedRelease !== undefined) {\n options.release = detectedRelease;\n } else {\n // If release is not provided, then we should disable autoSessionTracking\n options.autoSessionTracking = false;\n }\n }\n\n options.environment =\n options.environment || process.env.SENTRY_ENVIRONMENT || getVercelEnv(false) || process.env.NODE_ENV;\n\n if (options.autoSessionTracking === undefined && options.dsn !== undefined) {\n options.autoSessionTracking = true;\n }\n\n if (options.instrumenter === undefined) {\n options.instrumenter = 'sentry';\n }\n\n const clientOptions: VercelEdgeClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || nodeStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeEdgeTransport,\n };\n\n initAndBind(VercelEdgeClient, clientOptions);\n}\n\n/**\n * Returns a release dynamically from environment variables.\n */\nexport function getSentryRelease(fallback?: string): string | undefined {\n // Always read first as Sentry takes this as precedence\n if (process.env.SENTRY_RELEASE) {\n return process.env.SENTRY_RELEASE;\n }\n\n // This supports the variable that sentry-webpack-plugin injects\n if (GLOBAL_OBJ.SENTRY_RELEASE && GLOBAL_OBJ.SENTRY_RELEASE.id) {\n return GLOBAL_OBJ.SENTRY_RELEASE.id;\n }\n\n return (\n // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables\n process.env.GITHUB_SHA ||\n // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables\n process.env.VERCEL_GIT_COMMIT_SHA ||\n process.env.VERCEL_GITHUB_COMMIT_SHA ||\n process.env.VERCEL_GITLAB_COMMIT_SHA ||\n process.env.VERCEL_BITBUCKET_COMMIT_SHA ||\n // Zeit (now known as Vercel)\n process.env.ZEIT_GITHUB_COMMIT_SHA ||\n process.env.ZEIT_GITLAB_COMMIT_SHA ||\n process.env.ZEIT_BITBUCKET_COMMIT_SHA ||\n fallback\n );\n}\n"],"names":[],"mappings":";;;;;;;;AAsBA,MAAM,kBAAkB,iBAAiB,CAAC,mBAAmB,EAAE,CAAC,CAAA;AAChE;AACA;AACO,MAAM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