package.build.esm.integrations.functiontostring.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Base implementation for all Sentry JavaScript SDKs
{"version":3,"file":"functiontostring.js","sources":["../../../src/integrations/functiontostring.ts"],"sourcesContent":["import type { Client, IntegrationFn, WrappedFunction } from '@sentry/types';\nimport { getOriginalFunction } from '@sentry/utils';\nimport { getClient } from '../currentScopes';\nimport { defineIntegration } from '../integration';\n\nlet originalFunctionToString: () => void;\n\nconst INTEGRATION_NAME = 'FunctionToString';\n\nconst SETUP_CLIENTS = new WeakMap();\n\nconst _functionToStringIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n originalFunctionToString = Function.prototype.toString;\n\n // intrinsics (like Function.prototype) might be immutable in some environments\n // e.g. Node with --frozen-intrinsics, XS (an embedded JavaScript engine) or SES (a JavaScript proposal)\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Function.prototype.toString = function (this: WrappedFunction, ...args: any[]): string {\n const originalFunction = getOriginalFunction(this);\n const context =\n SETUP_CLIENTS.has(getClient() as Client) && originalFunction !== undefined ? originalFunction : this;\n return originalFunctionToString.apply(context, args);\n };\n } catch {\n // ignore errors here, just don't patch this\n }\n },\n setup(client) {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Patch toString calls to return proper name for wrapped functions.\n *\n * ```js\n * Sentry.init({\n * integrations: [\n * functionToStringIntegration(),\n * ],\n * });\n * ```\n */\nexport const functionToStringIntegration = defineIntegration(_functionToStringIntegration);\n"],"names":[],"mappings":";;;;AAKA,IAAI,wBAAwB,CAAA;AAC5B;AACA,MAAM,gBAAA,GAAmB,kBAAkB,CAAA;AAC3C;AACA,MAAM,aAAc,GAAE,IAAI,OAAO,EAAmB,CAAA;AACpD;AACA,MAAM,4BAA6B,IAAG,MAAM;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB;AACA,MAAM,2BAA2B,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAA;AAC5D;AACA;AACA;AACA,MAAM,IAAI;AACV;AACA,QAAQ,QAAQ,CAAC,SAAS,CAAC,QAAS,GAAE,WAAiC,GAAG,IAAI,EAAiB;AAC/F,UAAU,MAAM,gBAAiB,GAAE,mBAAmB,CAAC,IAAI,CAAC,CAAA;AAC5D,UAAU,MAAM,OAAQ;AACxB,YAAY,aAAa,CAAC,GAAG,CAAC,SAAS,EAAC,EAAa,IAAG,qBAAqB,SAAA,GAAY,gBAAA,GAAmB,IAAI,CAAA;AAChH,UAAU,OAAO,wBAAwB,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AAC9D,SAAS,CAAA;AACT,QAAQ,OAAM,CAAA,EAAA;AACd;AACA,OAAM;AACN,KAAK;AACL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AACrC,KAAK;AACL,GAAG,CAAA;AACH,CAAC,CAAE,EAAA;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,2BAA4B,GAAE,iBAAiB,CAAC,4BAA4B;;;;"}