@sentry/cloudflare 10.53.0 → 10.54.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 (166) hide show
  1. package/build/cjs/async.js +4 -30
  2. package/build/cjs/async.js.map +1 -1
  3. package/build/cjs/client.js +31 -58
  4. package/build/cjs/client.js.map +1 -1
  5. package/build/cjs/d1.js +26 -80
  6. package/build/cjs/d1.js.map +1 -1
  7. package/build/cjs/debug-build.js +0 -5
  8. package/build/cjs/debug-build.js.map +1 -1
  9. package/build/cjs/durableobject.js +44 -131
  10. package/build/cjs/durableobject.js.map +1 -1
  11. package/build/cjs/flush.js +47 -34
  12. package/build/cjs/flush.js.map +1 -1
  13. package/build/cjs/instrument.js +7 -48
  14. package/build/cjs/instrument.js.map +1 -1
  15. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js +9 -34
  16. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  17. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +20 -54
  18. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  19. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js +12 -66
  20. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  21. package/build/cjs/instrumentations/worker/instrumentEmail.js +21 -43
  22. package/build/cjs/instrumentations/worker/instrumentEmail.js.map +1 -1
  23. package/build/cjs/instrumentations/worker/instrumentEnv.js +12 -42
  24. package/build/cjs/instrumentations/worker/instrumentEnv.js.map +1 -1
  25. package/build/cjs/instrumentations/worker/instrumentFetch.js +20 -34
  26. package/build/cjs/instrumentations/worker/instrumentFetch.js.map +1 -1
  27. package/build/cjs/instrumentations/worker/instrumentFetcher.js +5 -19
  28. package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +1 -1
  29. package/build/cjs/instrumentations/worker/instrumentQueue.js +30 -62
  30. package/build/cjs/instrumentations/worker/instrumentQueue.js.map +1 -1
  31. package/build/cjs/instrumentations/worker/instrumentQueueProducer.js +31 -57
  32. package/build/cjs/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  33. package/build/cjs/instrumentations/worker/instrumentScheduled.js +25 -54
  34. package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +1 -1
  35. package/build/cjs/instrumentations/worker/instrumentTail.js +16 -43
  36. package/build/cjs/instrumentations/worker/instrumentTail.js.map +1 -1
  37. package/build/cjs/integrations/fetch.js +24 -56
  38. package/build/cjs/integrations/fetch.js.map +1 -1
  39. package/build/cjs/integrations/hono.js +7 -38
  40. package/build/cjs/integrations/hono.js.map +1 -1
  41. package/build/cjs/integrations/httpServer.js +6 -39
  42. package/build/cjs/integrations/httpServer.js.map +1 -1
  43. package/build/cjs/integrations/tracing/vercelai.js +3 -31
  44. package/build/cjs/integrations/tracing/vercelai.js.map +1 -1
  45. package/build/cjs/opentelemetry/tracer.js +17 -45
  46. package/build/cjs/opentelemetry/tracer.js.map +1 -1
  47. package/build/cjs/options.js +10 -46
  48. package/build/cjs/options.js.map +1 -1
  49. package/build/cjs/pages-plugin.js +9 -42
  50. package/build/cjs/pages-plugin.js.map +1 -1
  51. package/build/cjs/request.js +21 -67
  52. package/build/cjs/request.js.map +1 -1
  53. package/build/cjs/scope-utils.js +4 -15
  54. package/build/cjs/scope-utils.js.map +1 -1
  55. package/build/cjs/sdk.js +8 -25
  56. package/build/cjs/sdk.js.map +1 -1
  57. package/build/cjs/transport.js +14 -48
  58. package/build/cjs/transport.js.map +1 -1
  59. package/build/cjs/utils/instrumentContext.js +16 -52
  60. package/build/cjs/utils/instrumentContext.js.map +1 -1
  61. package/build/cjs/utils/isBinding.js +3 -23
  62. package/build/cjs/utils/isBinding.js.map +1 -1
  63. package/build/cjs/utils/isCloudflareClass.js +2 -8
  64. package/build/cjs/utils/isCloudflareClass.js.map +1 -1
  65. package/build/cjs/utils/rpcMeta.js +8 -32
  66. package/build/cjs/utils/rpcMeta.js.map +1 -1
  67. package/build/cjs/utils/rpcOptions.js +9 -32
  68. package/build/cjs/utils/rpcOptions.js.map +1 -1
  69. package/build/cjs/utils/streaming.js +3 -29
  70. package/build/cjs/utils/streaming.js.map +1 -1
  71. package/build/cjs/utils/traceLinks.js +8 -33
  72. package/build/cjs/utils/traceLinks.js.map +1 -1
  73. package/build/cjs/vendor/stacktrace.js +6 -27
  74. package/build/cjs/vendor/stacktrace.js.map +1 -1
  75. package/build/cjs/withSentry.js +16 -47
  76. package/build/cjs/withSentry.js.map +1 -1
  77. package/build/cjs/workflows.js +40 -100
  78. package/build/cjs/workflows.js.map +1 -1
  79. package/build/cjs/wrapMethodWithSentry.js +110 -167
  80. package/build/cjs/wrapMethodWithSentry.js.map +1 -1
  81. package/build/esm/async.js +4 -30
  82. package/build/esm/async.js.map +1 -1
  83. package/build/esm/client.js +31 -58
  84. package/build/esm/client.js.map +1 -1
  85. package/build/esm/d1.js +26 -80
  86. package/build/esm/d1.js.map +1 -1
  87. package/build/esm/debug-build.js +0 -5
  88. package/build/esm/debug-build.js.map +1 -1
  89. package/build/esm/durableobject.js +44 -131
  90. package/build/esm/durableobject.js.map +1 -1
  91. package/build/esm/flush.js +47 -34
  92. package/build/esm/flush.js.map +1 -1
  93. package/build/esm/instrument.js +7 -48
  94. package/build/esm/instrument.js.map +1 -1
  95. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js +9 -34
  96. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  97. package/build/esm/instrumentations/instrumentDurableObjectStorage.js +20 -54
  98. package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  99. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js +12 -66
  100. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  101. package/build/esm/instrumentations/worker/instrumentEmail.js +21 -43
  102. package/build/esm/instrumentations/worker/instrumentEmail.js.map +1 -1
  103. package/build/esm/instrumentations/worker/instrumentEnv.js +12 -42
  104. package/build/esm/instrumentations/worker/instrumentEnv.js.map +1 -1
  105. package/build/esm/instrumentations/worker/instrumentFetch.js +20 -34
  106. package/build/esm/instrumentations/worker/instrumentFetch.js.map +1 -1
  107. package/build/esm/instrumentations/worker/instrumentFetcher.js +5 -19
  108. package/build/esm/instrumentations/worker/instrumentFetcher.js.map +1 -1
  109. package/build/esm/instrumentations/worker/instrumentQueue.js +30 -62
  110. package/build/esm/instrumentations/worker/instrumentQueue.js.map +1 -1
  111. package/build/esm/instrumentations/worker/instrumentQueueProducer.js +31 -57
  112. package/build/esm/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  113. package/build/esm/instrumentations/worker/instrumentScheduled.js +25 -54
  114. package/build/esm/instrumentations/worker/instrumentScheduled.js.map +1 -1
  115. package/build/esm/instrumentations/worker/instrumentTail.js +16 -43
  116. package/build/esm/instrumentations/worker/instrumentTail.js.map +1 -1
  117. package/build/esm/integrations/fetch.js +24 -56
  118. package/build/esm/integrations/fetch.js.map +1 -1
  119. package/build/esm/integrations/hono.js +7 -38
  120. package/build/esm/integrations/hono.js.map +1 -1
  121. package/build/esm/integrations/httpServer.js +6 -39
  122. package/build/esm/integrations/httpServer.js.map +1 -1
  123. package/build/esm/integrations/tracing/vercelai.js +3 -31
  124. package/build/esm/integrations/tracing/vercelai.js.map +1 -1
  125. package/build/esm/opentelemetry/tracer.js +17 -45
  126. package/build/esm/opentelemetry/tracer.js.map +1 -1
  127. package/build/esm/options.js +10 -46
  128. package/build/esm/options.js.map +1 -1
  129. package/build/esm/package.json +1 -1
  130. package/build/esm/pages-plugin.js +9 -42
  131. package/build/esm/pages-plugin.js.map +1 -1
  132. package/build/esm/request.js +21 -67
  133. package/build/esm/request.js.map +1 -1
  134. package/build/esm/scope-utils.js +4 -15
  135. package/build/esm/scope-utils.js.map +1 -1
  136. package/build/esm/sdk.js +8 -25
  137. package/build/esm/sdk.js.map +1 -1
  138. package/build/esm/transport.js +14 -48
  139. package/build/esm/transport.js.map +1 -1
  140. package/build/esm/utils/instrumentContext.js +16 -52
  141. package/build/esm/utils/instrumentContext.js.map +1 -1
  142. package/build/esm/utils/isBinding.js +3 -23
  143. package/build/esm/utils/isBinding.js.map +1 -1
  144. package/build/esm/utils/isCloudflareClass.js +2 -8
  145. package/build/esm/utils/isCloudflareClass.js.map +1 -1
  146. package/build/esm/utils/rpcMeta.js +8 -32
  147. package/build/esm/utils/rpcMeta.js.map +1 -1
  148. package/build/esm/utils/rpcOptions.js +9 -32
  149. package/build/esm/utils/rpcOptions.js.map +1 -1
  150. package/build/esm/utils/streaming.js +3 -29
  151. package/build/esm/utils/streaming.js.map +1 -1
  152. package/build/esm/utils/traceLinks.js +8 -33
  153. package/build/esm/utils/traceLinks.js.map +1 -1
  154. package/build/esm/vendor/stacktrace.js +6 -27
  155. package/build/esm/vendor/stacktrace.js.map +1 -1
  156. package/build/esm/withSentry.js +16 -47
  157. package/build/esm/withSentry.js.map +1 -1
  158. package/build/esm/workflows.js +40 -100
  159. package/build/esm/workflows.js.map +1 -1
  160. package/build/esm/wrapMethodWithSentry.js +110 -167
  161. package/build/esm/wrapMethodWithSentry.js.map +1 -1
  162. package/build/types/client.d.ts.map +1 -1
  163. package/build/types/flush.d.ts.map +1 -1
  164. package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
  165. package/build/types/pages-plugin.d.ts.map +1 -1
  166. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"hono.js","sources":["../../../src/integrations/hono.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport {\n captureException,\n debug,\n defineIntegration,\n getActiveSpan,\n getClient,\n getIsolationScope,\n getRootSpan,\n updateSpanName,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\nconst INTEGRATION_NAME = 'Hono';\n\ninterface HonoError extends Error {\n status?: number;\n}\n\n// Minimal type - only exported for tests\nexport interface HonoContext {\n req: { method: string; path?: string };\n}\n\nexport interface Options {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n * @param error Captured middleware error\n */\n shouldHandleError?(this: void, error: HonoError): boolean;\n}\n\n/** Only exported for internal use */\nexport function getHonoIntegration(): ReturnType<typeof _honoIntegration> | undefined {\n return getClient()?.getIntegrationByName(INTEGRATION_NAME);\n}\n\nfunction isHonoError(err: unknown): err is HonoError {\n if (err instanceof Error) {\n return true;\n }\n return typeof err === 'object' && err !== null && 'status' in (err as Record<string, unknown>);\n}\n\n// Vendored from https://github.com/honojs/hono/blob/d3abeb1f801aaa1b334285c73da5f5f022dbcadb/src/helper/route/index.ts#L58-L59\nconst routePath = (c: HonoContext): string => c.req?.path ?? '';\n\nconst _honoIntegration = ((options: Partial<Options> = {}) => {\n return {\n name: INTEGRATION_NAME,\n // Hono error handler: https://github.com/honojs/hono/blob/d3abeb1f801aaa1b334285c73da5f5f022dbcadb/src/hono-base.ts#L35\n handleHonoException(err: HonoError, context: HonoContext): void {\n const shouldHandleError = options.shouldHandleError || defaultShouldHandleError;\n\n if (!isHonoError(err)) {\n DEBUG_BUILD && debug.log(\"[Hono] Won't capture exception in `onError` because it's not a Hono error.\", err);\n return;\n }\n\n if (shouldHandleError(err)) {\n if (context) {\n const activeSpan = getActiveSpan();\n const spanName = `${context.req.method} ${routePath(context)}`;\n\n if (activeSpan) {\n activeSpan.updateName(spanName);\n updateSpanName(getRootSpan(activeSpan), spanName);\n }\n\n getIsolationScope().setTransactionName(spanName);\n }\n\n captureException(err, { mechanism: { handled: false, type: 'auto.faas.hono.error_handler' } });\n } else {\n DEBUG_BUILD && debug.log('[Hono] Not capturing exception because `shouldHandleError` returned `false`.', err);\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Automatically captures exceptions caught with the `onError` handler in Hono.\n *\n * The integration is enabled by default.\n *\n * @example\n * integrations: [\n * honoIntegration({\n * shouldHandleError: (err) => true; // always capture exceptions in onError\n * })\n * ]\n */\nexport const honoIntegration = defineIntegration(_honoIntegration);\n\n/**\n * Default function to determine if an error should be sent to Sentry\n *\n * 3xx and 4xx errors are not sent by default.\n */\nfunction defaultShouldHandleError(error: HonoError): boolean {\n const statusCode = error?.status;\n // 3xx and 4xx errors are not sent by default.\n return statusCode ? statusCode >= 500 || statusCode <= 299 : true;\n}\n"],"names":[],"mappings":";;;AAaA,MAAM,gBAAA,GAAmB,MAAM;;AAmB/B;AACO,SAAS,kBAAkB,GAAoD;AACtF,EAAE,OAAO,SAAS,EAAE,EAAE,oBAAoB,CAAC,gBAAgB,CAAC;AAC5D;;AAEA,SAAS,WAAW,CAAC,GAAG,EAA6B;AACrD,EAAE,IAAI,GAAA,YAAe,KAAK,EAAE;AAC5B,IAAI,OAAO,IAAI;AACf,EAAE;AACF,EAAE,OAAO,OAAO,GAAA,KAAQ,YAAY,GAAA,KAAQ,IAAA,IAAQ,QAAA,KAAa,KAA+B;AAChG;;AAEA;AACA,MAAM,SAAA,GAAY,CAAC,CAAC,KAA0B,CAAC,CAAC,GAAG,EAAE,IAAA,IAAQ,EAAE;;AAE/D,MAAM,gBAAA,IAAoB,CAAC,OAAO,GAAqB,EAAE,KAAK;AAC9D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B;AACA,IAAI,mBAAmB,CAAC,GAAG,EAAa,OAAO,EAAqB;AACpE,MAAM,MAAM,iBAAA,GAAoB,OAAO,CAAC,iBAAA,IAAqB,wBAAwB;;AAErF,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;AAC7B,QAAQ,WAAA,IAAe,KAAK,CAAC,GAAG,CAAC,4EAA4E,EAAE,GAAG,CAAC;AACnH,QAAQ;AACR,MAAM;;AAEN,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE;AAClC,QAAQ,IAAI,OAAO,EAAE;AACrB,UAAU,MAAM,UAAA,GAAa,aAAa,EAAE;AAC5C,UAAU,MAAM,QAAA,GAAW,CAAC,EAAA,OAAA,CAAA,GAAA,CAAA,MAAA,CAAA,CAAA,EAAA,SAAA,CAAA,OAAA,CAAA,CAAA,CAAA;;AAEA,UAAA,IAAA,UAAA,EAAA;AACA,YAAA,UAAA,CAAA,UAAA,CAAA,QAAA,CAAA;AACA,YAAA,cAAA,CAAA,WAAA,CAAA,UAAA,CAAA,EAAA,QAAA,CAAA;AACA,UAAA;;AAEA,UAAA,iBAAA,EAAA,CAAA,kBAAA,CAAA,QAAA,CAAA;AACA,QAAA;;AAEA,QAAA,gBAAA,CAAA,GAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA,IAAA,EAAA,8BAAA,EAAA,EAAA,CAAA;AACA,MAAA,CAAA,MAAA;AACA,QAAA,WAAA,IAAA,KAAA,CAAA,GAAA,CAAA,8EAAA,EAAA,GAAA,CAAA;AACA,MAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,eAAA,GAAA,iBAAA,CAAA,gBAAA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAA,wBAAA,CAAA,KAAA,EAAA;AACA,EAAA,MAAA,UAAA,GAAA,KAAA,EAAA,MAAA;AACA;AACA,EAAA,OAAA,UAAA,GAAA,UAAA,IAAA,GAAA,IAAA,UAAA,IAAA,GAAA,GAAA,IAAA;AACA;;;;"}
