@sentry/cloudflare 11.13.0 → 11.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/build/cjs/dev/baseSdk.js.map +1 -1
  2. package/build/cjs/dev/client.js +17 -2
  3. package/build/cjs/dev/client.js.map +1 -1
  4. package/build/cjs/dev/durableobject.js.map +1 -1
  5. package/build/cjs/dev/options.js +1 -0
  6. package/build/cjs/dev/options.js.map +1 -1
  7. package/build/cjs/dev/orchestrion-deferred-channels.js +6 -2
  8. package/build/cjs/dev/orchestrion-deferred-channels.js.map +1 -1
  9. package/build/cjs/dev/vite/autoInstrument.js +5 -1
  10. package/build/cjs/dev/vite/autoInstrument.js.map +1 -1
  11. package/build/cjs/dev/vite/index.js.map +1 -1
  12. package/build/cjs/dev/vite/transform.js +12 -13
  13. package/build/cjs/dev/vite/transform.js.map +1 -1
  14. package/build/cjs/dev/vite/wranglerConfig.js +2 -0
  15. package/build/cjs/dev/vite/wranglerConfig.js.map +1 -1
  16. package/build/cjs/prod/baseSdk.js.map +1 -1
  17. package/build/cjs/prod/client.js +17 -2
  18. package/build/cjs/prod/client.js.map +1 -1
  19. package/build/cjs/prod/durableobject.js.map +1 -1
  20. package/build/cjs/prod/options.js +1 -0
  21. package/build/cjs/prod/options.js.map +1 -1
  22. package/build/cjs/prod/orchestrion-deferred-channels.js +6 -2
  23. package/build/cjs/prod/orchestrion-deferred-channels.js.map +1 -1
  24. package/build/cjs/prod/vite/autoInstrument.js +5 -1
  25. package/build/cjs/prod/vite/autoInstrument.js.map +1 -1
  26. package/build/cjs/prod/vite/index.js.map +1 -1
  27. package/build/cjs/prod/vite/transform.js +12 -13
  28. package/build/cjs/prod/vite/transform.js.map +1 -1
  29. package/build/cjs/prod/vite/wranglerConfig.js +2 -0
  30. package/build/cjs/prod/vite/wranglerConfig.js.map +1 -1
  31. package/build/esm/dev/baseSdk.js.map +1 -1
  32. package/build/esm/dev/client.js +18 -3
  33. package/build/esm/dev/client.js.map +1 -1
  34. package/build/esm/dev/durableobject.js.map +1 -1
  35. package/build/esm/dev/options.js +1 -0
  36. package/build/esm/dev/options.js.map +1 -1
  37. package/build/esm/dev/orchestrion-deferred-channels.js +7 -3
  38. package/build/esm/dev/orchestrion-deferred-channels.js.map +1 -1
  39. package/build/esm/dev/package.json +1 -1
  40. package/build/esm/dev/vite/autoInstrument.js +5 -1
  41. package/build/esm/dev/vite/autoInstrument.js.map +1 -1
  42. package/build/esm/dev/vite/index.js.map +1 -1
  43. package/build/esm/dev/vite/transform.js +12 -13
  44. package/build/esm/dev/vite/transform.js.map +1 -1
  45. package/build/esm/dev/vite/wranglerConfig.js +2 -0
  46. package/build/esm/dev/vite/wranglerConfig.js.map +1 -1
  47. package/build/esm/prod/baseSdk.js.map +1 -1
  48. package/build/esm/prod/client.js +18 -3
  49. package/build/esm/prod/client.js.map +1 -1
  50. package/build/esm/prod/durableobject.js.map +1 -1
  51. package/build/esm/prod/options.js +1 -0
  52. package/build/esm/prod/options.js.map +1 -1
  53. package/build/esm/prod/orchestrion-deferred-channels.js +7 -3
  54. package/build/esm/prod/orchestrion-deferred-channels.js.map +1 -1
  55. package/build/esm/prod/package.json +1 -1
  56. package/build/esm/prod/vite/autoInstrument.js +5 -1
  57. package/build/esm/prod/vite/autoInstrument.js.map +1 -1
  58. package/build/esm/prod/vite/index.js.map +1 -1
  59. package/build/esm/prod/vite/transform.js +12 -13
  60. package/build/esm/prod/vite/transform.js.map +1 -1
  61. package/build/esm/prod/vite/wranglerConfig.js +2 -0
  62. package/build/esm/prod/vite/wranglerConfig.js.map +1 -1
  63. package/build/types/baseSdk.d.ts.map +1 -1
  64. package/build/types/client.d.ts +8 -0
  65. package/build/types/client.d.ts.map +1 -1
  66. package/build/types/durableobject.d.ts.map +1 -1
  67. package/build/types/options.d.ts.map +1 -1
  68. package/build/types/orchestrion-deferred-channels.d.ts.map +1 -1
  69. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  70. package/build/types/vite/index.d.ts +3 -0
  71. package/build/types/vite/index.d.ts.map +1 -1
  72. package/build/types/vite/transform.d.ts +12 -2
  73. package/build/types/vite/transform.d.ts.map +1 -1
  74. package/build/types/vite/wranglerConfig.d.ts +8 -0
  75. package/build/types/vite/wranglerConfig.d.ts.map +1 -1
  76. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","names":[],"sources":["../../../../src/vite/transform.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport MagicString from 'magic-string';\nimport { DEFAULT_EXPORT, type ExportName, type SameWorkerBinding } from './wranglerConfig';\nimport { detectWorkerEntrypointClasses } from './workerEntrypoint';\n\nconst MERGED_OPTIONS_IDENTIFIER = '__SENTRY_OPTIONS__';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node types for the AST nodes we inspect.\n// ---------------------------------------------------------------------------\n\nexport interface BaseNode {\n type: string;\n start: number;\n end: number;\n}\n\nexport interface ProgramBody {\n body: BaseNode[];\n}\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface CalleeNode {\n type: string;\n name?: string;\n property?: { type: string; name?: string };\n}\n\ninterface CallExpressionNode extends BaseNode {\n callee?: CalleeNode;\n}\n\ninterface ClassDeclarationNode extends BaseNode {\n id?: IdentifierNode | null;\n}\n\ninterface ExportDefaultNode extends BaseNode {\n declaration: BaseNode;\n}\n\ninterface ExportSpecifierNode extends BaseNode {\n local?: { type: string; name?: string };\n exported?: { type: string; name?: string };\n}\n\ninterface ExportNamedNode extends BaseNode {\n declaration?: BaseNode | null;\n source?: BaseNode | null;\n specifiers?: ExportSpecifierNode[];\n}\n\ninterface VariableDeclaratorNode {\n id?: { type: string; name?: string };\n init?: BaseNode | null;\n}\n\ninterface VariableDeclarationNode extends BaseNode {\n declarations?: VariableDeclaratorNode[];\n}\n\ninterface ImportDeclarationNode extends BaseNode {\n specifiers?: Array<{ local?: { type: string; name?: string } }>;\n}\n\nfunction isCallToMethod(node: BaseNode, methodName: string): boolean {\n if (node.type !== 'CallExpression') return false;\n const callee = (node as CallExpressionNode).callee;\n if (!callee) return false;\n if (callee.type === 'Identifier' && callee.name === methodName) return true;\n return (\n callee.type === 'MemberExpression' && callee.property?.type === 'Identifier' && callee.property.name === methodName\n );\n}\n\n/**\n * The kind of Sentry wrapper to apply to an exported class.\n *\n * `durableObject` and `workflow` are keyed by name from the wrangler config\n * (`durable_objects.bindings`, `workflows`), since those class names are\n * authoritative there. `workerEntrypoint` is different: a worker's own\n * entrypoints aren't enumerated in its config, so they're detected structurally\n * (a class extending `WorkerEntrypoint` from `cloudflare:workers`), with the\n * config providing only a fallback for self-bound entrypoints whose base class\n * lives in another module.\n */\nexport type ClassWrapperKind = 'durableObject' | 'agent' | 'workflow' | 'workerEntrypoint';\n\n/** Specifier name a `export { default as X } from '...'` re-export uses for the source's default. */\nconst DEFAULT_IMPORT = 'default';\n\n/**\n * The `@sentry/cloudflare` helper each wrapper kind emits. All share the same\n * `(optionsCallback, Class)` signature. `WorkerEntrypoint` classes use\n * `withSentry`, which runtime-detects the class type and routes accordingly.\n */\nconst WRAPPER_METHODS: Record<ClassWrapperKind, string> = {\n durableObject: 'instrumentDurableObjectWithSentry',\n agent: 'instrumentAgentWithSentry',\n workflow: 'instrumentWorkflowWithSentry',\n workerEntrypoint: 'withSentry',\n};\n\nexport interface TransformContext {\n /**\n * Exported class name → the kind of Sentry wrapper to apply. Populated from\n * the wrangler config, so the transform can wrap by name without resolving\n * each class's base type.\n */\n classWrappers: Map<string, ClassWrapperKind>;\n /**\n * Local class names detected as `agents` Agents. An Agent is configured as a Durable Object in\n * wrangler, so this upgrades those entries from `durableObject` to `agent`.\n */\n agentClasses?: ReadonlySet<string>;\n optionsFn: string;\n /** Import statement prepended when `optionsFn` references a separate module. */\n optionsImport?: string;\n /** Module the generated code imports `withSentry` and the class wrappers from. Defaults to `@sentry/cloudflare`. */\n sentryModule?: string;\n /** @see {@link import('./wranglerConfig').WranglerConfig.sameWorkerBindings} */\n sameWorkerBindings?: readonly SameWorkerBinding[];\n}\n\nexport interface TransformResult {\n code: string;\n map: ReturnType<MagicString['generateMap']>;\n /**\n * The configured class names that were actually wrapped. Lets the plugin warn\n * about configured classes it could not find, instead of silently leaving\n * them uninstrumented.\n */\n wrappedClasses: Set<string>;\n}\n\n/**\n * Rewrite the worker entry source to wrap its default export with `withSentry`\n * and any configured class export with its matching Sentry wrapper (see\n * {@link TransformContext.classWrappers}, e.g. Durable Object classes with\n * `instrumentDurableObjectWithSentry`).\n *\n * Handles `export class MyDO {}`, the specifier form (`class MyDO {}` …\n * `export { MyDO }` / `export { Foo as MyDO }`), and classes that live in\n * another module (`import { MyDO } from './do'; export { MyDO }` or\n * `export { MyDO } from './do'`). Only star re-exports (`export * from './do'`)\n * are left alone — the plugin warns about those via\n * {@link TransformResult.wrappedClasses}.\n *\n * Exported (rather than inlined into the plugin) so it can be unit-tested with a\n * plain AST and no Vite context. Returns `undefined` when nothing was wrapped and\n * there are no already-manually-wrapped classes to report.\n */\nexport function applyAutoInstrumentTransforms(\n code: string,\n ast: ProgramBody,\n ctx: TransformContext,\n): TransformResult | undefined {\n const ms = new MagicString(code);\n const topLevelClasses = collectTopLevelClasses(ast);\n const sameWorkerBindings = ctx.sameWorkerBindings ?? [];\n const state: TransformState = {\n ms,\n needsImport: false,\n wrappedClasses: new Set<string>(),\n topLevelClasses,\n wrappedLocals: new Map<string, string>(),\n classWrappers: ctx.classWrappers,\n agentClasses: ctx.agentClasses ?? new Set<string>(),\n workerEntrypointClasses: detectWorkerEntrypointClasses(ast),\n // The identifier must be chosen before wrapping, which bindings survive is only known after.\n optionsFn: sameWorkerBindings.length > 0 ? MERGED_OPTIONS_IDENTIFIER : ctx.optionsFn,\n autoWrapped: new Set<ExportName>(),\n manuallyWrappedLocals: collectManuallyWrappedLocals(ast),\n declaringStatements: collectDeclaringStatements(ast),\n };\n const { wrappedClasses } = state;\n\n // Named exports first, regardless of source order: the default-export handler\n // needs to know which local bindings a named export already wrapped, so it can\n // skip a class that is both exported by name and re-exported as default (which\n // would otherwise wrap it twice).\n for (const node of ast.body) {\n if (node.type === 'ExportNamedDeclaration') {\n handleNamedExport(node, ctx, state);\n }\n }\n for (const node of ast.body) {\n if (node.type === 'ExportDefaultDeclaration') {\n wrapDefaultExport(node as ExportDefaultNode, ctx, state);\n }\n }\n\n if (!state.needsImport) {\n // Nothing was rewritten. Still surface any classes found already wrapped\n // manually (via `wrappedClasses`) so the caller doesn't warn about them;\n // return undefined only when there was nothing to report either.\n if (wrappedClasses.size === 0) return undefined;\n return { code, map: ms.generateMap({ hires: true }), wrappedClasses };\n }\n\n // `prepend` inserts before earlier prepends, yielding: Sentry import, options import, declaration.\n if (sameWorkerBindings.length > 0) {\n ms.prepend(buildMergedOptionsDeclaration(sameWorkerBindings, ctx.optionsFn, state));\n }\n if (ctx.optionsImport) ms.prepend(ctx.optionsImport);\n ms.prepend(`import * as __SENTRY__ from '${ctx.sentryModule ?? '@sentry/cloudflare'}';\\n`);\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ hires: true }),\n wrappedClasses,\n };\n}\n\ninterface TransformState {\n ms: MagicString;\n needsImport: boolean;\n wrappedClasses: Set<string>;\n /**\n * Top-level class declarations, exported or not, so specifier exports like\n * `export { MyDO }` can locate the class they refer to.\n */\n topLevelClasses: Map<string, ClassDeclarationNode>;\n /**\n * Local class name → the binding holding its wrapper, so two exports of the same class share one\n * wrapper and a default export of it can be re-pointed.\n */\n wrappedLocals: Map<string, string>;\n /** Class name → wrapper kind, keyed by the *exported* name (from config). */\n classWrappers: Map<string, ClassWrapperKind>;\n /** Local class names detected as `agents` Agents (see {@link TransformContext.agentClasses}). */\n agentClasses: ReadonlySet<string>;\n /**\n * Local class names detected as `WorkerEntrypoint` subclasses in this module,\n * so they can be wrapped without a config entry.\n */\n workerEntrypointClasses: Set<string>;\n optionsFn: string;\n /**\n * Export names wrapped by this transform, so their options can be extended with\n * `rpcTracePropagationBindings`. Hand-wrapped exports stay out, they keep the options they were\n * wrapped with. `wrappedClasses` counts both.\n */\n autoWrapped: Set<ExportName>;\n /**\n * Top-level bindings already assigned an `instrument*WithSentry(...)` result\n * (`const MyDO = instrumentDurableObjectWithSentry(...)`). Exporting one by\n * specifier must report it as wrapped rather than wrap it a second time.\n */\n manuallyWrappedLocals: Set<string>;\n /** Top-level binding name → the statement that declares it. */\n declaringStatements: Map<string, BaseNode>;\n}\n\n/**\n * Builds the callback that merges same-worker binding names into `rpcTracePropagationBindings` at\n * runtime, the options object only exists once the callback runs with `env`. Only bindings whose\n * class this transform wrapped survive, a hand-wrapped class runs on its own options.\n */\nfunction buildMergedOptionsDeclaration(\n sameWorkerBindings: readonly SameWorkerBinding[],\n optionsFn: string,\n state: TransformState,\n): string {\n const bindingNames = sameWorkerBindings\n .filter(({ className }) => state.autoWrapped.has(className))\n .map(({ bindingName }) => bindingName);\n\n if (!bindingNames.length) {\n return `const ${MERGED_OPTIONS_IDENTIFIER} = ${optionsFn};\\n`;\n }\n\n const names = bindingNames.map(name => JSON.stringify(name)).join(', ');\n return (\n `const ${MERGED_OPTIONS_IDENTIFIER} = (env) => { ` +\n `const opts = (${optionsFn})(env); ` +\n `return { ...opts, rpcTracePropagationBindings: [${names}, ...(opts?.rpcTracePropagationBindings ?? [])] }; };\\n`\n );\n}\n\n/**\n * Resolve the wrapper kind for a class export.\n *\n * Config (`classWrappers`) wins — it's authoritative for Durable Objects and\n * Workflows, and provides the self-binding fallback for WorkerEntrypoints whose\n * base class this module can't see. Otherwise a structurally-detected\n * `WorkerEntrypoint` subclass (matched by its *local* name) gets wrapped with\n * `withSentry`.\n *\n * `localName` is the binding **in this module** the export refers to, and must be\n * left undefined for `export { X } from '...'`: there the specifier's name belongs\n * to the source module, so matching it against anything detected here would wrap a\n * class that merely shares a name.\n *\n * The one case where config is refined rather than obeyed is an `agents` Agent:\n * it *is* a Durable Object, so wrangler can only ever describe it as one, and\n * only the detected base chain distinguishes the two.\n */\nfunction resolveWrapperKind(\n exportedName: string,\n localName: string | undefined,\n state: TransformState,\n): ClassWrapperKind | undefined {\n const configured = state.classWrappers.get(exportedName);\n\n if (\n configured === 'durableObject' &&\n ((localName && state.agentClasses.has(localName)) || state.agentClasses.has(exportedName))\n ) {\n return 'agent';\n }\n\n if (configured) return configured;\n if (localName && state.workerEntrypointClasses.has(localName)) return 'workerEntrypoint';\n return undefined;\n}\n\n/**\n * Top-level `const X = instrument*WithSentry(...)` bindings — a hand-wrapped class that is exported\n * separately (`export { X }`) rather than inline.\n */\nfunction collectManuallyWrappedLocals(ast: ProgramBody): Set<string> {\n const wrapperMethods = Object.values(WRAPPER_METHODS);\n const locals = new Set<string>();\n\n for (const node of ast.body) {\n const declaration = declarationOf(node);\n if (declaration?.type !== 'VariableDeclaration') continue;\n for (const declarator of (declaration as VariableDeclarationNode).declarations ?? []) {\n const name = declarator.id?.type === 'Identifier' ? declarator.id.name : undefined;\n const init = declarator.init;\n if (name && init && wrapperMethods.some(method => isCallToMethod(init, method))) {\n locals.add(name);\n }\n }\n }\n\n return locals;\n}\n\nfunction collectDeclaringStatements(ast: ProgramBody): Map<string, BaseNode> {\n const statements = new Map<string, BaseNode>();\n for (const node of ast.body) {\n const declaration = declarationOf(node);\n if (!declaration) continue;\n const ids =\n declaration.type === 'VariableDeclaration'\n ? ((declaration as VariableDeclarationNode).declarations ?? []).map(declarator => declarator.id)\n : declaration.type === 'ImportDeclaration'\n ? ((declaration as ImportDeclarationNode).specifiers ?? []).map(specifier => specifier.local)\n : [(declaration as ClassDeclarationNode).id];\n for (const id of ids) {\n if (id?.type === 'Identifier' && id.name) statements.set(id.name, node);\n }\n }\n return statements;\n}\n\nfunction collectTopLevelClasses(ast: ProgramBody): Map<string, ClassDeclarationNode> {\n const classes = new Map<string, ClassDeclarationNode>();\n for (const node of ast.body) {\n const declaration = declarationOf(node);\n if (declaration?.type !== 'ClassDeclaration') continue;\n const classNode = declaration as ClassDeclarationNode;\n if (classNode.id?.name) classes.set(classNode.id.name, classNode);\n }\n return classes;\n}\n\n/** The declaration a top-level statement makes, looking through `export` (`export const x = ...`). */\nfunction declarationOf(node: BaseNode): BaseNode | null | undefined {\n return node.type === 'ExportNamedDeclaration' ? (node as ExportNamedNode).declaration : node;\n}\n\nfunction wrapDefaultExport(node: ExportDefaultNode, ctx: TransformContext, state: TransformState): void {\n const decl = node.declaration;\n\n // Already wrapped — leave it alone\n if (isCallToMethod(decl, 'withSentry')) return;\n\n // `export default Foo` where `Foo` is a local class already wrapped by a named\n // export (e.g. a self-bound WorkerEntrypoint also used as the default handler).\n // Wrapping again would produce `withSentry(withSentry(...))`, so the default\n // export is re-pointed at the wrapper binding the named export created.\n if (decl.type === 'Identifier') {\n const wrappedName = state.wrappedLocals.get((decl as IdentifierNode).name);\n if (wrappedName) {\n state.ms.overwrite(decl.start, decl.end, wrappedName);\n state.autoWrapped.add(DEFAULT_EXPORT);\n return;\n }\n }\n\n // MagicString positions are always relative to the original source. Only the `export default`\n // keywords are replaced, so parentheses around the expression stay.\n const source = state.ms.original;\n const keywordsEnd = exportDefaultKeywordsEnd(source, node.start);\n const declaredName =\n decl.type === 'ClassDeclaration' || decl.type === 'FunctionDeclaration'\n ? (decl as ClassDeclarationNode).id?.name\n : undefined;\n\n // As with `export { handler as default }`, the export is set in two steps: bound as-is where the\n // original statement set it, then rebound at the end of the module to the wrapper, which sees\n // methods added in between. See `wrapDefaultSpecifier`.\n let wrapped = '__SENTRY_DEFAULT_EXPORT__';\n if (declaredName) {\n // `export default class Handler {}`: the declaration stays, so `Handler` stays bound in the module.\n state.ms.remove(node.start, decl.start);\n state.ms.appendLeft(node.end, `\\nvar __SENTRY_DEFAULT_EXPORT__ = ${declaredName};`);\n wrapped = declaredName;\n } else if (isAnonymousFunctionOrClass(decl)) {\n // As a property value, the class or function gets the name `default`, as `export default` gives it.\n const hasSemicolon = source[node.end - 1] === ';';\n state.ms.overwrite(node.start, keywordsEnd, 'var __SENTRY_DEFAULT_EXPORT__ = { default:');\n state.ms.appendLeft(hasSemicolon ? node.end - 1 : node.end, hasSemicolon ? ' }.default' : ' }.default;');\n } else {\n state.ms.overwrite(node.start, keywordsEnd, 'var __SENTRY_DEFAULT_EXPORT__ =');\n }\n state.ms.appendLeft(node.end, '\\nexport { __SENTRY_DEFAULT_EXPORT__ as default };');\n state.ms.append(`\\n__SENTRY_DEFAULT_EXPORT__ = __SENTRY__.withSentry(${state.optionsFn}, ${wrapped});`);\n state.needsImport = true;\n state.autoWrapped.add(DEFAULT_EXPORT);\n}\n\n/**\n * Offset just past the `default` keyword of the `export default` statement at `start`. Comments can\n * sit between `export`, `default` and the expression, and may themselves contain the word `default`.\n */\nfunction exportDefaultKeywordsEnd(source: string, start: number): number {\n let index = start + 'export'.length;\n while (index < source.length && !source.startsWith('default', index)) {\n if (source.startsWith('//', index)) {\n const lineEnd = source.indexOf('\\n', index);\n index = lineEnd === -1 ? source.length : lineEnd;\n } else if (source.startsWith('/*', index)) {\n const commentEnd = source.indexOf('*/', index + 2);\n index = commentEnd === -1 ? source.length : commentEnd + 2;\n } else {\n index++;\n }\n }\n return index + 'default'.length;\n}\n\nfunction isAnonymousFunctionOrClass(node: BaseNode): boolean {\n if (node.type === 'ArrowFunctionExpression') return true;\n const isFunctionOrClass = [\n 'FunctionExpression',\n 'FunctionDeclaration',\n 'ClassExpression',\n 'ClassDeclaration',\n ].includes(node.type);\n return isFunctionOrClass && !(node as ClassDeclarationNode).id;\n}\n\nfunction handleNamedExport(node: ExportNamedNode, ctx: TransformContext, state: TransformState): void {\n const decl = node.declaration;\n\n // ---- Manually wrapped class export ----\n // `export const MyDO = instrumentDurableObjectWithSentry(...)` — count it\n // as wrapped so the plugin doesn't warn about it, but leave it alone.\n if (decl?.type === 'VariableDeclaration') {\n collectManuallyWrappedClassExports(decl, ctx, state);\n return;\n }\n\n // ---- Named class export matching a configured binding ----\n if (decl?.type === 'ClassDeclaration') {\n wrapInlineClassExport(node, decl, ctx, state);\n return;\n }\n\n // ---- Specifier export (`export { Foo as MyDO }`, `export { MyDO } from './do'`) ----\n wrapSpecifierExports(node, ctx, state);\n}\n\nfunction collectManuallyWrappedClassExports(\n varDecl: VariableDeclarationNode,\n ctx: TransformContext,\n state: TransformState,\n): void {\n for (const declarator of varDecl.declarations ?? []) {\n const name = declarator.id?.type === 'Identifier' ? declarator.id.name : undefined;\n const kind = name ? ctx.classWrappers.get(name) : undefined;\n if (!name || !kind || !declarator.init) continue;\n\n // A hand-wrapped Agent is configured as a Durable Object, so accept either helper there —\n // otherwise an already-instrumented Agent would be reported as unwrapped.\n const accepted =\n kind === 'durableObject' ? [WRAPPER_METHODS.durableObject, WRAPPER_METHODS.agent] : [WRAPPER_METHODS[kind]];\n\n if (accepted.some(method => isCallToMethod(declarator.init as BaseNode, method))) {\n state.wrappedClasses.add(name);\n }\n }\n}\n\nfunction wrapInlineClassExport(\n exportNode: ExportNamedNode,\n classDecl: ClassDeclarationNode,\n ctx: TransformContext,\n state: TransformState,\n): void {\n const classId = classDecl.id;\n // Inline export: the exported name and the local class name are the same.\n const kind = classId ? resolveWrapperKind(classId.name, classId.name, state) : undefined;\n if (!classId || !kind) return;\n\n const className = classId.name;\n\n // Strip the `export ` keyword\n state.ms.overwrite(exportNode.start, classDecl.start, '');\n\n const wrappedName = wrapLocalClass(className, classDecl, kind, state);\n state.ms.appendLeft(exportNode.end, `export { ${wrappedName} as ${className} };\\n`);\n\n state.wrappedClasses.add(className);\n state.autoWrapped.add(className);\n}\n\n/**\n * Wrap a class declared in this module and return the binding that holds the wrapper.\n *\n * The declaration is left exactly as written. Only the *export* has to become the wrapper, so the\n * wrapper gets its own binding and the export is aliased to it, the same shape as the documented\n * manual `instrument*WithSentry` pattern and the cross-module re-export path below. Renaming the\n * declaration instead (`class __SENTRY_ORIGINAL_MyAgent__`) would also rename what the class reports\n * as `Function.prototype.name`, which libraries read to identify the user's class: `@cloudflare/think`\n * hands `this.constructor.name` to the AI SDK as the telemetry `functionId`, and that surfaced as a\n * `gen_ai.invoke_agent __SENTRY_ORIGINAL_MyAgent__` span.\n */\nfunction wrapLocalClass(\n localName: string,\n localClass: ClassDeclarationNode,\n kind: ClassWrapperKind,\n state: TransformState,\n): string {\n const existing = state.wrappedLocals.get(localName);\n if (existing) return existing;\n\n const wrappedName = `__SENTRY_WRAPPED_${localName}__`;\n state.wrappedLocals.set(localName, wrappedName);\n state.ms.appendLeft(\n localClass.end,\n `\\nconst ${wrappedName} = __SENTRY__.${WRAPPER_METHODS[kind]}(${state.optionsFn}, ${localName});\\n`,\n );\n state.needsImport = true;\n return wrappedName;\n}\n\n/**\n * Wrap the configured classes an `export { ... }` statement names.\n *\n * Each such specifier is re-pointed at a binding holding the wrapper, which means rebuilding the\n * statement; specifiers this plugin has no business touching are carried over verbatim. For a class\n * declared in this module the wrapper binding follows the declaration (see {@link wrapLocalClass}).\n * A class that lives in **another** module — imported and re-exported, or re-exported directly — is\n * first bound under a private name, since an import binding cannot be reassigned and the `from` form\n * has no local binding at all.\n */\nfunction wrapSpecifierExports(node: ExportNamedNode, ctx: TransformContext, state: TransformState): void {\n const specifiers = node.specifiers ?? [];\n if (specifiers.length === 0) return;\n\n const sourceLiteral = node.source ? state.ms.original.slice(node.source.start, node.source.end) : undefined;\n\n const prelude: string[] = [];\n const wrappedPairs: string[] = [];\n const kept: string[] = [];\n\n for (const specifier of specifiers) {\n const pair = wrapSpecifier(specifier, sourceLiteral, ctx, state, prelude);\n if (pair) {\n wrappedPairs.push(pair);\n } else {\n kept.push(state.ms.original.slice(specifier.start, specifier.end));\n }\n }\n\n if (wrappedPairs.length === 0) return;\n\n const statements = [...prelude, `export { ${wrappedPairs.join(', ')} };`];\n if (kept.length > 0) {\n const clause = `export { ${kept.join(', ')} }`;\n statements.push(sourceLiteral ? `${clause} from ${sourceLiteral};` : `${clause};`);\n }\n state.ms.overwrite(node.start, node.end, statements.join('\\n'));\n}\n\n/**\n * `export { handler as default }`, the form bundlers emit for a default export. The export is set\n * in two steps. Right after `handler` is declared, it is bound to `handler` as-is, so a circular\n * import that reads it during module evaluation gets the handler, as before the transform. At the\n * end of the module, it is rebound to the wrapper, so a handler assigned or given methods later is\n * wrapped as it ends up. The binding is a `var`: a read before `handler` is declared gets\n * `undefined`, as it would from the bundler's own `var`, where a `const` would throw and stop the\n * Worker from starting.\n */\nfunction wrapDefaultSpecifier(localName: string, state: TransformState): string | undefined {\n if (state.manuallyWrappedLocals.has(localName)) return undefined;\n\n // Same as `export default Foo`: re-point at the wrapper a named export already made.\n const wrappedName = state.wrappedLocals.get(localName);\n if (wrappedName) {\n state.autoWrapped.add(DEFAULT_EXPORT);\n return `${wrappedName} as default`;\n }\n\n const declaringStatement = state.declaringStatements.get(localName);\n if (declaringStatement) {\n state.ms.appendLeft(declaringStatement.end, `\\nvar __SENTRY_DEFAULT_EXPORT__ = ${localName};`);\n }\n state.ms.append(\n `\\n${declaringStatement ? '' : 'var '}__SENTRY_DEFAULT_EXPORT__ = __SENTRY__.withSentry(${state.optionsFn}, ${localName});`,\n );\n state.needsImport = true;\n state.autoWrapped.add(DEFAULT_EXPORT);\n return '__SENTRY_DEFAULT_EXPORT__ as default';\n}\n\n/**\n * `export { default } from './handler'`. The handler may already be wrapped in its own module,\n * which this transform cannot see, so the emitted guard returns such a handler as-is.\n *\n * The original re-export is a live binding to the handler module's export, but the wrapper is not\n * set until this module's body runs. A circular import that reads the default export before then\n * gets `undefined` instead of the handler. The binding is a `var` so that the read does not throw,\n * as a `const` would, and stop the Worker from starting. See `wrapDefaultSpecifier`.\n */\nfunction wrapDefaultReexport(\n localName: string,\n sourceLiteral: string,\n state: TransformState,\n prelude: string[],\n): string {\n const target = '__SENTRY_REEXPORT_default__';\n prelude.push(\n localName === DEFAULT_IMPORT\n ? `import ${target} from ${sourceLiteral};`\n : `import { ${localName} as ${target} } from ${sourceLiteral};`,\n `var __SENTRY_DEFAULT_EXPORT__ = __SENTRY__._INTERNAL_wrapUnlessInstrumented(__SENTRY__.withSentry, ${state.optionsFn}, ${target});`,\n );\n state.needsImport = true;\n state.autoWrapped.add(DEFAULT_EXPORT);\n return '__SENTRY_DEFAULT_EXPORT__ as default';\n}\n\n/**\n * Handle one export specifier, returning the `Wrapped as Exported` pair to emit for a class that\n * gets wrapped. The import/wrapper statements a cross-module pair depends on are pushed onto\n * `prelude`; a local class's wrapper binding is emitted after its declaration instead.\n *\n * Returns `undefined` when the specifier can stay exactly as written: it doesn't name a configured\n * class, or the binding is already hand-wrapped.\n */\nfunction wrapSpecifier(\n specifier: ExportSpecifierNode,\n sourceLiteral: string | undefined,\n ctx: TransformContext,\n state: TransformState,\n prelude: string[],\n): string | undefined {\n const exportedName =\n specifier.type === 'ExportSpecifier' && specifier.exported?.type === 'Identifier'\n ? specifier.exported.name\n : undefined;\n const localName = specifier.local?.type === 'Identifier' ? specifier.local.name : undefined;\n // With a `from` clause the specifier names an export of the *source* module, not a binding here.\n const kind = exportedName\n ? resolveWrapperKind(exportedName, sourceLiteral ? undefined : localName, state)\n : undefined;\n\n if (!exportedName || !localName) return undefined;\n if (!kind) {\n if (exportedName !== DEFAULT_IMPORT) return undefined;\n return sourceLiteral\n ? wrapDefaultReexport(localName, sourceLiteral, state, prelude)\n : wrapDefaultSpecifier(localName, state);\n }\n\n // Without a `from` clause the specifier points at a module-local binding.\n if (!sourceLiteral) {\n const localClass = state.topLevelClasses.get(localName);\n\n if (localClass?.id) {\n const wrappedName = wrapLocalClass(localName, localClass, kind, state);\n state.wrappedClasses.add(exportedName);\n return `${wrappedName} as ${exportedName}`;\n }\n\n if (state.manuallyWrappedLocals.has(localName)) {\n state.wrappedClasses.add(exportedName);\n return undefined;\n }\n }\n\n // The class comes from another module: bind it under a private name (for the `from` form, which\n // has no local binding at all), wrap that, and export the wrapper under the configured name.\n let target = localName;\n\n if (sourceLiteral) {\n target = `__SENTRY_REEXPORT_${exportedName}__`;\n prelude.push(\n localName === DEFAULT_IMPORT\n ? `import ${target} from ${sourceLiteral};`\n : `import { ${localName} as ${target} } from ${sourceLiteral};`,\n );\n }\n\n const wrappedName = `__SENTRY_WRAPPED_${exportedName}__`;\n\n // The class may already be hand-wrapped in its own module, which this transform cannot see. The\n // emitted guard returns such a class as-is instead of nesting a second wrapper around it.\n prelude.push(\n `const ${wrappedName} = __SENTRY__._INTERNAL_wrapUnlessInstrumented(__SENTRY__.${WRAPPER_METHODS[kind]}, ${state.optionsFn}, ${target});`,\n );\n state.wrappedClasses.add(exportedName);\n state.autoWrapped.add(exportedName);\n state.needsImport = true;\n\n return `${wrappedName} as ${exportedName}`;\n}\n"],"mappings":";;;;AAKA,MAAM,4BAA4B;AA8DlC,SAAS,eAAe,MAAgB,YAA6B;CACnE,IAAI,KAAK,SAAS,kBAAkB,OAAO;CAC3C,MAAM,SAAU,KAA4B;CAC5C,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,OAAO,SAAS,gBAAgB,OAAO,SAAS,YAAY,OAAO;CACvE,OACE,OAAO,SAAS,sBAAsB,OAAO,UAAU,SAAS,gBAAgB,OAAO,SAAS,SAAS;AAE7G;;AAgBA,MAAM,iBAAiB;;;;;;AAOvB,MAAM,kBAAoD;CACxD,eAAe;CACf,OAAO;CACP,UAAU;CACV,kBAAkB;AACpB;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,8BACd,MACA,KACA,KAC6B;CAC7B,MAAM,KAAK,IAAI,YAAY,IAAI;CAC/B,MAAM,kBAAkB,uBAAuB,GAAG;CAClD,MAAM,qBAAqB,IAAI,sBAAsB,CAAC;CACtD,MAAM,QAAwB;EAC5B;EACA,aAAa;EACb,gCAAgB,IAAI,IAAY;EAChC;EACA,+BAAe,IAAI,IAAoB;EACvC,eAAe,IAAI;EACnB,cAAc,IAAI,gCAAgB,IAAI,IAAY;EAClD,yBAAyB,8BAA8B,GAAG;EAE1D,WAAW,mBAAmB,SAAS,IAAI,4BAA4B,IAAI;EAC3E,6BAAa,IAAI,IAAgB;EACjC,uBAAuB,6BAA6B,GAAG;EACvD,qBAAqB,2BAA2B,GAAG;CACrD;CACA,MAAM,EA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eACJ,UAAU,SAAS,qBAAqB,UAAU,UAAU,SAAS,eACjE,UAAU,SAAS,OACnB,KAAA;CACN,MAAM,YAAY,UAAU,OAAO,SAAS,eAAe,UAAU,MAAM,OAAO,KAAA;CAElF,MAAM,OAAO,eACT,mBAAmB,cAAc,gBAAgB,KAAA,IAAY,WAAW,KAAK,IAC7E,KAAA;CAEJ,IAAI,CAAC,gBAAgB,CAAC,WAAW,OAAO,KAAA;CACxC,IAAI,CAAC,MAAM;EACT,IAAI,iBAAiB,gBAAgB,OAAO,KAAA;EAC5C,OAAO,gBACH,oBAAoB,WAAW,eAAe,OAAO,OAAO,IAC5D,qBAAqB,WAAW,KAAK;CAC3C;CAGA,IAAI,CAAC,eAAe;EAClB,MAAM,aAAa,MAAM,gBAAgB,IAAI,SAAS;EAEtD,IAAI,YAAY,IAAI;GAClB,MAAM,cAAc,eAAe,WAAW,YAAY,MAAM,KAAK;GACrE,MAAM,eAAe,IAAI,YAAY;GACrC,OAAO,GAAG,YAAY,MAAM;EAC9B;EAEA,IAAI,MAAM,sBAAsB,IAAI,SAAS,GAAG;GAC9C,MAAM,eAAe,IAAI,YAAY;GACrC;EACF;CACF;CAIA,IAAI,SAAS;CAEb,IAAI,eAAe;EACjB,SAAS,qBAAqB,aAAa;EAC3C,QAAQ,KACN,cAAc,iBACV,UAAU,OAAO,QAAQ,cAAc,KACvC,YAAY,UAAU,MAAM,OAAO,UAAU,cAAc,EACjE;CACF;CAEA,MAAM,cAAc,oBAAoB,aAAa;CAIrD,QAAQ,KACN,SAAS,YAAY,4DAA4D,gBAAgB,MAAM,IAAI,MAAM,UAAU,IAAI,OAAO,GACxI;CACA,MAAM,eAAe,IAAI,YAAY;CACrC,MAAM,YAAY,IAAI,YAAY;CAClC,MAAM,cAAc;CAEpB,OAAO,GAAG,YAAY,MAAM;AAC9B"}
