package.build.esm.carrier.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Base implementation for all Sentry JavaScript SDKs
{"version":3,"file":"carrier.js","sources":["../../src/carrier.ts"],"sourcesContent":["import type { Client, Integration, MetricsAggregator, Scope } from '@sentry/types';\nimport { GLOBAL_OBJ, SDK_VERSION } from '@sentry/utils';\nimport type { AsyncContextStack } from './asyncContext/stackStrategy';\nimport type { AsyncContextStrategy } from './asyncContext/types';\n\n/**\n * An object that contains globally accessible properties and maintains a scope stack.\n * @hidden\n */\nexport interface Carrier {\n __SENTRY__?: VersionedCarrier;\n}\n\ntype VersionedCarrier = {\n version?: string;\n} & Record, SentryCarrier>;\n\ninterface SentryCarrier {\n acs?: AsyncContextStrategy;\n stack?: AsyncContextStack;\n\n globalScope?: Scope;\n defaultIsolationScope?: Scope;\n defaultCurrentScope?: Scope;\n globalMetricsAggregators?: WeakMap | undefined;\n\n // TODO(v9): Remove these properties - they are no longer used and were left over in v8\n integrations?: Integration[];\n extensions?: {\n // eslint-disable-next-line @typescript-eslint/ban-types\n [key: string]: Function;\n };\n}\n\n/**\n * Returns the global shim registry.\n *\n * FIXME: This function is problematic, because despite always returning a valid Carrier,\n * it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check\n * at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.\n **/\nexport function getMainCarrier(): Carrier {\n // This ensures a Sentry carrier exists\n getSentryCarrier(GLOBAL_OBJ);\n return GLOBAL_OBJ;\n}\n\n/** Will either get the existing sentry carrier, or create a new one. */\nexport function getSentryCarrier(carrier: Carrier): SentryCarrier {\n const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {});\n\n // For now: First SDK that sets the .version property wins\n __SENTRY__.version = __SENTRY__.version || SDK_VERSION;\n\n // Intentionally populating and returning the version of \"this\" SDK instance\n // rather than what's set in .version so that \"this\" SDK always gets its carrier\n return (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});\n}\n"],"names":[],"mappings":";;AAKA;AACA;AACA;AACA;;AA0BA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,GAAY;AAC1C;AACA,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;AAC9B,EAAE,OAAO,UAAU,CAAA;AACnB,CAAA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,OAAO,EAA0B;AAClE,EAAE,MAAM,UAAA,IAAc,OAAO,CAAC,UAAA,GAAa,OAAO,CAAC,UAAA,IAAc,EAAE,CAAC,CAAA;AACpE;AACA;AACA,EAAE,UAAU,CAAC,OAAQ,GAAE,UAAU,CAAC,OAAA,IAAW,WAAW,CAAA;AACxD;AACA;AACA;AACA,EAAE,QAAQ,UAAU,CAAC,WAAW,CAAE,GAAE,UAAU,CAAC,WAAW,CAAA,IAAK,EAAE,EAAC;AAClE;;;;"}