1
+ {"version":3,"file":"hono.js","sources":["../../../src/integrations/hono.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport {\n captureException,\n debug,\n defineIntegration,\n getActiveSpan,\n getClient,\n getIsolationScope,\n getRootSpan,\n updateSpanName,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\nconst INTEGRATION_NAME = 'Hono';\n\ninterface HonoError extends Error {\n status?: number;\n}\n\n// Minimal type - only exported for tests\nexport interface HonoContext {\n req: { method: string; path?: string };\n}\n\nexport interface Options {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n * @param error Captured middleware error\n */\n shouldHandleError?(this: void, error: HonoError): boolean;\n}\n\n/** Only exported for internal use */\nexport function getHonoIntegration(): ReturnType<typeof _honoIntegration> | undefined {\n return getClient()?.getIntegrationByName(INTEGRATION_NAME);\n}\n\nfunction isHonoError(err: unknown): err is HonoError {\n if (err instanceof Error) {\n return true;\n }\n return typeof err === 'object' && err !== null && 'status' in (err as Record<string, unknown>);\n}\n\n// Vendored from https://github.com/honojs/hono/blob/d3abeb1f801aaa1b334285c73da5f5f022dbcadb/src/helper/route/index.ts#L58-L59\nconst routePath = (c: HonoContext): string => c.req?.path ?? '';\n\nconst _honoIntegration = ((options: Partial<Options> = {}) => {\n return {\n name: INTEGRATION_NAME,\n // Hono error handler: https://github.com/honojs/hono/blob/d3abeb1f801aaa1b334285c73da5f5f022dbcadb/src/hono-base.ts#L35\n handleHonoException(err: HonoError, context: HonoContext): void {\n const shouldHandleError = options.shouldHandleError || defaultShouldHandleError;\n\n if (!isHonoError(err)) {\n DEBUG_BUILD && debug.log(\"[Hono] Won't capture exception in `onError` because it's not a Hono error.\", err);\n return;\n }\n\n if (shouldHandleError(err)) {\n if (context) {\n const activeSpan = getActiveSpan();\n const spanName = `${context.req.method} ${routePath(context)}`;\n\n if (activeSpan) {\n activeSpan.updateName(spanName);\n updateSpanName(getRootSpan(activeSpan), spanName);\n }\n\n getIsolationScope().setTransactionName(spanName);\n }\n\n captureException(err, { mechanism: { handled: false, type: 'auto.faas.hono.error_handler' } });\n } else {\n DEBUG_BUILD && debug.log('[Hono] Not capturing exception because `shouldHandleError` returned `false`.', err);\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Automatically captures exceptions caught with the `onError` handler in Hono.\n *\n * The integration is enabled by default.\n *\n * @example\n * integrations: [\n * honoIntegration({\n * shouldHandleError: (err) => true; // always capture exceptions in onError\n * })\n * ]\n */\nexport const honoIntegration = defineIntegration(_honoIntegration);\n\n/**\n * Default function to determine if an error should be sent to Sentry\n *\n * 3xx and 4xx errors are not sent by default.\n */\nfunction defaultShouldHandleError(error: HonoError): boolean {\n const statusCode = error?.status;\n // 3xx and 4xx errors are not sent by default.\n return statusCode ? statusCode >= 500 || statusCode <= 299 : true;\n}\n"],"names":[],"mappings":";;;AAaA,MAAM,gBAAA,GAAmB,MAAA;AAoBlB,SAAS,kBAAA,GAAsE;AACpF,EAAA,OAAO,SAAA,EAAU,EAAG,oBAAA,CAAqB,gBAAgB,CAAA;AAC3D;AAEA,SAAS,YAAY,GAAA,EAAgC;AACnD,EAAA,IAAI,eAAe,KAAA,EAAO;AACxB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,QAAQ,QAAA,IAAa,GAAA;AACjE;AAGA,MAAM,SAAA,GAAY,CAAC,CAAA,KAA2B,CAAA,CAAE,KAAK,IAAA,IAAQ,EAAA;AAE7D,MAAM,gBAAA,IAAoB,CAAC,OAAA,GAA4B,EAAC,KAAM;AAC5D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA;AAAA,IAEN,mBAAA,CAAoB,KAAgB,OAAA,EAA4B;AAC9D,MAAA,MAAM,iBAAA,GAAoB,QAAQ,iBAAA,IAAqB,wBAAA;AAEvD,MAAA,IAAI,CAAC,WAAA,CAAY,GAAG,CAAA,EAAG;AACrB,QAAA,WAAA,IAAe,KAAA,CAAM,GAAA,CAAI,4EAAA,EAA8E,GAAG,CAAA;AAC1G,QAAA;AAAA,MACF;AAEA,MAAA,IAAI,iBAAA,CAAkB,GAAG,CAAA,EAAG;AAC1B,QAAA,IAAI,OAAA,EAAS;AACX,UAAA,MAAM,aAAa,aAAA,EAAc;AACjC,UAAA,MAAM,QAAA,GAAW,GAAG,OAAA,CAAQ,GAAA,CAAI,MAAM,CAAA,CAAA,EAAI,SAAA,CAAU,OAAO,CAAC,CAAA,CAAA;AAE5D,UAAA,IAAI,UAAA,EAAY;AACd,YAAA,UAAA,CAAW,WAAW,QAAQ,CAAA;AAC9B,YAAA,cAAA,CAAe,WAAA,CAAY,UAAU,CAAA,EAAG,QAAQ,CAAA;AAAA,UAClD;AAEA,UAAA,iBAAA,EAAkB,CAAE,mBAAmB,QAAQ,CAAA;AAAA,QACjD;AAEA,QAAA,gBAAA,CAAiB,GAAA,EAAK,EAAE,SAAA,EAAW,EAAE,SAAS,KAAA,EAAO,IAAA,EAAM,8BAAA,EAA+B,EAAG,CAAA;AAAA,MAC/F,CAAA,MAAO;AACL,QAAA,WAAA,IAAe,KAAA,CAAM,GAAA,CAAI,8EAAA,EAAgF,GAAG,CAAA;AAAA,MAC9G;AAAA,IACF;AAAA,GACF;AACF,CAAA,CAAA;AAcO,MAAM,eAAA,GAAkB,kBAAkB,gBAAgB;AAOjE,SAAS,yBAAyB,KAAA,EAA2B;AAC3D,EAAA,MAAM,aAAa,KAAA,EAAO,MAAA;AAE1B,EAAA,OAAO,UAAA,GAAa,UAAA,IAAc,GAAA,IAAO,UAAA,IAAc,GAAA,GAAM,IAAA;AAC/D;;;;"}
@@ -1,62 +1,29 @@
1
1
  import { defineIntegration, getIsolationScope, captureBodyFromWinterCGRequest } from '@sentry/core';
