{"version":3,"file":"registerChannelIntegration.js","sources":["../../../src/orchestrion/registerChannelIntegration.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { getClient, GLOBAL_OBJ } from '@sentry/core';\n\n/**\n * Register an orchestrion channel-subscriber integration from an instrumented\n * module. This is the runtime target of the snippet the subscribe-injection\n * transform splices into each transformed package (see\n * `bundler/subscribeInjection.ts`), so a bundler-only SDK (e.g.\n * `@sentry/cloudflare`, running in workerd where requires can't be\n * monkey-patched) wires up subscribers with no runtime module hook.\n *\n * It does two things, covering the two disjoint timing cases:\n *\n * 1. Stores the factory on the global orchestrion marker under `name`, so a\n * later `init()` (a fresh isolate, or a client created after this module\n * loads) picks it up via `getDefaultIntegrations()`.\n * 2. If a client already exists, registers the integration on it right away.\n * This is what makes the mechanism robust against module load order:\n * bundler-only SDKs call `init()` per request, but a package like `mysql`\n * loads its instrumented file lazily on first use, i.e. AFTER that request's\n * `init()` already snapshotted the marker. Without the live add, the first\n * request that touches such a package would publish to a channel nobody\n * subscribed to yet.\n *\n * `addIntegration` dedupes by integration name and only runs `setupOnce` once,\n * so storing AND live-adding never double-subscribes.\n *\n * The marker is a `Map` keyed by `name` (the factory's export name) so a package\n * split across several instrumented files (e.g. `pg`'s JS and native clients, or\n * openai's per-resource `.js`/`.mjs` files) registers its one subscriber once,\n * no matter how many of its files land in the bundle. `.set` on the shared key\n * is idempotent.\n */\nexport function registerOrchestrionChannelIntegration(name: string, integrationFn: () => Integration): void {\n const marker = (GLOBAL_OBJ.__SENTRY_ORCHESTRION__ ??= {});\n (marker.integrations ??= new Map()).set(name, integrationFn);\n getClient()?.addIntegration(integrationFn());\n}\n"],"names":["GLOBAL_OBJ","getClient"],"mappings":";;;;AAiCO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CA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