Skip to content

Commit 07c6838

Browse files
authored
fix(core): Avoid looking up client for hasTracingEnabled() if possible (#12066)
This is a bit weird in that we access the current scope & client etc., even if options are passed. Since we also use this method in `init()` before we have setup stuff, it seems safer to avoid calling this at all if possible. This is related to #12054, but not really the cause of it.
1 parent 677602f commit 07c6838

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/core/src/utils/hasTracingEnabled.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export function hasTracingEnabled(
1616
return false;
1717
}
1818

19-
const client = getClient();
20-
const options = maybeOptions || (client && client.getOptions());
19+
const options = maybeOptions || getClientOptions();
2120
return !!options && (options.enableTracing || 'tracesSampleRate' in options || 'tracesSampler' in options);
2221
}
22+
23+
function getClientOptions(): Options | undefined {
24+
const client = getClient();
25+
return client && client.getOptions();
26+
}

0 commit comments

Comments
 (0)