2
2
 
3
- const INTEGRATION_NAME = 'HttpServer';
4
-
3
+ const INTEGRATION_NAME = "HttpServer";
5
4
  const _httpServerIntegration = ((options = {}) => {
6
5
  return {
7
6
  name: INTEGRATION_NAME,
8
- maxRequestBodySize: options.maxRequestBodySize ?? 'medium',
9
- ignoreRequestBody: options.ignoreRequestBody,
7
+ maxRequestBodySize: options.maxRequestBodySize ?? "medium",
8
+ ignoreRequestBody: options.ignoreRequestBody
10
9
  };
11
- }) ;
12
-
13
- /**
14
- * Configures incoming HTTP request handling for Cloudflare Workers.
15
- *
16
- * This integration controls how incoming HTTP request data is captured,
17
- * matching the API of `httpServerIntegration` in Node.js.
18
- *
19
- * @example
20
- * ```ts
21
- * Sentry.init({
22
- * integrations: [
23
- * Sentry.httpServerIntegration({
24
- * maxRequestBodySize: 'medium',
25
- * ignoreRequestBody: (url) => url.includes('/health'),
26
- * }),
27
- * ],
28
- * });
29
- * ```
30
- */
10
+ });
31
11
  const httpServerIntegration = defineIntegration(_httpServerIntegration);