1
+ {"version":3,"file":"transform.js","names":[],"sources":["../../../../src/vite/transform.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport MagicString from 'magic-string';\nimport { DEFAULT_EXPORT, type ExportName, type SameWorkerBinding } from './wranglerConfig';\nimport { detectWorkerEntrypointClasses } from './workerEntrypoint';\nimport { stringifyForCodeInjection } from '@sentry/core';\n\nconst MERGED_OPTIONS_IDENTIFIER = '__SENTRY_OPTIONS__';\n\n// Read by `CloudflareClient` for the default `serverName` and the runtime version.\nconst WORKER_INFO_GLOBAL = '__SENTRY_CLOUDFLARE_WORKER__';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node types for the AST nodes we inspect.\n// ---------------------------------------------------------------------------\n\nexport interface BaseNode {\n type: string;\n start: number;\n end: number;\n}\n\nexport interface ProgramBody {\n body: BaseNode[];\n}\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface CalleeNode {\n type: string;\n name?: string;\n property?: { type: string; name?: string };\n}\n\ninterface CallExpressionNode extends BaseNode {\n callee?: CalleeNode;\n}\n\ninterface ClassDeclarationNode extends BaseNode {\n id?: IdentifierNode | null;\n}\n\ninterface ExportDefaultNode extends BaseNode {\n declaration: BaseNode;\n}\n\ninterface ExportSpecifierNode extends BaseNode {\n local?: { type: string; name?: string };\n exported?: { type: string; name?: string };\n}\n\ninterface ExportNamedNode extends BaseNode {\n declaration?: BaseNode | null;\n source?: BaseNode | null;\n specifiers?: ExportSpecifierNode[];\n}\n\ninterface VariableDeclaratorNode {\n id?: { type: string; name?: string };\n init?: BaseNode | null;\n}\n\ninterface VariableDeclarationNode extends BaseNode {\n declarations?: VariableDeclaratorNode[];\n}\n\ninterface ImportDeclarationNode extends BaseNode {\n specifiers?: Array<{ local?: { type: string; name?: string } }>;\n}\n\nfunction isCallToMethod(node: BaseNode, methodName: string): boolean {\n if (node.type !== 'CallExpression') return false;\n const callee = (node as CallExpressionNode).callee;\n if (!callee) return false;\n if (callee.type === 'Identifier' && callee.name === methodName) return true;\n return (\n callee.type === 'MemberExpression' && callee.property?.type === 'Identifier' && callee.property.name === methodName\n );\n}\n\n/**\n * The kind of Sentry wrapper to apply to an exported class.\n *\n * `durableObject` and `workflow` are keyed by name from the wrangler config\n * (`durable_objects.bindings`, `workflows`), since those class names are\n * authoritative there. `workerEntrypoint` is different: a worker's own\n * entrypoints aren't enumerated in its config, so they're detected structurally\n * (a class extending `WorkerEntrypoint` from `cloudflare:workers`), with the\n * config providing only a fallback for self-bound entrypoints whose base class\n * lives in another module.\n */\nexport type ClassWrapperKind = 'durableObject' | 'agent' | 'workflow' | 'workerEntrypoint';\n\n/** Specifier name a `export { default as X } from '...'` re-export uses for the source's default. */\nconst DEFAULT_IMPORT = 'default';\n\n/**\n * The `@sentry/cloudflare` helper each wrapper kind emits. All share the same\n * `(optionsCallback, Class)` signature. `WorkerEntrypoint` classes use\n * `withSentry`, which runtime-detects the class type and routes accordingly.\n */\nconst WRAPPER_METHODS: Record<ClassWrapperKind, string> = {\n durableObject: 'instrumentDurableObjectWithSentry',\n agent: 'instrumentAgentWithSentry',\n workflow: 'instrumentWorkflowWithSentry',\n workerEntrypoint: 'withSentry',\n};\n\nexport interface TransformContext {\n /**\n * Exported class name → the kind of Sentry wrapper to apply. Populated from\n * the wrangler config, so the transform can wrap by name without resolving\n * each class's base type.\n */\n classWrappers: Map<string, ClassWrapperKind>;\n /**\n * Local class names detected as `agents` Agents. An Agent is configured as a Durable Object in\n * wrangler, so this upgrades those entries from `durableObject` to `agent`.\n */\n agentClasses?: ReadonlySet<string>;\n optionsFn: string;\n /** Import statement prepended when `optionsFn` references a separate module. */\n optionsImport?: string;\n /** Module the generated code imports `withSentry` and the class wrappers from. Defaults to `@sentry/cloudflare`. */\n sentryModule?: string;\n /** @see {@link import('./wranglerConfig').WranglerConfig.sameWorkerBindings} */\n sameWorkerBindings?: readonly SameWorkerBinding[];\n /**\n * The Worker name and compatibility date, stored on `globalThis` as the default `serverName` and\n * the runtime version. The entry stores them also when nothing is wrapped, so hand-wrapped\n * handlers get them too.\n */\n workerInfo?: { name?: string; compatibilityDate?: string };\n}\n\nexport interface TransformResult {\n code: string;\n map: ReturnType<MagicString['generateMap']>;\n /**\n * The configured class names that were actually wrapped. Lets the plugin warn\n * about configured classes it could not find, instead of silently leaving\n * them uninstrumented.\n */\n wrappedClasses: Set<string>;\n}\n\n/**\n * Rewrite the worker entry source to wrap its default export with `withSentry`\n * and any configured class export with its matching Sentry wrapper (see\n * {@link TransformContext.classWrappers}, e.g. Durable Object classes with\n * `instrumentDurableObjectWithSentry`).\n *\n * Handles `export class MyDO {}`, the specifier form (`class MyDO {}` …\n * `export { MyDO }` / `export { Foo as MyDO }`), and classes that live in\n * another module (`import { MyDO } from './do'; export { MyDO }` or\n * `export { MyDO } from './do'`). Only star re-exports (`export * from './do'`)\n * are left alone — the plugin warns about those via\n * {@link TransformResult.wrappedClasses}.\n *\n * Exported (rather than inlined into the plugin) so it can be unit-tested with a\n * plain AST and no Vite context. Returns `undefined` when nothing was wrapped,\n * there are no already-manually-wrapped classes to report, and there is no\n * {@link TransformContext.workerInfo} to store.\n */\nexport function applyAutoInstrumentTransforms(\n code: string,\n ast: ProgramBody,\n ctx: TransformContext,\n): TransformResult | undefined {\n const ms = new MagicString(code);\n const topLevelClasses = collectTopLevelClasses(ast);\n const sameWorkerBindings = ctx.sameWorkerBindings ?? [];\n const state: TransformState = {\n ms,\n needsImport: false,\n wrappedClasses: new Set<string>(),\n topLevelClasses,\n wrappedLocals: new Map<string, string>(),\n classWrappers: ctx.classWrappers,\n agentClasses: ctx.agentClasses ?? new Set<string>(),\n workerEntrypointClasses: detectWorkerEntrypointClasses(ast),\n // The identifier must be chosen before wrapping, which bindings survive is only known after.\n optionsFn: sameWorkerBindings.length > 0 ? MERGED_OPTIONS_IDENTIFIER : ctx.optionsFn,\n autoWrapped: new Set<ExportName>(),\n manuallyWrappedLocals: collectManuallyWrappedLocals(ast),\n declaringStatements: collectDeclaringStatements(ast),\n };\n const { wrappedClasses } = state;\n\n // Named exports first, regardless of source order: the default-export handler\n // needs to know which local bindings a named export already wrapped, so it can\n // skip a class that is both exported by name and re-exported as default (which\n // would otherwise wrap it twice).\n for (const node of ast.body) {\n if (node.type === 'ExportNamedDeclaration') {\n handleNamedExport(node, ctx, state);\n }\n }\n for (const node of ast.body) {\n if (node.type === 'ExportDefaultDeclaration') {\n wrapDefaultExport(node as ExportDefaultNode, ctx, state);\n }\n }\n\n if (state.needsImport) {\n // `prepend` inserts before earlier prepends, yielding: Sentry import, options import, declaration.\n if (sameWorkerBindings.length > 0) {\n ms.prepend(buildMergedOptionsDeclaration(sameWorkerBindings, ctx.optionsFn, state));\n }\n if (ctx.optionsImport) ms.prepend(ctx.optionsImport);\n ms.prepend(`import * as __SENTRY__ from '${ctx.sentryModule ?? '@sentry/cloudflare'}';\\n`);\n }\n\n if (ctx.workerInfo?.name || ctx.workerInfo?.compatibilityDate) {\n ms.prepend(`globalThis.${WORKER_INFO_GLOBAL} = ${JSON.stringify(ctx.workerInfo)};\\n`);\n } else if (!state.needsImport && wrappedClasses.size === 0) {\n // Nothing was rewritten. Classes found already wrapped manually are still\n // reported (via `wrappedClasses`) so the caller doesn't warn about them.\n return undefined;\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ hires: true }),\n wrappedClasses,\n };\n}\n\ninterface TransformState {\n ms: MagicString;\n needsImport: boolean;\n wrappedClasses: Set<string>;\n /**\n * Top-level class declarations, exported or not, so specifier exports like\n * `export { MyDO }` can locate the class they refer to.\n */\n topLevelClasses: Map<string, ClassDeclarationNode>;\n /**\n * Local class name → the binding holding its wrapper, so two exports of the same class share one\n * wrapper and a default export of it can be re-pointed.\n */\n wrappedLocals: Map<string, string>;\n /** Class name → wrapper kind, keyed by the *exported* name (from config). */\n classWrappers: Map<string, ClassWrapperKind>;\n /** Local class names detected as `agents` Agents (see {@link TransformContext.agentClasses}). */\n agentClasses: ReadonlySet<string>;\n /**\n * Local class names detected as `WorkerEntrypoint` subclasses in this module,\n * so they can be wrapped without a config entry.\n */\n workerEntrypointClasses: Set<string>;\n optionsFn: string;\n /**\n * Export names wrapped by this transform, so their options can be extended with\n * `rpcTracePropagationBindings`. Hand-wrapped exports stay out, they keep the options they were\n * wrapped with. `wrappedClasses` counts both.\n */\n autoWrapped: Set<ExportName>;\n /**\n * Top-level bindings already assigned an `instrument*WithSentry(...)` result\n * (`const MyDO = instrumentDurableObjectWithSentry(...)`). Exporting one by\n * specifier must report it as wrapped rather than wrap it a second time.\n */\n manuallyWrappedLocals: Set<string>;\n /** Top-level binding name → the statement that declares it. */\n declaringStatements: Map<string, BaseNode>;\n}\n\n/**\n * Builds the callback that merges same-worker binding names into `rpcTracePropagationBindings` at\n * runtime, the options object only exists once the callback runs with `env`. Only bindings whose\n * class this transform wrapped survive, a hand-wrapped class runs on its own options.\n */\nfunction buildMergedOptionsDeclaration(\n sameWorkerBindings: readonly SameWorkerBinding[],\n optionsFn: string,\n state: TransformState,\n): string {\n const bindingNames = sameWorkerBindings\n .filter(({ className }) => state.autoWrapped.has(className))\n .map(({ bindingName }) => bindingName);\n\n if (!bindingNames.length) {\n return `const ${MERGED_OPTIONS_IDENTIFIER} = ${optionsFn};\\n`;\n }\n\n const names = bindingNames.map(name => stringifyForCodeInjection(name)).join(', ');\n return (\n `const ${MERGED_OPTIONS_IDENTIFIER} = (env) => { ` +\n `const opts = (${optionsFn})(env); ` +\n `return { ...opts, rpcTracePropagationBindings: [${names}, ...(opts?.rpcTracePropagationBindings ?? [])] }; };\\n`\n );\n}\n\n/**\n * Resolve the wrapper kind for a class export.\n *\n * Config (`classWrappers`) wins — it's authoritative for Durable Objects and\n * Workflows, and provides the self-binding fallback for WorkerEntrypoints whose\n * base class this module can't see. Otherwise a structurally-detected\n * `WorkerEntrypoint` subclass (matched by its *local* name) gets wrapped with\n * `withSentry`.\n *\n * `localName` is the binding **in this module** the export refers to, and must be\n * left undefined for `export { X } from '...'`: there the specifier's name belongs\n * to the source module, so matching it against anything detected here would wrap a\n * class that merely shares a name.\n *\n * The one case where config is refined rather than obeyed is an `agents` Agent:\n * it *is* a Durable Object, so wrangler can only ever describe it as one, and\n * only the detected base chain distinguishes the two.\n */\nfunction resolveWrapperKind(\n exportedName: string,\n localName: string | undefined,\n state: TransformState,\n): ClassWrapperKind | undefined {\n const configured = state.classWrappers.get(exportedName);\n\n if (\n configured === 'durableObject' &&\n ((localName && state.agentClasses.has(localName)) || state.agentClasses.has(exportedName))\n ) {\n return 'agent';\n }\n\n if (configured) return configured;\n if (localName && state.workerEntrypointClasses.has(localName)) return 'workerEntrypoint';\n return undefined;\n}\n\n/**\n * Top-level `const X = instrument*WithSentry(...)` bindings — a hand-wrapped class that is exported\n * separately (`export { X }`) rather than inline.\n */\nfunction collectManuallyWrappedLocals(ast: ProgramBody): Set<string> {\n const wrapperMethods = Object.values(WRAPPER_METHODS);\n const locals = new Set<string>();\n\n for (const node of ast.body) {\n const declaration = declarationOf(node);\n if (declaration?.type !== 'VariableDeclaration') continue;\n for (const declarator of (declaration as VariableDeclarationNode).declarations ?? []) {\n const name = declarator.id?.type === 'Identifier' ? declarator.id.name : undefined;\n const init = declarator.init;\n if (name && init && wrapperMethods.some(method => isCallToMethod(init, method))) {\n locals.add(name);\n }\n }\n }\n\n return locals;\n}\n\nfunction collectDeclaringStatements(ast: ProgramBody): Map<string, BaseNode> {\n const statements = new Map<string, BaseNode>();\n for (const node of ast.body) {\n const declaration = declarationOf(node);\n if (!declaration) continue;\n const ids =\n declaration.type === 'VariableDeclaration'\n ? ((declaration as VariableDeclarationNode).declarations ?? []).map(declarator => declarator.id)\n : declaration.type === 'ImportDeclaration'\n ? ((declaration as ImportDeclarationNode).specifiers ?? []).map(specifier => specifier.local)\n : [(declaration as ClassDeclarationNode).id];\n for (const id of ids) {\n if (id?.type === 'Identifier' && id.name) statements.set(id.name, node);\n }\n }\n return statements;\n}\n\nfunction collectTopLevelClasses(ast: ProgramBody): Map<string, ClassDeclarationNode> {\n const classes = new Map<string, ClassDeclarationNode>();\n for (const node of ast.body) {\n const declaration = declarationOf(node);\n if (declaration?.type !== 'ClassDeclaration') continue;\n const classNode = declaration as ClassDeclarationNode;\n if (classNode.id?.name) classes.set(classNode.id.name, classNode);\n }\n return classes;\n}\n\n/** The declaration a top-level statement makes, looking through `export` (`export const x = ...`). */\nfunction declarationOf(node: BaseNode): BaseNode | null | undefined {\n return node.type === 'ExportNamedDeclaration' ? (node as ExportNamedNode).declaration : node;\n}\n\nfunction wrapDefaultExport(node: ExportDefaultNode, ctx: TransformContext, state: TransformState): void {\n const decl = node.declaration;\n\n // Already wrapped — leave it alone\n if (isCallToMethod(decl, 'withSentry')) return;\n\n // `export default Foo` where `Foo` is a local class already wrapped by a named\n // export (e.g. a self-bound WorkerEntrypoint also used as the default handler).\n // Wrapping again would produce `withSentry(withSentry(...))`, so the default\n // export is re-pointed at the wrapper binding the named export created.\n if (decl.type === 'Identifier') {\n const wrappedName = state.wrappedLocals.get((decl as IdentifierNode).name);\n if (wrappedName) {\n state.ms.overwrite(decl.start, decl.end, wrappedName);\n state.autoWrapped.add(DEFAULT_EXPORT);\n return;\n }\n }\n\n // MagicString positions are always relative to the original source. Only the `export default`\n // keywords are replaced, so parentheses around the expression stay.\n const source = state.ms.original;\n const keywordsEnd = exportDefaultKeywordsEnd(source, node.start);\n const declaredName =\n decl.type === 'ClassDeclaration' || decl.type === 'FunctionDeclaration'\n ? (decl as ClassDeclarationNode).id?.name\n : undefined;\n\n // As with `export { handler as default }`, the export is set in two steps: bound as-is where the\n // original statement set it, then rebound at the end of the module to the wrapper, which sees\n // methods added in between. See `wrapDefaultSpecifier`.\n let wrapped = '__SENTRY_DEFAULT_EXPORT__';\n if (declaredName) {\n // `export default class Handler {}`: the declaration stays, so `Handler` stays bound in the module.\n state.ms.remove(node.start, decl.start);\n state.ms.appendLeft(node.end, `\\nvar __SENTRY_DEFAULT_EXPORT__ = ${declaredName};`);\n wrapped = declaredName;\n } else if (isAnonymousFunctionOrClass(decl)) {\n // As a property value, the class or function gets the name `default`, as `export default` gives it.\n const hasSemicolon = source[node.end - 1] === ';';\n state.ms.overwrite(node.start, keywordsEnd, 'var __SENTRY_DEFAULT_EXPORT__ = { default:');\n state.ms.appendLeft(hasSemicolon ? node.end - 1 : node.end, hasSemicolon ? ' }.default' : ' }.default;');\n } else {\n state.ms.overwrite(node.start, keywordsEnd, 'var __SENTRY_DEFAULT_EXPORT__ =');\n }\n state.ms.appendLeft(node.end, '\\nexport { __SENTRY_DEFAULT_EXPORT__ as default };');\n state.ms.append(`\\n__SENTRY_DEFAULT_EXPORT__ = __SENTRY__.withSentry(${state.optionsFn}, ${wrapped});`);\n state.needsImport = true;\n state.autoWrapped.add(DEFAULT_EXPORT);\n}\n\n/**\n * Offset just past the `default` keyword of the `export default` statement at `start`. Comments can\n * sit between `export`, `default` and the expression, and may themselves contain the word `default`.\n */\nfunction exportDefaultKeywordsEnd(source: string, start: number): number {\n let index = start + 'export'.length;\n while (index < source.length && !source.startsWith('default', index)) {\n if (source.startsWith('//', index)) {\n const lineEnd = source.indexOf('\\n', index);\n index = lineEnd === -1 ? source.length : lineEnd;\n } else if (source.startsWith('/*', index)) {\n const commentEnd = source.indexOf('*/', index + 2);\n index = commentEnd === -1 ? source.length : commentEnd + 2;\n } else {\n index++;\n }\n }\n return index + 'default'.length;\n}\n\nfunction isAnonymousFunctionOrClass(node: BaseNode): boolean {\n if (node.type === 'ArrowFunctionExpression') return true;\n const isFunctionOrClass = [\n 'FunctionExpression',\n 'FunctionDeclaration',\n 'ClassExpression',\n 'ClassDeclaration',\n ].includes(node.type);\n return isFunctionOrClass && !(node as ClassDeclarationNode).id;\n}\n\nfunction handleNamedExport(node: ExportNamedNode, ctx: TransformContext, state: TransformState): void {\n const decl = node.declaration;\n\n // ---- Manually wrapped class export ----\n // `export const MyDO = instrumentDurableObjectWithSentry(...)` — count it\n // as wrapped so the plugin doesn't warn about it, but leave it alone.\n if (decl?.type === 'VariableDeclaration') {\n collectManuallyWrappedClassExports(decl, ctx, state);\n return;\n }\n\n // ---- Named class export matching a configured binding ----\n if (decl?.type === 'ClassDeclaration') {\n wrapInlineClassExport(node, decl, ctx, state);\n return;\n }\n\n // ---- Specifier export (`export { Foo as MyDO }`, `export { MyDO } from './do'`) ----\n wrapSpecifierExports(node, ctx, state);\n}\n\nfunction collectManuallyWrappedClassExports(\n varDecl: VariableDeclarationNode,\n ctx: TransformContext,\n state: TransformState,\n): void {\n for (const declarator of varDecl.declarations ?? []) {\n const name = declarator.id?.type === 'Identifier' ? declarator.id.name : undefined;\n const kind = name ? ctx.classWrappers.get(name) : undefined;\n if (!name || !kind || !declarator.init) continue;\n\n // A hand-wrapped Agent is configured as a Durable Object, so accept either helper there —\n // otherwise an already-instrumented Agent would be reported as unwrapped.\n const accepted =\n kind === 'durableObject' ? [WRAPPER_METHODS.durableObject, WRAPPER_METHODS.agent] : [WRAPPER_METHODS[kind]];\n\n if (accepted.some(method => isCallToMethod(declarator.init as BaseNode, method))) {\n state.wrappedClasses.add(name);\n }\n }\n}\n\nfunction wrapInlineClassExport(\n exportNode: ExportNamedNode,\n classDecl: ClassDeclarationNode,\n ctx: TransformContext,\n state: TransformState,\n): void {\n const classId = classDecl.id;\n // Inline export: the exported name and the local class name are the same.\n const kind = classId ? resolveWrapperKind(classId.name, classId.name, state) : undefined;\n if (!classId || !kind) return;\n\n const className = classId.name;\n\n // Strip the `export ` keyword\n state.ms.overwrite(exportNode.start, classDecl.start, '');\n\n const wrappedName = wrapLocalClass(className, classDecl, kind, state);\n state.ms.appendLeft(exportNode.end, `export { ${wrappedName} as ${className} };\\n`);\n\n state.wrappedClasses.add(className);\n state.autoWrapped.add(className);\n}\n\n/**\n * Wrap a class declared in this module and return the binding that holds the wrapper.\n *\n * The declaration is left exactly as written. Only the *export* has to become the wrapper, so the\n * wrapper gets its own binding and the export is aliased to it, the same shape as the documented\n * manual `instrument*WithSentry` pattern and the cross-module re-export path below. Renaming the\n * declaration instead (`class __SENTRY_ORIGINAL_MyAgent__`) would also rename what the class reports\n * as `Function.prototype.name`, which libraries read to identify the user's class: `@cloudflare/think`\n * hands `this.constructor.name` to the AI SDK as the telemetry `functionId`, and that surfaced as a\n * `gen_ai.invoke_agent __SENTRY_ORIGINAL_MyAgent__` span.\n */\nfunction wrapLocalClass(\n localName: string,\n localClass: ClassDeclarationNode,\n kind: ClassWrapperKind,\n state: TransformState,\n): string {\n const existing = state.wrappedLocals.get(localName);\n if (existing) return existing;\n\n const wrappedName = `__SENTRY_WRAPPED_${localName}__`;\n state.wrappedLocals.set(localName, wrappedName);\n state.ms.appendLeft(\n localClass.end,\n `\\nconst ${wrappedName} = __SENTRY__.${WRAPPER_METHODS[kind]}(${state.optionsFn}, ${localName});\\n`,\n );\n state.needsImport = true;\n return wrappedName;\n}\n\n/**\n * Wrap the configured classes an `export { ... }` statement names.\n *\n * Each such specifier is re-pointed at a binding holding the wrapper, which means rebuilding the\n * statement; specifiers this plugin has no business touching are carried over verbatim. For a class\n * declared in this module the wrapper binding follows the declaration (see {@link wrapLocalClass}).\n * A class that lives in **another** module — imported and re-exported, or re-exported directly — is\n * first bound under a private name, since an import binding cannot be reassigned and the `from` form\n * has no local binding at all.\n */\nfunction wrapSpecifierExports(node: ExportNamedNode, ctx: TransformContext, state: TransformState): void {\n const specifiers = node.specifiers ?? [];\n if (specifiers.length === 0) return;\n\n const sourceLiteral = node.source ? state.ms.original.slice(node.source.start, node.source.end) : undefined;\n\n const prelude: string[] = [];\n const wrappedPairs: string[] = [];\n const kept: string[] = [];\n\n for (const specifier of specifiers) {\n const pair = wrapSpecifier(specifier, sourceLiteral, ctx, state, prelude);\n if (pair) {\n wrappedPairs.push(pair);\n } else {\n kept.push(state.ms.original.slice(specifier.start, specifier.end));\n }\n }\n\n if (wrappedPairs.length === 0) return;\n\n const statements = [...prelude, `export { ${wrappedPairs.join(', ')} };`];\n if (kept.length > 0) {\n const clause = `export { ${kept.join(', ')} }`;\n statements.push(sourceLiteral ? `${clause} from ${sourceLiteral};` : `${clause};`);\n }\n state.ms.overwrite(node.start, node.end, statements.join('\\n'));\n}\n\n/**\n * `export { handler as default }`, the form bundlers emit for a default export. The export is set\n * in two steps. Right after `handler` is declared, it is bound to `handler` as-is, so a circular\n * import that reads it during module evaluation gets the handler, as before the transform. At the\n * end of the module, it is rebound to the wrapper, so a handler assigned or given methods later is\n * wrapped as it ends up. The binding is a `var`: a read before `handler` is declared gets\n * `undefined`, as it would from the bundler's own `var`, where a `const` would throw and stop the\n * Worker from starting.\n */\nfunction wrapDefaultSpecifier(localName: string, state: TransformState): string | undefined {\n if (state.manuallyWrappedLocals.has(localName)) return undefined;\n\n // Same as `export default Foo`: re-point at the wrapper a named export already made.\n const wrappedName = state.wrappedLocals.get(localName);\n if (wrappedName) {\n state.autoWrapped.add(DEFAULT_EXPORT);\n return `${wrappedName} as default`;\n }\n\n const declaringStatement = state.declaringStatements.get(localName);\n if (declaringStatement) {\n state.ms.appendLeft(declaringStatement.end, `\\nvar __SENTRY_DEFAULT_EXPORT__ = ${localName};`);\n }\n state.ms.append(\n `\\n${declaringStatement ? '' : 'var '}__SENTRY_DEFAULT_EXPORT__ = __SENTRY__.withSentry(${state.optionsFn}, ${localName});`,\n );\n state.needsImport = true;\n state.autoWrapped.add(DEFAULT_EXPORT);\n return '__SENTRY_DEFAULT_EXPORT__ as default';\n}\n\n/**\n * `export { default } from './handler'`. The handler may already be wrapped in its own module,\n * which this transform cannot see, so the emitted guard returns such a handler as-is.\n *\n * The original re-export is a live binding to the handler module's export, but the wrapper is not\n * set until this module's body runs. A circular import that reads the default export before then\n * gets `undefined` instead of the handler. The binding is a `var` so that the read does not throw,\n * as a `const` would, and stop the Worker from starting. See `wrapDefaultSpecifier`.\n */\nfunction wrapDefaultReexport(\n localName: string,\n sourceLiteral: string,\n state: TransformState,\n prelude: string[],\n): string {\n const target = '__SENTRY_REEXPORT_default__';\n prelude.push(\n localName === DEFAULT_IMPORT\n ? `import ${target} from ${sourceLiteral};`\n : `import { ${localName} as ${target} } from ${sourceLiteral};`,\n `var __SENTRY_DEFAULT_EXPORT__ = __SENTRY__._INTERNAL_wrapUnlessInstrumented(__SENTRY__.withSentry, ${state.optionsFn}, ${target});`,\n );\n state.needsImport = true;\n state.autoWrapped.add(DEFAULT_EXPORT);\n return '__SENTRY_DEFAULT_EXPORT__ as default';\n}\n\n/**\n * Handle one export specifier, returning the `Wrapped as Exported` pair to emit for a class that\n * gets wrapped. The import/wrapper statements a cross-module pair depends on are pushed onto\n * `prelude`; a local class's wrapper binding is emitted after its declaration instead.\n *\n * Returns `undefined` when the specifier can stay exactly as written: it doesn't name a configured\n * class, or the binding is already hand-wrapped.\n */\nfunction wrapSpecifier(\n specifier: ExportSpecifierNode,\n sourceLiteral: string | undefined,\n ctx: TransformContext,\n state: TransformState,\n prelude: string[],\n): string | undefined {\n const exportedName =\n specifier.type === 'ExportSpecifier' && specifier.exported?.type === 'Identifier'\n ? specifier.exported.name\n : undefined;\n const localName = specifier.local?.type === 'Identifier' ? specifier.local.name : undefined;\n // With a `from` clause the specifier names an export of the *source* module, not a binding here.\n const kind = exportedName\n ? resolveWrapperKind(exportedName, sourceLiteral ? undefined : localName, state)\n : undefined;\n\n if (!exportedName || !localName) return undefined;\n if (!kind) {\n if (exportedName !== DEFAULT_IMPORT) return undefined;\n return sourceLiteral\n ? wrapDefaultReexport(localName, sourceLiteral, state, prelude)\n : wrapDefaultSpecifier(localName, state);\n }\n\n // Without a `from` clause the specifier points at a module-local binding.\n if (!sourceLiteral) {\n const localClass = state.topLevelClasses.get(localName);\n\n if (localClass?.id) {\n const wrappedName = wrapLocalClass(localName, localClass, kind, state);\n state.wrappedClasses.add(exportedName);\n return `${wrappedName} as ${exportedName}`;\n }\n\n if (state.manuallyWrappedLocals.has(localName)) {\n state.wrappedClasses.add(exportedName);\n return undefined;\n }\n }\n\n // The class comes from another module: bind it under a private name (for the `from` form, which\n // has no local binding at all), wrap that, and export the wrapper under the configured name.\n let target = localName;\n\n if (sourceLiteral) {\n target = `__SENTRY_REEXPORT_${exportedName}__`;\n prelude.push(\n localName === DEFAULT_IMPORT\n ? `import ${target} from ${sourceLiteral};`\n : `import { ${localName} as ${target} } from ${sourceLiteral};`,\n );\n }\n\n const wrappedName = `__SENTRY_WRAPPED_${exportedName}__`;\n\n // The class may already be hand-wrapped in its own module, which this transform cannot see. The\n // emitted guard returns such a class as-is instead of nesting a second wrapper around it.\n prelude.push(\n `const ${wrappedName} = __SENTRY__._INTERNAL_wrapUnlessInstrumented(__SENTRY__.${WRAPPER_METHODS[kind]}, ${state.optionsFn}, ${target});`,\n );\n state.wrappedClasses.add(exportedName);\n state.autoWrapped.add(exportedName);\n state.needsImport = true;\n\n return `${wrappedName} as ${exportedName}`;\n}\n"],"mappings":";;;;;AAMA,MAAM,4BAA4B;AAGlC,MAAM,qBAAqB;AA8D3B,SAAS,eAAe,MAAgB,YAA6B;CACnE,IAAI,KAAK,SAAS,kBAAkB,OAAO;CAC3C,MAAM,SAAU,KAA4B;CAC5C,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,OAAO,SAAS,gBAAgB,OAAO,SAAS,YAAY,OAAO;CACvE,OACE,OAAO,SAAS,sBAAsB,OAAO,UAAU,SAAS,gBAAgB,OAAO,SAAS,SAAS;AAE7G;;AAgBA,MAAM,iBAAiB;;;;;;AAOvB,MAAM,kBAAoD;CACxD,eAAe;CACf,OAAO;CACP,UAAU;CACV,kBAAkB;AACpB;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,8BACd,MACA,KACA,KAC6B;CAC7B,MAAM,KAAK,IAAI,YAAY,IAAI;CAC/B,MAAM,kBAAkB,uBAAuB,GAAG;CAClD,MAAM,qBAAqB,IAAI,sBAAsB,CAAC;CACtD,MAAM,QAAwB;EAC5B;EACA,aAAa;EACb,gCAAgB,IAAI,IAAY;EAChC;EACA,+BAAe,IAAI,IAAoB;EACvC,eAAe,IAAI;EACnB,cAAc,IAAI,gCAAgB,IAAI,IAAY;EAClD,yBAAyB,8BAA8B,GAAG;EAE1D,WAAW,mBAAmB,SAAS,IAAI,4BAA4B,IAAI;EAC3E,6BAAa,IAAI,IAAgB;EACjC,uBAAuB,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;AAC9B"}
@@ -40,6 +40,8 @@ function resolveWranglerConfig(root, explicitPath) {
40
40
  const configDir = dirname(resolvedConfigPath);
41
41
  return {
42
42
  config: {
43
+ name: raw.name,
44
+ compatibilityDate: raw.compatibility_date,
43
45
  main: raw.main && ENTRY_FILE_REGEX.test(raw.main) ? resolve(configDir, raw.main) : raw.main,
44
46
  durableObjects: collectClassBindings(raw.durable_objects?.bindings),
45
47
  workflows: collectClassBindings(raw.workflows),
@@ -1 +1 @@
1
- {"version":3,"file":"wranglerConfig.js","names":[],"sources":["../../../../src/vite/wranglerConfig.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { type Unstable_Config, unstable_readConfig } from 'wrangler';\n\n/**\n * The slice of the wrangler configuration the auto-instrument plugin cares\n * about.\n */\nexport interface WranglerConfig {\n /**\n * An absolute path when `main` names a JS or TS file, otherwise the\n * original value (a package export or virtual module) for Vite to resolve.\n */\n main?: string;\n durableObjects: Array<{ name: string; className: string }>;\n workflows: Array<{ name: string; className: string }>;\n /**\n * Named `WorkerEntrypoint` exports this worker binds to itself via a service\n * binding (`services[]` whose `service` is this worker's own `name`). Only\n * self-bindings appear here: a service binding's `entrypoint` otherwise names\n * an export on a *different* worker, which this build can't wrap.\n */\n workerEntrypoints: string[];\n /**\n * Bindings whose RPC receiver lives in this worker, so this build instruments it. Not deduped by\n * class, two bindings may point at the same class and both names have to be listed.\n */\n sameWorkerBindings: SameWorkerBinding[];\n}\n\n// Same rule as `@cloudflare/vite-plugin`: only these extensions mark `main` as a file path.\nconst ENTRY_FILE_REGEX = /\\.(?:m?[jt]s|[jt]sx)$/;\n\n/** Stands in for a class name where a binding targets the module's default export. */\nexport const DEFAULT_EXPORT = Symbol('defaultExport');\n\n/** The name a binding or an export is known by, either an exported class name or the default export. */\nexport type ExportName = string | typeof DEFAULT_EXPORT;\n\nexport interface SameWorkerBinding {\n bindingName: string;\n className: ExportName;\n}\n\n/**\n * Locate and resolve the wrangler configuration via wrangler's own\n * `unstable_readConfig` — the API `@cloudflare/vite-plugin` uses.\n *\n * We only locate the file (probing `wrangler.json`, `.jsonc`, `.toml` inside\n * `root` with wrangler's own precedence, since it discovers from `cwd` rather\n * than an arbitrary root); wrangler then parses it and flattens the active\n * environment (honoring `CLOUDFLARE_ENV`). Durable Object and Workflow\n * bindings are the active environment's, matching what the deployed Worker\n * actually binds.\n *\n * Returns `undefined` when no config file is found or it can't be read/parsed\n * (the caller warns and disables auto-instrumentation rather than failing the\n * whole build).\n */\nexport function resolveWranglerConfig(\n root: string,\n explicitPath?: string,\n): { config: WranglerConfig; configPath: string; configDir: string } | undefined {\n const configPath = explicitPath\n ? resolve(root, explicitPath)\n : ['wrangler.json', 'wrangler.jsonc', 'wrangler.toml'].map(name => resolve(root, name)).find(existsSync);\n\n if (!configPath || !existsSync(configPath)) {\n return undefined;\n }\n\n let raw: Unstable_Config;\n try {\n // `hideWarnings` keeps wrangler's config diagnostics (e.g. missing DO\n // migrations) out of the Vite build output.\n raw = unstable_readConfig({ config: configPath }, { hideWarnings: true, preserveOriginalMain: true });\n } catch {\n return undefined;\n }\n\n const resolvedConfigPath = raw.configPath ?? configPath;\n const configDir = dirname(resolvedConfigPath);\n\n return {\n config: {\n main: raw.main && ENTRY_FILE_REGEX.test(raw.main) ? resolve(configDir, raw.main) : raw.main,\n durableObjects: collectClassBindings(raw.durable_objects?.bindings),\n workflows: collectClassBindings(raw.workflows),\n workerEntrypoints: collectSelfBoundEntrypoints(raw),\n sameWorkerBindings: collectSameWorkerBindings(raw),\n },\n configPath: resolvedConfigPath,\n configDir,\n };\n}\n\n/**\n * Collect named `WorkerEntrypoint` exports the worker binds to itself. A service\n * binding's `entrypoint` normally names an export on the *target* worker, so it\n * is only ours when `service` equals this worker's own `name`. Without a `name`\n * there is nothing to match against, so no entrypoints are derivable.\n */\nfunction collectSelfBoundEntrypoints(raw: Unstable_Config): string[] {\n if (!raw.name) {\n return [];\n }\n const entrypoints = new Set<string>();\n for (const binding of raw.services ?? []) {\n if (binding?.service === raw.name && typeof binding.entrypoint === 'string') {\n entrypoints.add(binding.entrypoint);\n }\n }\n return [...entrypoints];\n}\n\n/**\n * Bindings with a `script_name` or naming another worker target a class this build does not wrap,\n * so they are excluded and stay opt-in.\n */\nfunction collectSameWorkerBindings(raw: Unstable_Config): SameWorkerBinding[] {\n const bindings: SameWorkerBinding[] = [];\n\n for (const binding of raw.durable_objects?.bindings ?? []) {\n if (typeof binding?.name === 'string' && typeof binding.class_name === 'string' && !binding.script_name) {\n bindings.push({ bindingName: binding.name, className: binding.class_name });\n }\n }\n\n for (const binding of raw.services ?? []) {\n // A service binding is only ours when `service` names this worker; without a `name` none can be.\n if (raw.name && binding?.service === raw.name && typeof binding.binding === 'string') {\n bindings.push({\n bindingName: binding.binding,\n className: typeof binding.entrypoint === 'string' ? binding.entrypoint : DEFAULT_EXPORT,\n });\n }\n }\n\n return bindings;\n}\n\n/**\n * Map wrangler class bindings (Durable Objects, Workflows — same shape) to the\n * `{ name, className }` the transform needs, skipping duplicates and bindings\n * with a `script_name` (those reference a class exported by a *different*\n * worker, so there is nothing to wrap in this worker's entry file).\n */\nfunction collectClassBindings(\n bindings: ReadonlyArray<{ name: string; class_name?: string; script_name?: string }> | undefined,\n): Array<{ name: string; className: string }> {\n const result: Array<{ name: string; className: string }> = [];\n const seenClassNames = new Set<string>();\n for (const binding of bindings ?? []) {\n if (typeof binding?.class_name !== 'string' || binding.script_name || seenClassNames.has(binding.class_name)) {\n continue;\n }\n seenClassNames.add(binding.class_name);\n result.push({ name: binding.name, className: binding.class_name });\n }\n return result;\n}\n"],"mappings":";;;;AA+BA,MAAM,mBAAmB;;AAGzB,MAAa,iBAAiB,OAAO,eAAe;;;;;;;;;;;;;;;;AAyBpD,SAAgB,sBACd,MACA,cAC+E;CAC/E,MAAM,aAAa,eACf,QAAQ,MAAM,YAAY,IAC1B;EAAC;EAAiB;EAAkB;CAAe,CAAC,CAAC,KAAI,SAAQ,QAAQ,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,KAAK;EACZ,aAAa,QAAQ;EACrB,WAAW,OAAO,QAAQ,eAAe,WAAW,QAAQ,aAAa;CAC3E,CAAC;CAIL,OAAO;AACT;;;;;;;AAQA,SAAS,qBACP,UAC4C;CAC5C,MAAM,SAAqD,CAAC;CAC5D,MAAM,iCAAiB,IAAI,IAAY;CACvC,KAAK,MAAM,WAAW,YAAY,CAAC,GAAG;EACpC,IAAI,OAAO,SAAS,eAAe,YAAY,QAAQ,eAAe,eAAe,IAAI,QAAQ,UAAU,GACzG;EAEF,eAAe,IAAI,QAAQ,UAAU;EACrC,OAAO,KAAK;GAAE,MAAM,QAAQ;GAAM,WAAW,QAAQ;EAAW,CAAC;CACnE;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"wranglerConfig.js","names":[],"sources":["../../../../src/vite/wranglerConfig.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { type Unstable_Config, unstable_readConfig } from 'wrangler';\n\n/**\n * The slice of the wrangler configuration the auto-instrument plugin cares\n * about.\n */\nexport interface WranglerConfig {\n /**\n * The name of the deployed Worker, `<name>-<environment>` for a wrangler environment.\n */\n name?: string;\n /**\n * The `compatibility_date` that selects the workerd behavior of the Worker.\n */\n compatibilityDate?: string;\n /**\n * An absolute path when `main` names a JS or TS file, otherwise the\n * original value (a package export or virtual module) for Vite to resolve.\n */\n main?: string;\n durableObjects: Array<{ name: string; className: string }>;\n workflows: Array<{ name: string; className: string }>;\n /**\n * Named `WorkerEntrypoint` exports this worker binds to itself via a service\n * binding (`services[]` whose `service` is this worker's own `name`). Only\n * self-bindings appear here: a service binding's `entrypoint` otherwise names\n * an export on a *different* worker, which this build can't wrap.\n */\n workerEntrypoints: string[];\n /**\n * Bindings whose RPC receiver lives in this worker, so this build instruments it. Not deduped by\n * class, two bindings may point at the same class and both names have to be listed.\n */\n sameWorkerBindings: SameWorkerBinding[];\n}\n\n// Same rule as `@cloudflare/vite-plugin`: only these extensions mark `main` as a file path.\nconst ENTRY_FILE_REGEX = /\\.(?:m?[jt]s|[jt]sx)$/;\n\n/** Stands in for a class name where a binding targets the module's default export. */\nexport const DEFAULT_EXPORT = Symbol('defaultExport');\n\n/** The name a binding or an export is known by, either an exported class name or the default export. */\nexport type ExportName = string | typeof DEFAULT_EXPORT;\n\nexport interface SameWorkerBinding {\n bindingName: string;\n className: ExportName;\n}\n\n/**\n * Locate and resolve the wrangler configuration via wrangler's own\n * `unstable_readConfig` — the API `@cloudflare/vite-plugin` uses.\n *\n * We only locate the file (probing `wrangler.json`, `.jsonc`, `.toml` inside\n * `root` with wrangler's own precedence, since it discovers from `cwd` rather\n * than an arbitrary root); wrangler then parses it and flattens the active\n * environment (honoring `CLOUDFLARE_ENV`). Durable Object and Workflow\n * bindings are the active environment's, matching what the deployed Worker\n * actually binds.\n *\n * Returns `undefined` when no config file is found or it can't be read/parsed\n * (the caller warns and disables auto-instrumentation rather than failing the\n * whole build).\n */\nexport function resolveWranglerConfig(\n root: string,\n explicitPath?: string,\n): { config: WranglerConfig; configPath: string; configDir: string } | undefined {\n const configPath = explicitPath\n ? resolve(root, explicitPath)\n : ['wrangler.json', 'wrangler.jsonc', 'wrangler.toml'].map(name => resolve(root, name)).find(existsSync);\n\n if (!configPath || !existsSync(configPath)) {\n return undefined;\n }\n\n let raw: Unstable_Config;\n try {\n // `hideWarnings` keeps wrangler's config diagnostics (e.g. missing DO\n // migrations) out of the Vite build output.\n raw = unstable_readConfig({ config: configPath }, { hideWarnings: true, preserveOriginalMain: true });\n } catch {\n return undefined;\n }\n\n const resolvedConfigPath = raw.configPath ?? configPath;\n const configDir = dirname(resolvedConfigPath);\n\n return {\n config: {\n name: raw.name,\n compatibilityDate: raw.compatibility_date,\n main: raw.main && ENTRY_FILE_REGEX.test(raw.main) ? resolve(configDir, raw.main) : raw.main,\n durableObjects: collectClassBindings(raw.durable_objects?.bindings),\n workflows: collectClassBindings(raw.workflows),\n workerEntrypoints: collectSelfBoundEntrypoints(raw),\n sameWorkerBindings: collectSameWorkerBindings(raw),\n },\n configPath: resolvedConfigPath,\n configDir,\n };\n}\n\n/**\n * Collect named `WorkerEntrypoint` exports the worker binds to itself. A service\n * binding's `entrypoint` normally names an export on the *target* worker, so it\n * is only ours when `service` equals this worker's own `name`. Without a `name`\n * there is nothing to match against, so no entrypoints are derivable.\n */\nfunction collectSelfBoundEntrypoints(raw: Unstable_Config): string[] {\n if (!raw.name) {\n return [];\n }\n const entrypoints = new Set<string>();\n for (const binding of raw.services ?? []) {\n if (binding?.service === raw.name && typeof binding.entrypoint === 'string') {\n entrypoints.add(binding.entrypoint);\n }\n }\n return [...entrypoints];\n}\n\n/**\n * Bindings with a `script_name` or naming another worker target a class this build does not wrap,\n * so they are excluded and stay opt-in.\n */\nfunction collectSameWorkerBindings(raw: Unstable_Config): SameWorkerBinding[] {\n const bindings: SameWorkerBinding[] = [];\n\n for (const binding of raw.durable_objects?.bindings ?? []) {\n if (typeof binding?.name === 'string' && typeof binding.class_name === 'string' && !binding.script_name) {\n bindings.push({ bindingName: binding.name, className: binding.class_name });\n }\n }\n\n for (const binding of raw.services ?? []) {\n // A service binding is only ours when `service` names this worker; without a `name` none can be.\n if (raw.name && binding?.service === raw.name && typeof binding.binding === 'string') {\n bindings.push({\n bindingName: binding.binding,\n className: typeof binding.entrypoint === 'string' ? binding.entrypoint : DEFAULT_EXPORT,\n });\n }\n }\n\n return bindings;\n}\n\n/**\n * Map wrangler class bindings (Durable Objects, Workflows — same shape) to the\n * `{ name, className }` the transform needs, skipping duplicates and bindings\n * with a `script_name` (those reference a class exported by a *different*\n * worker, so there is nothing to wrap in this worker's entry file).\n */\nfunction collectClassBindings(\n bindings: ReadonlyArray<{ name: string; class_name?: string; script_name?: string }> | undefined,\n): Array<{ name: string; className: string }> {\n const result: Array<{ name: string; className: string }> = [];\n const seenClassNames = new Set<string>();\n for (const binding of bindings ?? []) {\n if (typeof binding?.class_name !== 'string' || binding.script_name || seenClassNames.has(binding.class_name)) {\n continue;\n }\n seenClassNames.add(binding.class_name);\n result.push({ name: binding.name, className: binding.class_name });\n }\n return result;\n}\n"],"mappings":";;;;AAuCA,MAAM,mBAAmB;;AAGzB,MAAa,iBAAiB,OAAO,eAAe;;;;;;;;;;;;;;;;AAyBpD,SAAgB,sBACd,MACA,cAC+E;CAC/E,MAAM,aAAa,eACf,QAAQ,MAAM,YAAY,IAC1B;EAAC;EAAiB;EAAkB;CAAe,CAAC,CAAC,KAAI,SAAQ,QAAQ,MAAM,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU;CAEzG,IAAI,CAAC,cAAc,CAAC,WAAW,UAAU,GACvC;CAGF,IAAI;CACJ,IAAI;EAGF,MAAM,oBAAoB,EAAE,QAAQ,WAAW,GAAG;GAAE,cAAc;GAAM,sBAAsB;EAAK,CAAC;CACtG,QAAQ;EACN;CACF;CAEA,MAAM,qBAAqB,IAAI,cAAc;CAC7C,MAAM,YAAY,QAAQ,kBAAkB;CAE5C,OAAO;EACL,QAAQ;GACN,MAAM,IAAI;GACV,mBAAmB,IAAI;GACvB,MAAM,IAAI,QAAQ,iBAAiB,KAAK,IAAI,IAAI,IAAI,QAAQ,WAAW,IAAI,IAAI,IAAI,IAAI;GACvF,gBAAgB,qBAAqB,IAAI,iBAAiB,QAAQ;GAClE,WAAW,qBAAqB,IAAI,SAAS;GAC7C,mBAAmB,4BAA4B,GAAG;GAClD,oBAAoB,0BAA0B,GAAG;EACnD;EACA,YAAY;EACZ;CACF;AACF;;;;;;;AAQA,SAAS,4BAA4B,KAAgC;CACnE,IAAI,CAAC,IAAI,MACP,OAAO,CAAC;CAEV,MAAM,8BAAc,IAAI,IAAY;CACpC,KAAK,MAAM,WAAW,IAAI,YAAY,CAAC,GACrC,IAAI,SAAS,YAAY,IAAI,QAAQ,OAAO,QAAQ,eAAe,UACjE,YAAY,IAAI,QAAQ,UAAU;CAGtC,OAAO,CAAC,GAAG,WAAW;AACxB;;;;;AAMA,SAAS,0BAA0B,KAA2C;CAC5E,MAAM,WA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
+ {"version":3,"file":"baseSdk.d.ts","sourceRoot":"","sources":["../../src/baseSdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAehD,OAAO,KAAK,EAA2B,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AA0B5C;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,EAAE,CAqBhF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,SAAS,CAsGpF"}
@@ -17,6 +17,7 @@ export declare class CloudflareClient extends ServerRuntimeClient {
17
17
  private _unsubscribeSpanStart;
18
18
  private _unsubscribeSpanEnd;
19
19
  private _inBoundaryFlush;
20
+ private _envelopeDuringBoundaryFlush;
20
21
  private readonly _pendingEagerDrains;
21
22
  /**
22
23
  * Whether this client is a cached, cross-invocation client (`cacheClient`).
@@ -243,6 +244,9 @@ interface BaseCloudflareOptions {
243
244
  * Sets an optional server name (device name).
244
245
  *
245
246
  * This is useful for identifying which server or instance is sending events.
247
+ *
248
+ * @default the `SENTRY_NAME` variable of `env`, else the `name` of the wrangler config when you
249
+ * build with `sentryCloudflareVitePlugin`
246
250
  */
247
251
  serverName?: string;
248
252
  /**
@@ -276,6 +280,10 @@ interface BaseCloudflareOptions {
276
280
  * handler completes.
277
281
  *
278
282
  * @default true
283
+ *
284
+ * @deprecated `cacheClient` will be removed in the next major version (v12), and the client will always be cached.
285
+ * If you set `cacheClient: false`, please open an issue at https://github.com/getsentry/sentry-javascript/issues
286
+ * and tell us why `cacheClient: true` does not work for your use case.
279
287
  */
280
288
  cacheClient?: boolean;
281
289
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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AAK,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,KAAK,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,EACzG,CAAC,GAAG,OAAO,EACX,eAAe,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,uBAAuB,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,GAAG,CAAC,CAiBpG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,GAAG,UAAU,EAEhB,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,EAEjD,CAAC,SAAS,KAAK,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,KAAK,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,EACzG,CAAC,GAAG,OAAO,EACX,eAAe,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,uBAAuB,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAsB5F"}
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAyBlD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,iBAAiB,YAAK,EAAE,GAAG,EAAE,OAAO,GAAG,iBAAiB,CAqCpG"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAyBlD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,iBAAiB,YAAK,EAAE,GAAG,EAAE,OAAO,GAAG,iBAAiB,CAsCpG"}
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrion-deferred-channels.d.ts","sourceRoot":"","sources":["../../src/orchestrion-deferred-channels.ts"],"names":[],"mappings":"AAgBA,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAMnC,UAAU,yBAAyB;IACjC,KAAK,EAAE;QAAE,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAA;KAAE,CAAC;IACnC,GAAG,EAAE;QAAE,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAA;KAAE,CAAC;IACjC,KAAK,EAAE;QAAE,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAA;KAAE,CAAC;CACpC;AAWD,mGAAmG;AACnG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE1D;AAED,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,yBAAyB,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAMpF;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAgBjD"}
1
+ {"version":3,"file":"orchestrion-deferred-channels.d.ts","sourceRoot":"","sources":["../../src/orchestrion-deferred-channels.ts"],"names":[],"mappings":"AAgBA,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAMnC,UAAU,yBAAyB;IACjC,KAAK,EAAE;QAAE,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAA;KAAE,CAAC;IACnC,GAAG,EAAE;QAAE,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAA;KAAE,CAAC;IACjC,KAAK,EAAE;QAAE,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAA;KAAE,CAAC;CACpC;AAkBD,mGAAmG;AACnG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE1D;AAED,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,yBAAyB,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAMpF;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAiBjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"autoInstrument.d.ts","sourceRoot":"","sources":["../../../src/vite/autoInstrument.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,MAAM,CAAC;AAC7D,OAAO,EAA8C,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AA6C/F,KAAK,gBAAgB,GAAG,cAAc,GAAG;IACvC,IAAI,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClE,CAAC;AAEF,wBAAgB,oCAAoC,CAAC,OAAO,GAAE;IAAE,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAO;IAsC9F,IAAI;IAEJ,cAAc,SAAS;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,SAAS;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QACvC,MAAM,CAAC,EAAE;YAAE,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC;KACtC,GAAG,IAAI;IAmCF,SAAS,OACP,gBAAgB,QAChB,MAAM,MACR,MAAM,GACT,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC;EA+FzD"}
1
+ {"version":3,"file":"autoInstrument.d.ts","sourceRoot":"","sources":["../../../src/vite/autoInstrument.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,MAAM,CAAC;AAC7D,OAAO,EAA8C,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AA6C/F,KAAK,gBAAgB,GAAG,cAAc,GAAG;IACvC,IAAI,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClE,CAAC;AAEF,wBAAgB,oCAAoC,CAAC,OAAO,GAAE;IAAE,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAO;IAsC9F,IAAI;IAEJ,cAAc,SAAS;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,SAAS;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QACvC,MAAM,CAAC,EAAE;YAAE,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC;KACtC,GAAG,IAAI;IAmCF,SAAS,OACP,gBAAgB,QAChB,MAAM,MACR,MAAM,GACT,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC;EAgGzD"}
@@ -41,6 +41,9 @@ export interface SentryCloudflareVitePluginOptions {
41
41
  * Durable Objects and self service bindings) to `rpcTracePropagationBindings`. Bindings to
42
42
  * other workers stay opt-in, their receivers may not run Sentry.
43
43
  *
44
+ * The plugin also sets the `name` of your wrangler config as the default `serverName` and the
45
+ * `compatibility_date` as the runtime version, also for handlers you wrap yourself.
46
+ *
44
47
  * @default true
45
48
  */
46
49
  autoInstrumentation?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;;OAYG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;;;;;;;;;;;OAeG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,iCAAsC,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBnH"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;;OAYG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,iCAAsC,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBnH"}
@@ -39,6 +39,15 @@ export interface TransformContext {
39
39
  sentryModule?: string;
40
40
  /** @see {@link import('./wranglerConfig').WranglerConfig.sameWorkerBindings} */
41
41
  sameWorkerBindings?: readonly SameWorkerBinding[];
42
+ /**
43
+ * The Worker name and compatibility date, stored on `globalThis` as the default `serverName` and
44
+ * the runtime version. The entry stores them also when nothing is wrapped, so hand-wrapped
45
+ * handlers get them too.
46
+ */
47
+ workerInfo?: {
48
+ name?: string;
49
+ compatibilityDate?: string;
50
+ };
42
51
  }
43
52
  export interface TransformResult {
44
53
  code: string;
@@ -64,8 +73,9 @@ export interface TransformResult {
64
73
  * {@link TransformResult.wrappedClasses}.
65
74
  *
66
75
  * Exported (rather than inlined into the plugin) so it can be unit-tested with a
67
- * plain AST and no Vite context. Returns `undefined` when nothing was wrapped and
68
- * there are no already-manually-wrapped classes to report.
76
+ * plain AST and no Vite context. Returns `undefined` when nothing was wrapped,
77
+ * there are no already-manually-wrapped classes to report, and there is no
78
+ * {@link TransformContext.workerInfo} to store.
69
79
  */
70
80
  export declare function applyAutoInstrumentTransforms(code: string, ast: ProgramBody, ctx: TransformContext): TransformResult | undefined;
71
81
  //# sourceMappingURL=transform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/vite/transform.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAmC,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAS3F,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,EAAE,CAAC;CAClB;AA0DD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,OAAO,GAAG,UAAU,GAAG,kBAAkB,CAAC;AAiB3F,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC7C;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oHAAoH;IACpH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,kBAAkB,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACnD;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,M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,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5C;;;;OAIG;IACH,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,gBAAgB,GACpB,eAAe,GAAG,SAAS,CA0D7B"}
@@ -3,6 +3,14 @@
3
3
  * about.
4
4
  */
5
5
  export interface WranglerConfig {
6
+ /**
7
+ * The name of the deployed Worker, `<name>-<environment>` for a wrangler environment.
8
+ */
9
+ name?: string;
10
+ /**
11
+ * The `compatibility_date` that selects the workerd behavior of the Worker.
12
+ */
13
+ compatibilityDate?: string;
6
14
  /**
7
15
  * An absolute path when `main` names a JS or TS file, otherwise the
8
16
  * original value (a package export or virtual module) for Vite to resolve.
@@ -1 +1 @@
1
- {"version":3,"file":"wranglerConfig.d.ts","sourceRoot":"","sources":["../../../src/vite/wranglerConfig.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD;;;;;OAKG;IACH,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B;;;OAGG;IACH,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;CACzC;AAKD,sFAAsF;AACtF,eAAO,MAAM,c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CACvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,MAAM,GACpB;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAkC/E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/cloudflare",
3
- "version": "11.13.0",
3
+ "version": "11.15.0",
4
4
  "description": "Official Sentry SDK for Cloudflare Workers and Pages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -57,9 +57,9 @@
57
57
  "dependencies": {
58
58
  "@opentelemetry/api": "^1.9.1",
59
59
  "@sentry/conventions": "^0.33.0",
60
- "@sentry/core": "11.13.0",
61
- "@sentry/opentelemetry": "11.13.0",
62
- "@sentry/server-utils": "11.13.0",
60
+ "@sentry/core": "11.15.0",
61
+ "@sentry/opentelemetry": "11.15.0",
62
+ "@sentry/server-utils": "11.15.0",
63
63
  "magic-string": "~0.30.21"
64
64
  },
65
65
  "peerDependencies": {
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "devDependencies": {
82
82
  "@cloudflare/workers-types": "5.20260710.1",
83
- "@sentry-internal/rollup-utils": "11.13.0",
83
+ "@sentry-internal/rollup-utils": "11.15.0",
84
84
  "@types/node": "^20.19.0",
85
85
  "acorn": "^8.14.0",
86
86
  "vite": "^8.3.6",