UNPKG

@sentry/core

Version:
38 lines (35 loc) 1.21 kB
import { getClient } from '../currentScopes.js'; import { defineIntegration } from '../integration.js'; import { getOriginalFunction } from '../utils/object.js'; const INTEGRATION_NAME = "FunctionToString"; const SETUP_CLIENTS = /* @__PURE__ */ new WeakMap(); const _functionToStringIntegration = (() => { return { name: INTEGRATION_NAME, setupOnce() { const originalFunctionToString = Function.prototype.toString; try { Function.prototype.toString = new Proxy(originalFunctionToString, { apply(target, thisArg, args) { const originalFunction = getOriginalFunction(thisArg); let context = thisArg; try { if (SETUP_CLIENTS.has(getClient()) && originalFunction) { context = originalFunction; } } catch { } return Reflect.apply(target, context, args); } }); } catch { } }, setup(client) { SETUP_CLIENTS.set(client, true); } }; }); const functionToStringIntegration = defineIntegration(_functionToStringIntegration); export { functionToStringIntegration }; //# sourceMappingURL=functiontostring.js.map