32
-
33
- /**
34
- * Capture the request body based on the HttpServer integration config.
35
- * Called internally by `wrapRequestHandler`.
36
- */
37
12
  async function captureIncomingRequestBody(client, request) {
38
13
  const integration = client.getIntegrationByName(INTEGRATION_NAME);
39
-
40
14
  if (!integration) {
41
15
  return;
42
16
  }
43
-
44
17
  const maxRequestBodySize = integration.maxRequestBodySize;
45
-
46
- if (maxRequestBodySize === 'none') {
18
+ if (maxRequestBodySize === "none") {
47
19
  return;
48
20
  }
49
-
50
- // Skip GET and HEAD requests - they don't have bodies
51
- // Also skip OPTIONS, even if they may have a body, they might not give a lot of extra value
52
- if (request.method === 'GET' || request.method === 'HEAD' || request.method === 'OPTIONS') {
21
+ if (request.method === "GET" || request.method === "HEAD" || request.method === "OPTIONS") {
53
22
  return;
54
23
  }
55
-
56
24
  if (integration.ignoreRequestBody?.(request.url, request)) {
57
25
  return;
58
26
  }
59
-
60
27
  const isolationScope = getIsolationScope();
61
28
  await captureBodyFromWinterCGRequest(request, isolationScope, maxRequestBodySize);
62
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"httpServer.js","sources":["../../../src/integrations/httpServer.ts"],"sourcesContent":["import type { Client, IntegrationFn, MaxRequestBodySize } from '@sentry/core';\nimport { captureBodyFromWinterCGRequest, defineIntegration, getIsolationScope } from '@sentry/core';\n\nconst INTEGRATION_NAME = 'HttpServer';\n\nexport interface HttpServerIntegrationOptions {\n /**\n * Controls the maximum size of incoming request bodies attached to events.\n *\n * Only applies to requests with textual content types (text/*, application/json,\n * application/x-www-form-urlencoded, application/xml, application/graphql).\n * Binary data is not captured.\n *\n * Available options:\n * - `'none'`: No request bodies will be attached\n * - `'small'`: Request bodies up to 1,000 bytes will be attached\n * - `'medium'`: Request bodies up to 10,000 bytes will be attached (default)\n * - `'always'`: Request bodies will always be attached (up to 1MB limit)\n *\n * @default 'medium'\n */\n maxRequestBodySize?: MaxRequestBodySize;\n\n /**\n * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed, health check endpoints,\n * or requests containing sensitive data that should not be captured.\n *\n * @param url The full URL of the incoming request, including query string, protocol, host, etc.\n * @param request The incoming Request object.\n * @returns `true` to skip body capture for this request, `false` to capture normally.\n *\n * @example\n * ```ts\n * Sentry.httpServerIntegration({\n * ignoreRequestBody: (url) => url.includes('/health') || url.includes('/upload'),\n * })\n * ```\n */\n ignoreRequestBody?: (url: string, request: Request) => boolean;\n}\n\ninterface HttpServerIntegrationInstance {\n name: string;\n maxRequestBodySize: MaxRequestBodySize;\n ignoreRequestBody?: (url: string, request: Request) => boolean;\n}\n\nconst _httpServerIntegration = ((options: HttpServerIntegrationOptions = {}): HttpServerIntegrationInstance => {\n return {\n name: INTEGRATION_NAME,\n maxRequestBodySize: options.maxRequestBodySize ?? 'medium',\n ignoreRequestBody: options.ignoreRequestBody,\n };\n}) satisfies IntegrationFn;\n\n/**\n * Configures incoming HTTP request handling for Cloudflare Workers.\n *\n * This integration controls how incoming HTTP request data is captured,\n * matching the API of `httpServerIntegration` in Node.js.\n *\n * @example\n * ```ts\n * Sentry.init({\n * integrations: [\n * Sentry.httpServerIntegration({\n * maxRequestBodySize: 'medium',\n * ignoreRequestBody: (url) => url.includes('/health'),\n * }),\n * ],\n * });\n * ```\n */\nexport const httpServerIntegration = defineIntegration(_httpServerIntegration);\n\n/**\n * Capture the request body based on the HttpServer integration config.\n * Called internally by `wrapRequestHandler`.\n */\nexport async function captureIncomingRequestBody(client: Client, request: Request): Promise<void> {\n const integration = client.getIntegrationByName<HttpServerIntegrationInstance>(INTEGRATION_NAME);\n\n if (!integration) {\n return;\n }\n\n const maxRequestBodySize = integration.maxRequestBodySize;\n\n if (maxRequestBodySize === 'none') {\n return;\n }\n\n // Skip GET and HEAD requests - they don't have bodies\n // Also skip OPTIONS, even if they may have a body, they might not give a lot of extra value\n if (request.method === 'GET' || request.method === 'HEAD' || request.method === 'OPTIONS') {\n return;\n }\n\n if (integration.ignoreRequestBody?.(request.url, request)) {\n return;\n }\n\n const isolationScope = getIsolationScope();\n await captureBodyFromWinterCGRequest(request, isolationScope, maxRequestBodySize);\n}\n"],"names":[],"mappings":";;AAGA,MAAM,gBAAA,GAAmB,YAAY;;AA6CrC,MAAM,sBAAA,IAA0B,CAAC,OAAO,GAAiC,EAAE,KAAoC;AAC/G,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,kBAAkB,EAAE,OAAO,CAAC,kBAAA,IAAsB,QAAQ;AAC9D,IAAI,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;AAChD,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,qBAAA,GAAwB,iBAAiB,CAAC,sBAAsB;;AAE7E;AACA;AACA;AACA;AACO,eAAe,0BAA0B,CAAC,MAAM,EAAU,OAAO,EAA0B;AAClG,EAAE,MAAM,cAAc,MAAM,CAAC,oBAAoB,CAAgC,gBAAgB,CAAC;;AAElG,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,kBAAA,GAAqB,WAAW,CAAC,kBAAkB;;AAE3D,EAAE,IAAI,kBAAA,KAAuB,MAAM,EAAE;AACrC,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,IAAI,OAAO,CAAC,MAAA,KAAW,SAAS,OAAO,CAAC,MAAA,KAAW,UAAU,OAAO,CAAC,MAAA,KAAW,SAAS,EAAE;AAC7F,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,WAAW,CAAC,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE;AAC7D,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,cAAA,GAAiB,iBAAiB,EAAE;AAC5C,EAAE,MAAM,8BAA8B,CAAC,OAAO,EAAE,cAAc,EAAE,kBAAkB,CAAC;AACnF;;;;"}
1
+ {"version":3,"file":"httpServer.js","sources":["../../../src/integrations/httpServer.ts"],"sourcesContent":["import type { Client, IntegrationFn, MaxRequestBodySize } from '@sentry/core';\nimport { captureBodyFromWinterCGRequest, defineIntegration, getIsolationScope } from '@sentry/core';\n\nconst INTEGRATION_NAME = 'HttpServer';\n\nexport interface HttpServerIntegrationOptions {\n /**\n * Controls the maximum size of incoming request bodies attached to events.\n *\n * Only applies to requests with textual content types (text/*, application/json,\n * application/x-www-form-urlencoded, application/xml, application/graphql).\n * Binary data is not captured.\n *\n * Available options:\n * - `'none'`: No request bodies will be attached\n * - `'small'`: Request bodies up to 1,000 bytes will be attached\n * - `'medium'`: Request bodies up to 10,000 bytes will be attached (default)\n * - `'always'`: Request bodies will always be attached (up to 1MB limit)\n *\n * @default 'medium'\n */\n maxRequestBodySize?: MaxRequestBodySize;\n\n /**\n * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed, health check endpoints,\n * or requests containing sensitive data that should not be captured.\n *\n * @param url The full URL of the incoming request, including query string, protocol, host, etc.\n * @param request The incoming Request object.\n * @returns `true` to skip body capture for this request, `false` to capture normally.\n *\n * @example\n * ```ts\n * Sentry.httpServerIntegration({\n * ignoreRequestBody: (url) => url.includes('/health') || url.includes('/upload'),\n * })\n * ```\n */\n ignoreRequestBody?: (url: string, request: Request) => boolean;\n}\n\ninterface HttpServerIntegrationInstance {\n name: string;\n maxRequestBodySize: MaxRequestBodySize;\n ignoreRequestBody?: (url: string, request: Request) => boolean;\n}\n\nconst _httpServerIntegration = ((options: HttpServerIntegrationOptions = {}): HttpServerIntegrationInstance => {\n return {\n name: INTEGRATION_NAME,\n maxRequestBodySize: options.maxRequestBodySize ?? 'medium',\n ignoreRequestBody: options.ignoreRequestBody,\n };\n}) satisfies IntegrationFn;\n\n/**\n * Configures incoming HTTP request handling for Cloudflare Workers.\n *\n * This integration controls how incoming HTTP request data is captured,\n * matching the API of `httpServerIntegration` in Node.js.\n *\n * @example\n * ```ts\n * Sentry.init({\n * integrations: [\n * Sentry.httpServerIntegration({\n * maxRequestBodySize: 'medium',\n * ignoreRequestBody: (url) => url.includes('/health'),\n * }),\n * ],\n * });\n * ```\n */\nexport const httpServerIntegration = defineIntegration(_httpServerIntegration);\n\n/**\n * Capture the request body based on the HttpServer integration config.\n * Called internally by `wrapRequestHandler`.\n */\nexport async function captureIncomingRequestBody(client: Client, request: Request): Promise<void> {\n const integration = client.getIntegrationByName<HttpServerIntegrationInstance>(INTEGRATION_NAME);\n\n if (!integration) {\n return;\n }\n\n const maxRequestBodySize = integration.maxRequestBodySize;\n\n if (maxRequestBodySize === 'none') {\n return;\n }\n\n // Skip GET and HEAD requests - they don't have bodies\n // Also skip OPTIONS, even if they may have a body, they might not give a lot of extra value\n if (request.method === 'GET' || request.method === 'HEAD' || request.method === 'OPTIONS') {\n return;\n }\n\n if (integration.ignoreRequestBody?.(request.url, request)) {\n return;\n }\n\n const isolationScope = getIsolationScope();\n await captureBodyFromWinterCGRequest(request, isolationScope, maxRequestBodySize);\n}\n"],"names":[],"mappings":";;AAGA,MAAM,gBAAA,GAAmB,YAAA;AA6CzB,MAAM,sBAAA,IAA0B,CAAC,OAAA,GAAwC,EAAC,KAAqC;AAC7G,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,kBAAA,EAAoB,QAAQ,kBAAA,IAAsB,QAAA;AAAA,IAClD,mBAAmB,OAAA,CAAQ;AAAA,GAC7B;AACF,CAAA,CAAA;AAoBO,MAAM,qBAAA,GAAwB,kBAAkB,sBAAsB;AAM7E,eAAsB,0BAAA,CAA2B,QAAgB,OAAA,EAAiC;AAChG,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,oBAAA,CAAoD,gBAAgB,CAAA;AAE/F,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,qBAAqB,WAAA,CAAY,kBAAA;AAEvC,EAAA,IAAI,uBAAuB,MAAA,EAAQ;AACjC,IAAA;AAAA,EACF;AAIA,EAAA,IAAI,OAAA,CAAQ,WAAW,KAAA,IAAS,OAAA,CAAQ,WAAW,MAAA,IAAU,OAAA,CAAQ,WAAW,SAAA,EAAW;AACzF,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,WAAA,CAAY,iBAAA,GAAoB,OAAA,CAAQ,GAAA,EAAK,OAAO,CAAA,EAAG;AACzD,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,iBAAiB,iBAAA,EAAkB;AACzC,EAAA,MAAM,8BAAA,CAA+B,OAAA,EAAS,cAAA,EAAgB,kBAAkB,CAAA;AAClF;;;;"}
@@ -1,43 +1,15 @@
1
1
  import { defineIntegration, addVercelAiProcessors } from '@sentry/core';
2
2
 
3
- const INTEGRATION_NAME = 'VercelAI';
4
-
3
+ const INTEGRATION_NAME = "VercelAI";
5
4
  const _vercelAIIntegration = ((options = {}) => {
6
5
  return {
7
6
  name: INTEGRATION_NAME,
8
7
  options,
9
8
  setup(client) {
10
9
  addVercelAiProcessors(client);
11
- },
10
+ }
12
11
  };
13
- }) ;
14
-
15
- /**
16
- * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
17
- * This integration is not enabled by default, you need to manually add it.
18
- *
19
- * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
20
- *
21
- * You need to enable collecting spans for a specific call by setting
22
- * `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
23
- *
24
- * ```javascript
25
- * const result = await generateText({
26
- * model: openai('gpt-4-turbo'),
27
- * experimental_telemetry: { isEnabled: true },
28
- * });
29
- * ```
30
- *
31
- * If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each
32
- * function call by setting `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs`
33
- * to `true`.
34
- *
35
- * ```javascript
36
- * const result = await generateText({
37
- * model: openai('gpt-4-turbo'),
38
- * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },
39
- * });
40
- */
12
+ });
41
13
  const vercelAIIntegration = defineIntegration(_vercelAIIntegration);
42
14
 
43
15
  export { vercelAIIntegration };
