1 |
- {"version":3,"file":"extensions.js","sources":["../../src/extensions.ts"],"sourcesContent":["import { addTracingExtensions, getMainCarrier } from '@sentry/core';\nimport type { Integration, IntegrationClass } from '@sentry/types';\nimport { dynamicRequire, isNodeEnv, loadModule } from '@sentry/utils';\n\n/**\n * @private\n */\nfunction _autoloadDatabaseIntegrations(): void {\n const carrier = getMainCarrier();\n if (!carrier.__SENTRY__) {\n return;\n }\n\n const packageToIntegrationMapping: Record<string, () => Integration> = {\n mongodb() {\n const integration = dynamicRequire(module, './node/integrations/mongo') as {\n Mongo: IntegrationClass<Integration>;\n };\n return new integration.Mongo();\n },\n mongoose() {\n const integration = dynamicRequire(module, './node/integrations/mongo') as {\n Mongo: IntegrationClass<Integration>;\n };\n return new integration.Mongo();\n },\n mysql() {\n const integration = dynamicRequire(module, './node/integrations/mysql') as {\n Mysql: IntegrationClass<Integration>;\n };\n return new integration.Mysql();\n },\n pg() {\n const integration = dynamicRequire(module, './node/integrations/postgres') as {\n Postgres: IntegrationClass<Integration>;\n };\n return new integration.Postgres();\n },\n };\n\n const mappedPackages = Object.keys(packageToIntegrationMapping)\n .filter(moduleName => !!loadModule(moduleName))\n .map(pkg => {\n try {\n return packageToIntegrationMapping[pkg]();\n } catch (e) {\n return undefined;\n }\n })\n .filter(p => p) as Integration[];\n\n if (mappedPackages.length > 0) {\n carrier.__SENTRY__.integrations = [...(carrier.__SENTRY__.integrations || []), ...mappedPackages];\n }\n}\n\n/**\n * This patches the global object and injects the Tracing extensions methods\n */\nexport function addExtensionMethods(): void {\n addTracingExtensions();\n\n // Detect and automatically load specified integrations.\n if (isNodeEnv()) {\n _autoloadDatabaseIntegrations();\n }\n}\n"],"names":[],"mappings":";;;AAIA;AACA;AACA;AACA,SAAS,6BAA6B,GAAS;AAC/C,EAAE,MAAM,OAAA,GAAU,cAAc,EAAE,CAAA;AAClC,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;AAC3B,IAAI,OAAM;AACV,GAAE;AACF;AACA,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