@@ -2,7 +2,6 @@ import type { AsyncContextStack } from './asyncContext/stackStrategy';
22import type { AsyncContextStrategy } from './asyncContext/types' ;
33import type { Scope } from './scope' ;
44import type { Logger } from './utils-hoist/logger' ;
5- import { SDK_VERSION } from './utils-hoist/version' ;
65import { GLOBAL_OBJ } from './utils-hoist/worldwide' ;
76
87/**
@@ -17,6 +16,11 @@ type VersionedCarrier = {
1716 version ?: string ;
1817} & Record < Exclude < string , 'version' > , SentryCarrier > ;
1918
19+ /**
20+ * IMPORTANT - This must be updated if any breaking changes are made to the 'SentryCarrier' interface.
21+ */
22+ const CARRIER_VERSION = '9' ;
23+
2024export interface SentryCarrier {
2125 acs ?: AsyncContextStrategy ;
2226 stack ?: AsyncContextStack ;
@@ -34,10 +38,6 @@ export interface SentryCarrier {
3438
3539/**
3640 * Returns the global shim registry.
37- *
38- * FIXME: This function is problematic, because despite always returning a valid Carrier,
39- * it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check
40- * at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.
4141 **/
4242export function getMainCarrier ( ) : Carrier {
4343 // This ensures a Sentry carrier exists
@@ -50,11 +50,11 @@ export function getSentryCarrier(carrier: Carrier): SentryCarrier {
5050 const __SENTRY__ = ( carrier . __SENTRY__ = carrier . __SENTRY__ || { } ) ;
5151
5252 // For now: First SDK that sets the .version property wins
53- __SENTRY__ . version = __SENTRY__ . version || SDK_VERSION ;
53+ __SENTRY__ . version = __SENTRY__ . version || CARRIER_VERSION ;
5454
5555 // Intentionally populating and returning the version of "this" SDK instance
5656 // rather than what's set in .version so that "this" SDK always gets its carrier
57- return ( __SENTRY__ [ SDK_VERSION ] = __SENTRY__ [ SDK_VERSION ] || { } ) ;
57+ return ( __SENTRY__ [ CARRIER_VERSION ] = __SENTRY__ [ CARRIER_VERSION ] || { } ) ;
5858}
5959
6060/**
@@ -74,7 +74,7 @@ export function getGlobalSingleton<Prop extends keyof SentryCarrier>(
7474 obj = GLOBAL_OBJ ,
7575) : NonNullable < SentryCarrier [ Prop ] > {
7676 const __SENTRY__ = ( obj . __SENTRY__ = obj . __SENTRY__ || { } ) ;
77- const carrier = ( __SENTRY__ [ SDK_VERSION ] = __SENTRY__ [ SDK_VERSION ] || { } ) ;
77+ const carrier = ( __SENTRY__ [ CARRIER_VERSION ] = __SENTRY__ [ CARRIER_VERSION ] || { } ) ;
7878 // Note: We do not want to set `carrier.version` here, as this may be called before any `init` is called, e.g. for the default scopes
7979 return carrier [ name ] || ( carrier [ name ] = creator ( ) ) ;
8080}
0 commit comments