@@ -1 +1 @@
1
- {"version":3,"file":"vercelai.js","sources":["../../../../src/integrations/tracing/vercelai.ts"],"sourcesContent":["/**\n * This is a copy of the Vercel AI integration from the node SDK.\n *\n * The only difference is that it does not use `@opentelemetry/instrumentation`\n * because Cloudflare Workers do not support it.\n *\n * Therefore, we cannot automatically patch setting `experimental_telemetry: { isEnabled: true }`\n * and users have to manually set this to get spans.\n */\n\nimport type { IntegrationFn } from '@sentry/core';\nimport { addVercelAiProcessors, defineIntegration } from '@sentry/core';\n\nconst INTEGRATION_NAME = 'VercelAI';\n\ninterface VercelAiOptions {\n /**\n * Enable or disable truncation of recorded input messages.\n * Defaults to `true`.\n */\n enableTruncation?: boolean;\n}\n\nconst _vercelAIIntegration = ((options: VercelAiOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n options,\n setup(client) {\n addVercelAiProcessors(client);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.\n * This integration is not enabled by default, you need to manually add it.\n *\n * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).\n *\n * You need to enable collecting spans for a specific call by setting\n * `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true },\n * });\n * ```\n *\n * If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each\n * function call by setting `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs`\n * to `true`.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },\n * });\n */\nexport const vercelAIIntegration = defineIntegration(_vercelAIIntegration);\n"],"names":[],"mappings":";;AAaA,MAAM,gBAAA,GAAmB,UAAU;;AAUnC,MAAM,oBAAA,IAAwB,CAAC,OAAO,GAAoB,EAAE,KAAK;AACjE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,OAAO;AACX,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,qBAAqB,CAAC,MAAM,CAAC;AACnC,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,mBAAA,GAAsB,iBAAiB,CAAC,oBAAoB;;;;"}
1
+ {"version":3,"file":"vercelai.js","sources":["../../../../src/integrations/tracing/vercelai.ts"],"sourcesContent":["/**\n * This is a copy of the Vercel AI integration from the node SDK.\n *\n * The only difference is that it does not use `@opentelemetry/instrumentation`\n * because Cloudflare Workers do not support it.\n *\n * Therefore, we cannot automatically patch setting `experimental_telemetry: { isEnabled: true }`\n * and users have to manually set this to get spans.\n */\n\nimport type { IntegrationFn } from '@sentry/core';\nimport { addVercelAiProcessors, defineIntegration } from '@sentry/core';\n\nconst INTEGRATION_NAME = 'VercelAI';\n\ninterface VercelAiOptions {\n /**\n * Enable or disable truncation of recorded input messages.\n * Defaults to `true`.\n */\n enableTruncation?: boolean;\n}\n\nconst _vercelAIIntegration = ((options: VercelAiOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n options,\n setup(client) {\n addVercelAiProcessors(client);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.\n * This integration is not enabled by default, you need to manually add it.\n *\n * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).\n *\n * You need to enable collecting spans for a specific call by setting\n * `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true },\n * });\n * ```\n *\n * If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each\n * function call by setting `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs`\n * to `true`.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },\n * });\n */\nexport const vercelAIIntegration = defineIntegration(_vercelAIIntegration);\n"],"names":[],"mappings":";;AAaA,MAAM,gBAAA,GAAmB,UAAA;AAUzB,MAAM,oBAAA,IAAwB,CAAC,OAAA,GAA2B,EAAC,KAAM;AAC/D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,OAAA;AAAA,IACA,MAAM,MAAA,EAAQ;AACZ,MAAA,qBAAA,CAAsB,MAAM,CAAA;AAAA,IAC9B;AAAA,GACF;AACF,CAAA,CAAA;AA4BO,MAAM,mBAAA,GAAsB,kBAAkB,oBAAoB;;;;"}
@@ -1,73 +1,45 @@
1
1
  import { trace } from '@opentelemetry/api';
2
2
  import { startInactiveSpan, startSpanManual } from '@sentry/core';
3
3
 
4
- /**
5
- * Set up a mock OTEL tracer to allow inter-op with OpenTelemetry emitted spans.
6
- * This is not perfect but handles easy/common use cases.
7
- */
8
4
  function setupOpenTelemetryTracer() {
9
5
  trace.setGlobalTracerProvider(new SentryCloudflareTraceProvider());
10
6
  }
