MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / setupOnce

Function setupOnce

packages/core/src/integrations/functiontostring.ts:17–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15 return {
16 name: INTEGRATION_NAME,
17 setupOnce() {
18 // eslint-disable-next-line @typescript-eslint/unbound-method
19 originalFunctionToString = Function.prototype.toString;
20
21 // intrinsics (like Function.prototype) might be immutable in some environments
22 // e.g. Node with --frozen-intrinsics, XS (an embedded JavaScript engine) or SES (a JavaScript proposal)
23 try {
24 Function.prototype.toString = function (this: WrappedFunction, ...args: unknown[]): string {
25 const originalFunction = getOriginalFunction(this);
26 const context =
27 SETUP_CLIENTS.has(getClient() as Client) && originalFunction !== undefined ? originalFunction : this;
28 return originalFunctionToString.apply(context, args);
29 };
30 } catch {
31 // ignore errors here, just don't patch this
32 }
33 },
34 setup(client) {
35 SETUP_CLIENTS.set(client, true);
36 },

Callers

nothing calls this directly

Calls 4

getOriginalFunctionFunction · 0.90
getClientFunction · 0.90
hasMethod · 0.65
applyMethod · 0.45

Tested by

no test coverage detected