123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- Object.defineProperty(exports, '__esModule', { value: true });
- const core = require('@sentry/core');
- const utils = require('@sentry/utils');
- const async = require('./async.js');
- const client = require('./client.js');
- const wintercgFetch = require('./integrations/wintercg-fetch.js');
- const index = require('./transports/index.js');
- const vercel = require('./utils/vercel.js');
- const nodeStackParser = utils.createStackParser(utils.nodeStackLineParser());
- const defaultIntegrations = [
- core.inboundFiltersIntegration(),
- core.functionToStringIntegration(),
- core.linkedErrorsIntegration(),
- wintercgFetch.winterCGFetchIntegration(),
- ];
- function getDefaultIntegrations(options) {
- return [
-
- ...defaultIntegrations,
- ...(options.sendDefaultPii ? [core.requestDataIntegration()] : []),
- ];
- }
- function init(options = {}) {
- async.setAsyncLocalStorageAsyncContextStrategy();
- if (options.defaultIntegrations === undefined) {
- options.defaultIntegrations = getDefaultIntegrations(options);
- }
- if (options.dsn === undefined && process.env.SENTRY_DSN) {
- options.dsn = process.env.SENTRY_DSN;
- }
- if (options.tracesSampleRate === undefined && process.env.SENTRY_TRACES_SAMPLE_RATE) {
- const tracesSampleRate = parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE);
- if (isFinite(tracesSampleRate)) {
- options.tracesSampleRate = tracesSampleRate;
- }
- }
- if (options.release === undefined) {
- const detectedRelease = getSentryRelease();
- if (detectedRelease !== undefined) {
- options.release = detectedRelease;
- } else {
-
- options.autoSessionTracking = false;
- }
- }
- options.environment =
- options.environment || process.env.SENTRY_ENVIRONMENT || vercel.getVercelEnv(false) || process.env.NODE_ENV;
- if (options.autoSessionTracking === undefined && options.dsn !== undefined) {
- options.autoSessionTracking = true;
- }
- if (options.instrumenter === undefined) {
- options.instrumenter = 'sentry';
- }
- const clientOptions = {
- ...options,
- stackParser: utils.stackParserFromStackParserOptions(options.stackParser || nodeStackParser),
- integrations: core.getIntegrationsToSetup(options),
- transport: options.transport || index.makeEdgeTransport,
- };
- core.initAndBind(client.VercelEdgeClient, clientOptions);
- }
- function getSentryRelease(fallback) {
-
- if (process.env.SENTRY_RELEASE) {
- return process.env.SENTRY_RELEASE;
- }
-
- if (utils.GLOBAL_OBJ.SENTRY_RELEASE && utils.GLOBAL_OBJ.SENTRY_RELEASE.id) {
- return utils.GLOBAL_OBJ.SENTRY_RELEASE.id;
- }
- return (
-
- process.env.GITHUB_SHA ||
-
- process.env.VERCEL_GIT_COMMIT_SHA ||
- process.env.VERCEL_GITHUB_COMMIT_SHA ||
- process.env.VERCEL_GITLAB_COMMIT_SHA ||
- process.env.VERCEL_BITBUCKET_COMMIT_SHA ||
-
- process.env.ZEIT_GITHUB_COMMIT_SHA ||
- process.env.ZEIT_GITLAB_COMMIT_SHA ||
- process.env.ZEIT_BITBUCKET_COMMIT_SHA ||
- fallback
- );
- }
- exports.defaultIntegrations = defaultIntegrations;
- exports.getDefaultIntegrations = getDefaultIntegrations;
- exports.getSentryRelease = getSentryRelease;
- exports.init = init;
|