11
-
12
- class SentryCloudflareTraceProvider {constructor() { SentryCloudflareTraceProvider.prototype.__init.call(this); }
13
- __init() {this._tracers = new Map();}
14
-
15
- getTracer(name, version, options) {
16
- const key = `${name}@${version || ''}:${options?.schemaUrl || ''}`;
7
+ class SentryCloudflareTraceProvider {
8
+ constructor() {
9
+ this._tracers = /* @__PURE__ */ new Map();
10
+ }
11
+ getTracer(name, version, options) {
12
+ const key = `${name}@${version || ""}:${options?.schemaUrl || ""}`;
17
13
  if (!this._tracers.has(key)) {
18
14
  this._tracers.set(key, new SentryCloudflareTracer());
19
15
  }
20
-
21
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22
16
  return this._tracers.get(key);
23
17
  }
24
18
  }
25
-
26
- class SentryCloudflareTracer {
27
- startSpan(name, options) {
19
+ class SentryCloudflareTracer {
20
+ startSpan(name, options) {
28
21
  return startInactiveSpan({
29
22
  ...options,
30
23
  name,
31
24
  attributes: {
32
25
  ...options?.attributes,
33
- 'sentry.cloudflare_tracer': true,
34
- },
26
+ "sentry.cloudflare_tracer": true
27
+ }
35
28
  });
36
29
  }
37
-
38
- /**
39
- * NOTE: This does not handle `context` being passed in. It will always put spans on the current scope.
40
- */
41
-
42
- startActiveSpan(
43
- name,
44
- options,
45
- context,
46
- fn,
47
- ) {
48
- const opts = (typeof options === 'object' && options !== null ? options : {}) ;
49
-
30
+ startActiveSpan(name, options, context, fn) {
31
+ const opts = typeof options === "object" && options !== null ? options : {};
50
32
  const spanOpts = {
51
33
  ...opts,
52
34
  name,
53
35
  attributes: {
54
36
  ...opts.attributes,
55
- 'sentry.cloudflare_tracer': true,
56
- },
37
+ "sentry.cloudflare_tracer": true
38
+ }
57
39
  };
58
-
59
- const callback = (
60
- typeof options === 'function'
61
- ? options
62
- : typeof context === 'function'
63
- ? context
64
- : typeof fn === 'function'
65
- ? fn
66
- : () => {}
67
- ) ;
68
-
69
- // In OTEL the semantic matches `startSpanManual` because spans are not auto-ended
70
- return startSpanManual(spanOpts, callback) ;
40
+ const callback = typeof options === "function" ? options : typeof context === "function" ? context : typeof fn === "function" ? fn : () => {
41
+ };
42
+ return startSpanManual(spanOpts, callback);
71
43
  }
72
44
  }
73
45
 
@@ -1 +1 @@
1
- {"version":3,"file":"tracer.js","sources":["../../../src/opentelemetry/tracer.ts"],"sourcesContent":["import type { Context, Span, SpanOptions, Tracer, TracerProvider } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\nimport { startInactiveSpan, startSpanManual } from '@sentry/core';\n\n/**\n * Set up a mock OTEL tracer to allow inter-op with OpenTelemetry emitted spans.\n * This is not perfect but handles easy/common use cases.\n */\nexport function setupOpenTelemetryTracer(): void {\n trace.setGlobalTracerProvider(new SentryCloudflareTraceProvider());\n}\n\nclass SentryCloudflareTraceProvider implements TracerProvider {\n private readonly _tracers: Map<string, Tracer> = new Map();\n\n public getTracer(name: string, version?: string, options?: { schemaUrl?: string }): Tracer {\n const key = `${name}@${version || ''}:${options?.schemaUrl || ''}`;\n if (!this._tracers.has(key)) {\n this._tracers.set(key, new SentryCloudflareTracer());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._tracers.get(key)!;\n }\n}\n\nclass SentryCloudflareTracer implements Tracer {\n public startSpan(name: string, options?: SpanOptions): Span {\n return startInactiveSpan({\n ...options,\n name,\n attributes: {\n ...options?.attributes,\n 'sentry.cloudflare_tracer': true,\n },\n });\n }\n\n /**\n * NOTE: This does not handle `context` being passed in. It will always put spans on the current scope.\n */\n public startActiveSpan<F extends (span: Span) => unknown>(name: string, fn: F): ReturnType<F>;\n public startActiveSpan<F extends (span: Span) => unknown>(name: string, options: SpanOptions, fn: F): ReturnType<F>;\n public startActiveSpan<F extends (span: Span) => unknown>(\n name: string,\n options: SpanOptions,\n context: Context,\n fn: F,\n ): ReturnType<F>;\n public startActiveSpan<F extends (span: Span) => unknown>(\n name: string,\n options: unknown,\n context?: unknown,\n fn?: F,\n ): ReturnType<F> {\n const opts = (typeof options === 'object' && options !== null ? options : {}) as SpanOptions;\n\n const spanOpts = {\n ...opts,\n name,\n attributes: {\n ...opts.attributes,\n 'sentry.cloudflare_tracer': true,\n },\n };\n\n const callback = (\n typeof options === 'function'\n ? options\n : typeof context === 'function'\n ? context\n : typeof fn === 'function'\n ? fn\n : () => {}\n ) as F;\n\n // In OTEL the semantic matches `startSpanManual` because spans are not auto-ended\n return startSpanManual(spanOpts, callback) as ReturnType<F>;\n }\n}\n"],"names":[],"mappings":";;;AAIA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,GAAS;AACjD,EAAE,KAAK,CAAC,uBAAuB,CAAC,IAAI,6BAA6B,EAAE,CAAC;AACpE;;AAEA,MAAM,+BAAwD,CAAA,WAAA,GAAA,EAAA,6BAAA,CAAA,SAAA,CAAA,MAAA,CAAA,IAAA,CAAA,IAAA,CAAA,CAAA,CAAA;AAC9D,mBAAmB,QAAQ,GAAwB,IAAI,GAAG,GAAC;;AAE3D,GAAS,SAAS,CAAC,IAAI,EAAU,OAAO,EAAW,OAAO,EAAmC;AAC7F,IAAI,MAAM,GAAA,GAAM,CAAC,EAAA,IAAA,CAAA,CAAA,EAAA,OAAA,IAAA,EAAA,CAAA,CAAA,EAAA,OAAA,EAAA,SAAA,IAAA,EAAA,CAAA,CAAA;AACA,IAAA,IAAA,CAAA,IAAA,CAAA,QAAA,CAAA,GAAA,CAAA,GAAA,CAAA,EAAA;AACA,MAAA,IAAA,CAAA,QAAA,CAAA,GAAA,CAAA,GAAA,EAAA,IAAA,sBAAA,EAAA,CAAA;AACA,IAAA;;AAEA;AACA,IAAA,OAAA,IAAA,CAAA,QAAA,CAAA,GAAA,CAAA,GAAA,CAAA;AACA,EAAA;AACA;;AAEA,MAAA,sBAAA,EAAA;AACA,GAAA,SAAA,CAAA,IAAA,EAAA,OAAA,EAAA;AACA,IAAA,OAAA,iBAAA,CAAA;AACA,MAAA,GAAA,OAAA;AACA,MAAA,IAAA;AACA,MAAA,UAAA,EAAA;AACA,QAAA,GAAA,OAAA,EAAA,UAAA;AACA,QAAA,0BAAA,EAAA,IAAA;AACA,OAAA;AACA,KAAA,CAAA;AACA,EAAA;;AAEA;AACA;AACA;;AASA,GAAA,eAAA;AACA,IAAA,IAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA,EAAA;AACA,IAAA;AACA,IAAA,MAAA,IAAA,IAAA,OAAA,OAAA,KAAA,QAAA,IAAA,OAAA,KAAA,IAAA,GAAA,OAAA,GAAA,EAAA,CAAA;;AAEA,IAAA,MAAA,QAAA,GAAA;AACA,MAAA,GAAA,IAAA;AACA,MAAA,IAAA;AACA,MAAA,UAAA,EAAA;AACA,QAAA,GAAA,IAAA,CAAA,UAAA;AACA,QAAA,0BAAA,EAAA,IAAA;AACA,OAAA;AACA,KAAA;;AAEA,IAAA,MAAA,QAAA;AACA,MAAA,OAAA,OAAA,KAAA;AACA,UAAA;AACA,UAAA,OAAA,OAAA,KAAA;AACA,YAAA;AACA,YAAA,OAAA,EAAA,KAAA;AACA,cAAA;AACA,cAAA,MAAA,CAAA;AACA,KAAA;;AAEA;AACA,IAAA,OAAA,eAAA,CAAA,QAAA,EAAA,QAAA,CAAA;AACA,EAAA;AACA;;;;"}
1
+ {"version":3,"file":"tracer.js","sources":["../../../src/opentelemetry/tracer.ts"],"sourcesContent":["import type { Context, Span, SpanOptions, Tracer, TracerProvider } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\nimport { startInactiveSpan, startSpanManual } from '@sentry/core';\n\n/**\n * Set up a mock OTEL tracer to allow inter-op with OpenTelemetry emitted spans.\n * This is not perfect but handles easy/common use cases.\n */\nexport function setupOpenTelemetryTracer(): void {\n trace.setGlobalTracerProvider(new SentryCloudflareTraceProvider());\n}\n\nclass SentryCloudflareTraceProvider implements TracerProvider {\n private readonly _tracers: Map<string, Tracer> = new Map();\n\n public getTracer(name: string, version?: string, options?: { schemaUrl?: string }): Tracer {\n const key = `${name}@${version || ''}:${options?.schemaUrl || ''}`;\n if (!this._tracers.has(key)) {\n this._tracers.set(key, new SentryCloudflareTracer());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._tracers.get(key)!;\n }\n}\n\nclass SentryCloudflareTracer implements Tracer {\n public startSpan(name: string, options?: SpanOptions): Span {\n return startInactiveSpan({\n ...options,\n name,\n attributes: {\n ...options?.attributes,\n 'sentry.cloudflare_tracer': true,\n },\n });\n }\n\n /**\n * NOTE: This does not handle `context` being passed in. It will always put spans on the current scope.\n */\n public startActiveSpan<F extends (span: Span) => unknown>(name: string, fn: F): ReturnType<F>;\n public startActiveSpan<F extends (span: Span) => unknown>(name: string, options: SpanOptions, fn: F): ReturnType<F>;\n public startActiveSpan<F extends (span: Span) => unknown>(\n name: string,\n options: SpanOptions,\n context: Context,\n fn: F,\n ): ReturnType<F>;\n public startActiveSpan<F extends (span: Span) => unknown>(\n name: string,\n options: unknown,\n context?: unknown,\n fn?: F,\n ): ReturnType<F> {\n const opts = (typeof options === 'object' && options !== null ? options : {}) as SpanOptions;\n\n const spanOpts = {\n ...opts,\n name,\n attributes: {\n ...opts.attributes,\n 'sentry.cloudflare_tracer': true,\n },\n };\n\n const callback = (\n typeof options === 'function'\n ? options\n : typeof context === 'function'\n ? context\n : typeof fn === 'function'\n ? fn\n : () => {}\n ) as F;\n\n // In OTEL the semantic matches `startSpanManual` because spans are not auto-ended\n return startSpanManual(spanOpts, callback) as ReturnType<F>;\n }\n}\n"],"names":[],"mappings":";;;AAQO,SAAS,wBAAA,GAAiC;AAC/C,EAAA,KAAA,CAAM,uBAAA,CAAwB,IAAI,6BAAA,EAA+B,CAAA;AACnE;AAEA,MAAM,6BAAA,CAAwD;AAAA,EAA9D,WAAA,GAAA;AACE,IAAA,IAAA,CAAiB,QAAA,uBAAoC,GAAA,EAAI;AAAA,EAAA;AAAA,EAElD,SAAA,CAAU,IAAA,EAAc,OAAA,EAAkB,OAAA,EAA0C;AACzF,IAAA,MAAM,GAAA,GAAM,GAAG,IAAI,CAAA,CAAA,EAAI,WAAW,EAAE,CAAA,CAAA,EAAI,OAAA,EAAS,SAAA,IAAa,EAAE,CAAA,CAAA;AAChE,IAAA,IAAI,CAAC,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAG,CAAA,EAAG;AAC3B,MAAA,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAA,EAAK,IAAI,wBAAwB,CAAA;AAAA,IACrD;AAGA,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAG,CAAA;AAAA,EAC9B;AACF;AAEA,MAAM,sBAAA,CAAyC;AAAA,EACtC,SAAA,CAAU,MAAc,OAAA,EAA6B;AAC1D,IAAA,OAAO,iBAAA,CAAkB;AAAA,MACvB,GAAG,OAAA;AAAA,MACH,IAAA;AAAA,MACA,UAAA,EAAY;AAAA,QACV,GAAG,OAAA,EAAS,UAAA;AAAA,QACZ,0BAAA,EAA4B;AAAA;AAC9B,KACD,CAAA;AAAA,EACH;AAAA,EAaO,eAAA,CACL,IAAA,EACA,OAAA,EACA,OAAA,EACA,EAAA,EACe;AACf,IAAA,MAAM,OAAQ,OAAO,OAAA,KAAY,YAAY,OAAA,KAAY,IAAA,GAAO,UAAU,EAAC;AAE3E,IAAA,MAAM,QAAA,GAAW;AAAA,MACf,GAAG,IAAA;AAAA,MACH,IAAA;AAAA,MACA,UAAA,EAAY;AAAA,QACV,GAAG,IAAA,CAAK,UAAA;AAAA,QACR,0BAAA,EAA4B;AAAA;AAC9B,KACF;AAEA,IAAA,MAAM,QAAA,GACJ,OAAO,OAAA,KAAY,UAAA,GACf,OAAA,GACA,OAAO,OAAA,KAAY,UAAA,GACjB,OAAA,GACA,OAAO,EAAA,KAAO,UAAA,GACZ,KACA,MAAM;AAAA,IAAC,CAAA;AAIjB,IAAA,OAAO,eAAA,CAAgB,UAAU,QAAQ,CAAA;AAAA,EAC3C;AACF;;;;"}
@@ -1,61 +1,25 @@
1
1
  import { envToBool } from '@sentry/core';
2
2
 
3
- /**
4
- * Cloudflare's version metadata binding structure.
5
- * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/version-metadata/
6
- */
7
-
8
- /**
9
- * Checks if the value is a valid CF_VERSION_METADATA binding.
10
- */
11
3
  function isVersionMetadata(value) {
12
- return typeof value === 'object' && value !== null && 'id' in value && typeof value.id === 'string';
4
+ return typeof value === "object" && value !== null && "id" in value && typeof value.id === "string";
13
5
  }
14
-
15
6
  function getEnvVar(env, varName) {
16
- return typeof env === 'object' && env !== null && varName in env && typeof (env )[varName] === 'string'
17
- ? ((env )[varName] )
18
- : undefined;
7
+ return typeof env === "object" && env !== null && varName in env && typeof env[varName] === "string" ? env[varName] : void 0;
19
8
  }
20
-
21
- /**
22
- * Merges the options passed in from the user with the options we read from
23
- * the Cloudflare `env` environment variable object.
24
- *
25
- * Release is determined with the following priority (highest to lowest):
26
- * 1. User-provided release option
27
- * 2. SENTRY_RELEASE environment variable
28
- * 3. CF_VERSION_METADATA.id binding (if configured in the wrangler config)
29
- *
30
- * @param userOptions - The options passed in from the user.
31
- * @param env - The environment variables.
32
- *
33
- * @returns The final options.
34
- */
35
9
  function getFinalOptions(userOptions = {}, env) {
36
- if (typeof env !== 'object' || env === null) {
10
+ if (typeof env !== "object" || env === null) {
37
11
  return userOptions;
38
12
  }
39
-
40
- // Priority: userOptions.release > SENTRY_RELEASE > CF_VERSION_METADATA.id
41
- const release =
42
- 'SENTRY_RELEASE' in env && typeof env.SENTRY_RELEASE === 'string'
43
- ? env.SENTRY_RELEASE
44
- : 'CF_VERSION_METADATA' in env && isVersionMetadata(env.CF_VERSION_METADATA)
45
- ? env.CF_VERSION_METADATA.id
46
- : undefined;
47
-
48
- const tracesSampleRate =
49
- userOptions.tracesSampleRate ?? parseFloat(getEnvVar(env, 'SENTRY_TRACES_SAMPLE_RATE') ?? '');
50
-
13
+ const release = "SENTRY_RELEASE" in env && typeof env.SENTRY_RELEASE === "string" ? env.SENTRY_RELEASE : "CF_VERSION_METADATA" in env && isVersionMetadata(env.CF_VERSION_METADATA) ? env.CF_VERSION_METADATA.id : void 0;
14
+ const tracesSampleRate = userOptions.tracesSampleRate ?? parseFloat(getEnvVar(env, "SENTRY_TRACES_SAMPLE_RATE") ?? "");
51
15
  return {
52
16
  release,
53
17
  ...userOptions,
54
- dsn: userOptions.dsn ?? getEnvVar(env, 'SENTRY_DSN'),
55
- environment: userOptions.environment ?? getEnvVar(env, 'SENTRY_ENVIRONMENT'),
56
- tracesSampleRate: isFinite(tracesSampleRate) ? tracesSampleRate : undefined,
57
- debug: userOptions.debug ?? envToBool(getEnvVar(env, 'SENTRY_DEBUG')),
58
- tunnel: userOptions.tunnel ?? getEnvVar(env, 'SENTRY_TUNNEL'),
18
+ dsn: userOptions.dsn ?? getEnvVar(env, "SENTRY_DSN"),
19
+ environment: userOptions.environment ?? getEnvVar(env, "SENTRY_ENVIRONMENT"),
20
+ tracesSampleRate: isFinite(tracesSampleRate) ? tracesSampleRate : void 0,
21
+ debug: userOptions.debug ?? envToBool(getEnvVar(env, "SENTRY_DEBUG")),
22
+ tunnel: userOptions.tunnel ?? getEnvVar(env, "SENTRY_TUNNEL")
59
23
  };
60
24
  }
61
25
 
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sources":["../../src/options.ts"],"sourcesContent":["import { envToBool } from '@sentry/core';\nimport type { CloudflareOptions } from './client';\n\n/**\n * Cloudflare's version metadata binding structure.\n * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/version-metadata/\n */\ninterface CfVersionMetadata {\n id: string;\n tag?: string;\n timestamp?: string;\n}\n\n/**\n * Checks if the value is a valid CF_VERSION_METADATA binding.\n */\nfunction isVersionMetadata(value: unknown): value is CfVersionMetadata {\n return typeof value === 'object' && value !== null && 'id' in value && typeof value.id === 'string';\n}\n\nfunction getEnvVar<T extends Record<string, unknown>>(env: unknown, varName: keyof T): string | undefined {\n return typeof env === 'object' && env !== null && varName in env && typeof (env as T)[varName] === 'string'\n ? ((env as T)[varName] as string)\n : undefined;\n}\n\n/**\n * Merges the options passed in from the user with the options we read from\n * the Cloudflare `env` environment variable object.\n *\n * Release is determined with the following priority (highest to lowest):\n * 1. User-provided release option\n * 2. SENTRY_RELEASE environment variable\n * 3. CF_VERSION_METADATA.id binding (if configured in the wrangler config)\n *\n * @param userOptions - The options passed in from the user.\n * @param env - The environment variables.\n *\n * @returns The final options.\n */\nexport function getFinalOptions(userOptions: CloudflareOptions = {}, env: unknown): CloudflareOptions {\n if (typeof env !== 'object' || env === null) {\n return userOptions;\n }\n\n // Priority: userOptions.release > SENTRY_RELEASE > CF_VERSION_METADATA.id\n const release =\n 'SENTRY_RELEASE' in env && typeof env.SENTRY_RELEASE === 'string'\n ? env.SENTRY_RELEASE\n : 'CF_VERSION_METADATA' in env && isVersionMetadata(env.CF_VERSION_METADATA)\n ? env.CF_VERSION_METADATA.id\n : undefined;\n\n const tracesSampleRate =\n userOptions.tracesSampleRate ?? parseFloat(getEnvVar(env, 'SENTRY_TRACES_SAMPLE_RATE') ?? '');\n\n return {\n release,\n ...userOptions,\n dsn: userOptions.dsn ?? getEnvVar(env, 'SENTRY_DSN'),\n environment: userOptions.environment ?? getEnvVar(env, 'SENTRY_ENVIRONMENT'),\n tracesSampleRate: isFinite(tracesSampleRate) ? tracesSampleRate : undefined,\n debug: userOptions.debug ?? envToBool(getEnvVar(env, 'SENTRY_DEBUG')),\n tunnel: userOptions.tunnel ?? getEnvVar(env, 'SENTRY_TUNNEL'),\n };\n}\n"],"names":[],"mappings":";;AAGA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,KAAK,EAAuC;AACvE,EAAE,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,UAAU,IAAA,IAAQ,IAAA,IAAQ,SAAS,OAAO,KAAK,CAAC,EAAA,KAAO,QAAQ;AACrG;;AAEA,SAAS,SAAS,CAAoC,GAAG,EAAW,OAAO,EAA+B;AAC1G,EAAE,OAAO,OAAO,GAAA,KAAQ,YAAY,GAAA,KAAQ,IAAA,IAAQ,WAAW,GAAA,IAAO,OAAO,CAAC,MAAU,OAAO,CAAA,KAAM;AACrG,OAAO,CAAC,MAAU,OAAO,CAAA;AACzB,MAAM,SAAS;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,WAAW,GAAsB,EAAE,EAAE,GAAG,EAA8B;AACtG,EAAE,IAAI,OAAO,GAAA,KAAQ,YAAY,GAAA,KAAQ,IAAI,EAAE;AAC/C,IAAI,OAAO,WAAW;AACtB,EAAE;;AAEF;AACA,EAAE,MAAM,OAAA;AACR,IAAI,gBAAA,IAAoB,GAAA,IAAO,OAAO,GAAG,CAAC,mBAAmB;AAC7D,QAAQ,GAAG,CAAC;AACZ,QAAQ,yBAAyB,GAAA,IAAO,iBAAiB,CAAC,GAAG,CAAC,mBAAmB;AACjF,UAAU,GAAG,CAAC,mBAAmB,CAAC;AAClC,UAAU,SAAS;;AAEnB,EAAE,MAAM,gBAAA;AACR,IAAI,WAAW,CAAC,gBAAA,IAAoB,UAAU,CAAC,SAAS,CAAC,GAAG,EAAE,2BAA2B,CAAA,IAAK,EAAE,CAAC;;AAEjG,EAAE,OAAO;AACT,IAAI,OAAO;AACX,IAAI,GAAG,WAAW;AAClB,IAAI,GAAG,EAAE,WAAW,CAAC,GAAA,IAAO,SAAS,CAAC,GAAG,EAAE,YAAY,CAAC;AACxD,IAAI,WAAW,EAAE,WAAW,CAAC,WAAA,IAAe,SAAS,CAAC,GAAG,EAAE,oBAAoB,CAAC;AAChF,IAAI,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,CAAA,GAAI,gBAAA,GAAmB,SAAS;AAC/E,IAAI,KAAK,EAAE,WAAW,CAAC,SAAS,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;AACzE,IAAI,MAAM,EAAE,WAAW,CAAC,MAAA,IAAU,SAAS,CAAC,GAAG,EAAE,eAAe,CAAC;AACjE,GAAG;AACH;;;;"}
1
+ {"version":3,"file":"options.js","sources":["../../src/options.ts"],"sourcesContent":["import { envToBool } from '@sentry/core';\nimport type { CloudflareOptions } from './client';\n\n/**\n * Cloudflare's version metadata binding structure.\n * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/version-metadata/\n */\ninterface CfVersionMetadata {\n id: string;\n tag?: string;\n timestamp?: string;\n}\n\n/**\n * Checks if the value is a valid CF_VERSION_METADATA binding.\n */\nfunction isVersionMetadata(value: unknown): value is CfVersionMetadata {\n return typeof value === 'object' && value !== null && 'id' in value && typeof value.id === 'string';\n}\n\nfunction getEnvVar<T extends Record<string, unknown>>(env: unknown, varName: keyof T): string | undefined {\n return typeof env === 'object' && env !== null && varName in env && typeof (env as T)[varName] === 'string'\n ? ((env as T)[varName] as string)\n : undefined;\n}\n\n/**\n * Merges the options passed in from the user with the options we read from\n * the Cloudflare `env` environment variable object.\n *\n * Release is determined with the following priority (highest to lowest):\n * 1. User-provided release option\n * 2. SENTRY_RELEASE environment variable\n * 3. CF_VERSION_METADATA.id binding (if configured in the wrangler config)\n *\n * @param userOptions - The options passed in from the user.\n * @param env - The environment variables.\n *\n * @returns The final options.\n */\nexport function getFinalOptions(userOptions: CloudflareOptions = {}, env: unknown): CloudflareOptions {\n if (typeof env !== 'object' || env === null) {\n return userOptions;\n }\n\n // Priority: userOptions.release > SENTRY_RELEASE > CF_VERSION_METADATA.id\n const release =\n 'SENTRY_RELEASE' in env && typeof env.SENTRY_RELEASE === 'string'\n ? env.SENTRY_RELEASE\n : 'CF_VERSION_METADATA' in env && isVersionMetadata(env.CF_VERSION_METADATA)\n ? env.CF_VERSION_METADATA.id\n : undefined;\n\n const tracesSampleRate =\n userOptions.tracesSampleRate ?? parseFloat(getEnvVar(env, 'SENTRY_TRACES_SAMPLE_RATE') ?? '');\n\n return {\n release,\n ...userOptions,\n dsn: userOptions.dsn ?? getEnvVar(env, 'SENTRY_DSN'),\n environment: userOptions.environment ?? getEnvVar(env, 'SENTRY_ENVIRONMENT'),\n tracesSampleRate: isFinite(tracesSampleRate) ? tracesSampleRate : undefined,\n debug: userOptions.debug ?? envToBool(getEnvVar(env, 'SENTRY_DEBUG')),\n tunnel: userOptions.tunnel ?? getEnvVar(env, 'SENTRY_TUNNEL'),\n };\n}\n"],"names":[],"mappings":";;AAgBA,SAAS,kBAAkB,KAAA,EAA4C;AACrE,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,IAAA,IAAQ,KAAA,IAAS,OAAO,KAAA,CAAM,EAAA,KAAO,QAAA;AAC7F;AAEA,SAAS,SAAA,CAA6C,KAAc,OAAA,EAAsC;AACxG,EAAA,OAAO,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,QAAQ,OAAA,IAAW,GAAA,IAAO,OAAQ,GAAA,CAAU,OAAO,CAAA,KAAM,QAAA,GAC7F,GAAA,CAAU,OAAO,CAAA,GACnB,MAAA;AACN;AAgBO,SAAS,eAAA,CAAgB,WAAA,GAAiC,EAAC,EAAG,GAAA,EAAiC;AACpG,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,IAAA,EAAM;AAC3C,IAAA,OAAO,WAAA;AAAA,EACT;AAGA,EAAA,MAAM,UACJ,gBAAA,IAAoB,GAAA,IAAO,OAAO,GAAA,CAAI,mBAAmB,QAAA,GACrD,GAAA,CAAI,cAAA,GACJ,qBAAA,IAAyB,OAAO,iBAAA,CAAkB,GAAA,CAAI,mBAAmB,CAAA,GACvE,GAAA,CAAI,oBAAoB,EAAA,GACxB,MAAA;AAER,EAAA,MAAM,gBAAA,GACJ,YAAY,gBAAA,IAAoB,UAAA,CAAW,UAAU,GAAA,EAAK,2BAA2B,KAAK,EAAE,CAAA;AAE9F,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,GAAG,WAAA;AAAA,IACH,GAAA,EAAK,WAAA,CAAY,GAAA,IAAO,SAAA,CAAU,KAAK,YAAY,CAAA;AAAA,IACnD,WAAA,EAAa,WAAA,CAAY,WAAA,IAAe,SAAA,CAAU,KAAK,oBAAoB,CAAA;AAAA,IAC3E,gBAAA,EAAkB,QAAA,CAAS,gBAAgB,CAAA,GAAI,gBAAA,GAAmB,MAAA;AAAA,IAClE,OAAO,WAAA,CAAY,KAAA,IAAS,UAAU,SAAA,CAAU,GAAA,EAAK,cAAc,CAAC,CAAA;AAAA,IACpE,MAAA,EAAQ,WAAA,CAAY,MAAA,IAAU,SAAA,CAAU,KAAK,eAAe;AAAA,GAC9D;AACF;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"10.53.0","sideEffects":false}
1
+ {"type":"module","version":"10.54.0","sideEffects":false}
@@ -1,49 +1,16 @@
1
1
  import { setAsyncLocalStorageAsyncContextStrategy } from './async.js';
2
2
  import { wrapRequestHandler } from './request.js';
3
3
 
4
- /**
5
- * Plugin middleware for Cloudflare Pages.
6
- *
7
- * Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.
8
- *
9
- * @example Simple usage
10
- *
11
- * ```javascript
12
- * // functions/_middleware.js
13
- * import * as Sentry from '@sentry/cloudflare';
14
- *
15
- * export const onRequest = Sentry.sentryPagesPlugin({
16
- * dsn: process.env.SENTRY_DSN,
17
- * tracesSampleRate: 1.0,
18
- * });
19
- * ```
20
- *
21
- * @example Usage with handler function to access context for environmental variables
22
- *
23
- * ```javascript
24
- * import * as Sentry from '@sentry/cloudflare';
25
- *
26
- * const const onRequest = Sentry.sentryPagesPlugin((context) => ({
27
- * dsn: context.env.SENTRY_DSN,
28
- * tracesSampleRate: 1.0,
29
- * })
30
- * ```
31
- *
32
- * @param handlerOrOptions Configuration options or a function that returns configuration options.
33
- * @returns A plugin function that can be used in Cloudflare Pages.
34
- */
35
- function sentryPagesPlugin
36
-
37
- (
38
- handlerOrOptions
39
-
40
- ,
41
- ) {
4
+ function sentryPagesPlugin(handlerOrOptions) {
42
5
  setAsyncLocalStorageAsyncContextStrategy();
43
- return context => {
44
- const options = typeof handlerOrOptions === 'function' ? handlerOrOptions(context) : handlerOrOptions;
45
- return wrapRequestHandler({ options, request: context.request, context: { ...context, props: {} } }, () =>
46
- context.next(),
6
+ return (context) => {
7
+ if (context.request.method === "OPTIONS" || context.request.method === "HEAD") {
8
+ return context.next();
9
+ }
10
+ const options = typeof handlerOrOptions === "function" ? handlerOrOptions(context) : handlerOrOptions;
11
+ return wrapRequestHandler(
12
+ { options, request: context.request, context: { ...context, props: {} } },
13
+ () => context.next()
47
14
  );
48
15
  };
49
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pages-plugin.js","sources":["../../src/pages-plugin.ts"],"sourcesContent":["import { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { wrapRequestHandler } from './request';\n\n/**\n * Plugin middleware for Cloudflare Pages.\n *\n * Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.\n *\n * @example Simple usage\n *\n * ```javascript\n * // functions/_middleware.js\n * import * as Sentry from '@sentry/cloudflare';\n *\n * export const onRequest = Sentry.sentryPagesPlugin({\n * dsn: process.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * });\n * ```\n *\n * @example Usage with handler function to access context for environmental variables\n *\n * ```javascript\n * import * as Sentry from '@sentry/cloudflare';\n *\n * const const onRequest = Sentry.sentryPagesPlugin((context) => ({\n * dsn: context.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * })\n * ```\n *\n * @param handlerOrOptions Configuration options or a function that returns configuration options.\n * @returns A plugin function that can be used in Cloudflare Pages.\n */\nexport function sentryPagesPlugin<\n Env = unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // Although it is not ideal to use `any` here, it makes usage more flexible for different setups.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(\n handlerOrOptions:\n | CloudflareOptions\n | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions),\n): PagesPluginFunction<Env, Params, Data, PluginParams> {\n setAsyncLocalStorageAsyncContextStrategy();\n return context => {\n const options = typeof handlerOrOptions === 'function' ? handlerOrOptions(context) : handlerOrOptions;\n return wrapRequestHandler({ options, request: context.request, context: { ...context, props: {} } }, () =>\n context.next(),\n );\n };\n}\n"],"names":[],"mappings":";;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS;;AAQhB;AACA,EAAE;;AAEE;AACJ,EAAwD;AACxD,EAAE,wCAAwC,EAAE;AAC5C,EAAE,OAAO,WAAW;AACpB,IAAI,MAAM,OAAA,GAAU,OAAO,gBAAA,KAAqB,UAAA,GAAa,gBAAgB,CAAC,OAAO,CAAA,GAAI,gBAAgB;AACzG,IAAI,OAAO,kBAAkB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,EAAC,EAAE,EAAG,EAAE;AACzG,MAAM,OAAO,CAAC,IAAI,EAAE;AACpB,KAAK;AACL,EAAE,CAAC;AACH;;;;"}
1
+ {"version":3,"file":"pages-plugin.js","sources":["../../src/pages-plugin.ts"],"sourcesContent":["import { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { wrapRequestHandler } from './request';\n\n/**\n * Plugin middleware for Cloudflare Pages.\n *\n * Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.\n *\n * @example Simple usage\n *\n * ```javascript\n * // functions/_middleware.js\n * import * as Sentry from '@sentry/cloudflare';\n *\n * export const onRequest = Sentry.sentryPagesPlugin({\n * dsn: process.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * });\n * ```\n *\n * @example Usage with handler function to access context for environmental variables\n *\n * ```javascript\n * import * as Sentry from '@sentry/cloudflare';\n *\n * const const onRequest = Sentry.sentryPagesPlugin((context) => ({\n * dsn: context.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * })\n * ```\n *\n * @param handlerOrOptions Configuration options or a function that returns configuration options.\n * @returns A plugin function that can be used in Cloudflare Pages.\n */\nexport function sentryPagesPlugin<\n Env = unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // Although it is not ideal to use `any` here, it makes usage more flexible for different setups.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(\n handlerOrOptions:\n | CloudflareOptions\n | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions),\n): PagesPluginFunction<Env, Params, Data, PluginParams> {\n setAsyncLocalStorageAsyncContextStrategy();\n return context => {\n if (context.request.method === 'OPTIONS' || context.request.method === 'HEAD') {\n return context.next();\n }\n\n const options = typeof handlerOrOptions === 'function' ? handlerOrOptions(context) : handlerOrOptions;\n return wrapRequestHandler({ options, request: context.request, context: { ...context, props: {} } }, () =>\n context.next(),\n );\n };\n}\n"],"names":[],"mappings":";;;AAmCO,SAAS,kBASd,gBAAA,EAGsD;AACtD,EAAA,wCAAA,EAAyC;AACzC,EAAA,OAAO,CAAA,OAAA,KAAW;AAChB,IAAA,IAAI,QAAQ,OAAA,CAAQ,MAAA,KAAW,aAAa,OAAA,CAAQ,OAAA,CAAQ,WAAW,MAAA,EAAQ;AAC7E,MAAA,OAAO,QAAQ,IAAA,EAAK;AAAA,IACtB;AAEA,IAAA,MAAM,UAAU,OAAO,gBAAA,KAAqB,UAAA,GAAa,gBAAA,CAAiB,OAAO,CAAA,GAAI,gBAAA;AACrF,IAAA,OAAO,kBAAA;AAAA,MAAmB,EAAE,OAAA,EAAS,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,OAAA,EAAS,EAAE,GAAG,OAAA,EAAS,KAAA,EAAO,EAAC,EAAE,EAAE;AAAA,MAAG,MACnG,QAAQ,IAAA;AAAK,KACf;AAAA,EACF,CAAA;AACF;;;;"}