From 1312fbee82b52c6f933cc4dce8998948cb9620ac Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 16 Apr 2024 16:42:22 +0200 Subject: [PATCH 1/2] doc: Add clarifying comment for hub on ACS --- packages/core/src/asyncContext/stackStrategy.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/src/asyncContext/stackStrategy.ts b/packages/core/src/asyncContext/stackStrategy.ts index 4ec7445d1b3e..f4b5e41aecdc 100644 --- a/packages/core/src/asyncContext/stackStrategy.ts +++ b/packages/core/src/asyncContext/stackStrategy.ts @@ -132,9 +132,12 @@ export class AsyncContextStack { */ function getAsyncContextStack(): AsyncContextStack { const registry = getMainCarrier(); + + // For now we continue to keep this as `hub` on the ACS, + // as e.g. the Loader Script relies on this. + // Eventually we may change this if/when we update the loader to not require this field anymore const sentry = getSentryCarrier(registry) as { hub?: AsyncContextStack }; - // If there's no hub, or its an old API, assign a new one if (sentry.hub) { return sentry.hub; } From d17ea9eb3e8b0ca2a9d80c884cbb35a48f6b2cfb Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 16 Apr 2024 17:06:02 +0200 Subject: [PATCH 2/2] better comment --- packages/core/src/asyncContext/stackStrategy.ts | 1 + packages/core/src/sdk.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/asyncContext/stackStrategy.ts b/packages/core/src/asyncContext/stackStrategy.ts index f4b5e41aecdc..05160d685e89 100644 --- a/packages/core/src/asyncContext/stackStrategy.ts +++ b/packages/core/src/asyncContext/stackStrategy.ts @@ -136,6 +136,7 @@ function getAsyncContextStack(): AsyncContextStack { // For now we continue to keep this as `hub` on the ACS, // as e.g. the Loader Script relies on this. // Eventually we may change this if/when we update the loader to not require this field anymore + // Related, we also write to `hub` in {@link ./../sdk.ts registerClientOnGlobalHub} const sentry = getSentryCarrier(registry) as { hub?: AsyncContextStack }; if (sentry.hub) { diff --git a/packages/core/src/sdk.ts b/packages/core/src/sdk.ts index 85fdeae6e4d6..70bf19779c9b 100644 --- a/packages/core/src/sdk.ts +++ b/packages/core/src/sdk.ts @@ -48,11 +48,11 @@ export function setCurrentClient(client: Client): void { } /** - * Unfortunately, we still have to manually bind the client to the "hub" set on the global + * Unfortunately, we still have to manually bind the client to the "hub" property set on the global * Sentry carrier object. This is because certain scripts (e.g. our loader script) obtain * the client via `window.__SENTRY__.hub.getClient()`. * - * @see {@link hub.ts getGlobalHub} + * @see {@link ./asyncContext/stackStrategy.ts getAsyncContextStack} */ function registerClientOnGlobalHub(client: Client): void { const sentryGlobal = getSentryCarrier(getMainCarrier()) as { hub?: AsyncContextStack };