Skip to content

Commit 2ebe592

Browse files
committed
ref(core)!: Remove backwards compatible SentryCarrier type
I do not really think this is breaking or has any impact on any user code, but to be on the safe side, we can remove this in v9.
1 parent 7bf602c commit 2ebe592

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

packages/core/src/utils-hoist/worldwide.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,6 @@ interface SentryCarrier {
3434
decodePolyfill?: (input: Uint8Array) => string;
3535
}
3636

37-
// TODO(v9): Clean up or remove this type
38-
type BackwardsCompatibleSentryCarrier = SentryCarrier & {
39-
// pre-v7 hub (replaced by .stack)
40-
hub: any;
41-
integrations?: any[];
42-
logger: any;
43-
extensions?: {
44-
/** Extension methods for the hub, which are bound to the current Hub instance */
45-
// eslint-disable-next-line @typescript-eslint/ban-types
46-
[key: string]: Function;
47-
};
48-
};
49-
5037
/** Internal global with common properties and Sentry extensions */
5138
export type InternalGlobal = {
5239
navigator?: { userAgent?: string };
@@ -75,7 +62,7 @@ export type InternalGlobal = {
7562
_sentryDebugIds?: Record<string, string>;
7663
__SENTRY__: Record<Exclude<string, 'version'>, SentryCarrier> & {
7764
version?: string;
78-
} & BackwardsCompatibleSentryCarrier;
65+
};
7966
/**
8067
* Raw module metadata that is injected by bundler plugins.
8168
*
@@ -99,9 +86,15 @@ export const GLOBAL_OBJ = globalThis as unknown as InternalGlobal;
9986
* @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value
10087
* @returns the singleton
10188
*/
102-
export function getGlobalSingleton<T>(name: keyof SentryCarrier, creator: () => T, obj?: unknown): T {
103-
const gbl = (obj || GLOBAL_OBJ) as InternalGlobal;
104-
const __SENTRY__ = (gbl.__SENTRY__ = gbl.__SENTRY__ || {});
89+
export function getGlobalSingleton<T>(name: keyof SentryCarrier, creator: () => T, obj = GLOBAL_OBJ): T {
90+
const __SENTRY__ = getSentryCarrierObj(obj);
10591
const versionedCarrier = (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});
10692
return versionedCarrier[name] || (versionedCarrier[name] = creator());
10793
}
94+
95+
function getSentryCarrierObj(
96+
obj: Omit<InternalGlobal, '__SENTRY__'> & Partial<Pick<InternalGlobal, '__SENTRY__'>>,
97+
): InternalGlobal['__SENTRY__'] {
98+
// Set the Sentry carrier, if it does not exist yet
99+
return obj.__SENTRY__ || (obj.__SENTRY__ = {});
100+
}

0 commit comments

Comments
 (0)