@sentry/cloudflare 10.62.0 → 10.64.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 (51) hide show
  1. package/README.md +3 -7
  2. package/build/cjs/async.js.map +1 -1
  3. package/build/cjs/flush.js +15 -5
  4. package/build/cjs/flush.js.map +1 -1
  5. package/build/cjs/integrations/fetch.js.map +1 -1
  6. package/build/cjs/integrations/hono.js.map +1 -1
  7. package/build/cjs/integrations/httpServer.js.map +1 -1
  8. package/build/cjs/nodejs_compat/index.js +124 -0
  9. package/build/cjs/nodejs_compat/index.js.map +1 -0
  10. package/build/cjs/nodejs_compat/integrations/tracing/vercelai.js +18 -0
  11. package/build/cjs/nodejs_compat/integrations/tracing/vercelai.js.map +1 -0
  12. package/build/cjs/sdk.js +1 -5
  13. package/build/cjs/sdk.js.map +1 -1
  14. package/build/esm/async.js.map +1 -1
  15. package/build/esm/flush.js +16 -6
  16. package/build/esm/flush.js.map +1 -1
  17. package/build/esm/integrations/fetch.js.map +1 -1
  18. package/build/esm/integrations/hono.js.map +1 -1
  19. package/build/esm/integrations/httpServer.js.map +1 -1
  20. package/build/esm/nodejs_compat/index.js +16 -0
  21. package/build/esm/nodejs_compat/index.js.map +1 -0
  22. package/build/esm/nodejs_compat/integrations/tracing/vercelai.js +16 -0
  23. package/build/esm/nodejs_compat/integrations/tracing/vercelai.js.map +1 -0
  24. package/build/esm/package.json +1 -1
  25. package/build/esm/sdk.js +2 -6
  26. package/build/esm/sdk.js.map +1 -1
  27. package/build/types/async.d.ts +1 -1
  28. package/build/types/flush.d.ts +5 -0
  29. package/build/types/flush.d.ts.map +1 -1
  30. package/build/types/integrations/fetch.d.ts +3 -1
  31. package/build/types/integrations/fetch.d.ts.map +1 -1
  32. package/build/types/integrations/hono.d.ts +4 -2
  33. package/build/types/integrations/hono.d.ts.map +1 -1
  34. package/build/types/integrations/httpServer.d.ts +3 -1
  35. package/build/types/integrations/httpServer.d.ts.map +1 -1
  36. package/build/types/integrations/tracing/vercelai.d.ts +3 -1
  37. package/build/types/integrations/tracing/vercelai.d.ts.map +1 -1
  38. package/build/types/nodejs_compat/index.d.ts +4 -0
  39. package/build/types/nodejs_compat/index.d.ts.map +1 -0
  40. package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts +44 -0
  41. package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts.map +1 -0
  42. package/build/types/sdk.d.ts.map +1 -1
  43. package/build/types-ts3.8/async.d.ts +1 -1
  44. package/build/types-ts3.8/flush.d.ts +5 -0
  45. package/build/types-ts3.8/integrations/fetch.d.ts +3 -1
  46. package/build/types-ts3.8/integrations/hono.d.ts +4 -2
  47. package/build/types-ts3.8/integrations/httpServer.d.ts +3 -1
  48. package/build/types-ts3.8/integrations/tracing/vercelai.d.ts +3 -1
  49. package/build/types-ts3.8/nodejs_compat/index.d.ts +4 -0
  50. package/build/types-ts3.8/nodejs_compat/integrations/tracing/vercelai.d.ts +44 -0
  51. package/package.json +14 -2
package/README.md CHANGED
@@ -22,20 +22,16 @@ To get started, first install the `@sentry/cloudflare` package:
22
22
  npm install @sentry/cloudflare
23
23
  ```
24
24
 
25
- Then either set the `nodejs_als` or `nodejs_compat` compatibility flags in your `wrangler.jsonc`/`wrangler.toml` config. This is because the SDK needs access to the `AsyncLocalStorage` API to work correctly.
25
+ Then set the `nodejs_compat` compatibility flag in your `wrangler.jsonc`/`wrangler.toml` config. This is because the SDK needs access to Node.js compatibility APIs to work correctly.
26
26
 
27
27
  ```jsonc {tabTitle:JSON} {filename:wrangler.jsonc}
28
28
  {
29
- "compatibility_flags": [
30
- "nodejs_als",
31
- // "nodejs_compat"
32
- ],
29
+ "compatibility_flags": ["nodejs_compat"],
33
30
  }
34
31
  ```
35
32
 
36
33
  ```toml {tabTitle:Toml} {filename:wrangler.toml}
37
- compatibility_flags = ["nodejs_als"]
38
- # compatibility_flags = ["nodejs_compat"]
34
+ compatibility_flags = ["nodejs_compat"]
39
35
  ```
40
36
 
41
37
  ## Setup (Cloudflare Pages)
@@ -1 +1 @@
1
- {"version":3,"file":"async.js","sources":["../../src/async.ts"],"sourcesContent":["// Need to use node: prefix for cloudflare workers compatibility\n// Note: Because we are using node:async_hooks, we need to set `node_compat` in the wrangler.toml\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport type { Scope } from '@sentry/core';\nimport {\n _INTERNAL_createTracingChannelBinding,\n getDefaultCurrentScope,\n getDefaultIsolationScope,\n setAsyncContextStrategy,\n} from '@sentry/core';\n\n/**\n * Sets the async context strategy to use AsyncLocalStorage.\n *\n * AsyncLocalStorage is only available in the cloudflare workers runtime if you set\n * compatibility_flags = [\"nodejs_compat\"] or compatibility_flags = [\"nodejs_als\"]\n *\n * @internal Only exported to be used in higher-level Sentry packages\n * @hidden Only exported to be used in higher-level Sentry packages\n */\nexport function setAsyncLocalStorageAsyncContextStrategy(): void {\n const asyncStorage = new AsyncLocalStorage<{\n scope: Scope;\n isolationScope: Scope;\n }>();\n\n function getScopes(): { scope: Scope; isolationScope: Scope } {\n const scopes = asyncStorage.getStore();\n\n if (scopes) {\n return scopes;\n }\n\n // fallback behavior:\n // if, for whatever reason, we can't find scopes on the context here, we have to fix this somehow\n return {\n scope: getDefaultCurrentScope(),\n isolationScope: getDefaultIsolationScope(),\n };\n }\n\n function withScope<T>(callback: (scope: Scope) => T): T {\n const scope = getScopes().scope.clone();\n const isolationScope = getScopes().isolationScope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withSetScope<T>(scope: Scope, callback: (scope: Scope) => T): T {\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope;\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n function withSetIsolationScope<T>(isolationScope: Scope, callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n // In contrast to the browser, we can rely on async context isolation here\n function suppressTracing<T>(callback: () => T): T {\n return withScope(scope => {\n scope.setSDKProcessingMetadata({ __SENTRY_SUPPRESS_TRACING__: true });\n return callback();\n });\n }\n\n setAsyncContextStrategy({\n suppressTracing,\n withScope,\n withSetScope,\n withIsolationScope,\n withSetIsolationScope,\n getCurrentScope: () => getScopes().scope,\n getIsolationScope: () => getScopes().isolationScope,\n getTracingChannelBinding: () => _INTERNAL_createTracingChannelBinding(asyncStorage, getScopes),\n });\n}\n"],"names":["AsyncLocalStorage","getDefaultCurrentScope","getDefaultIsolationScope","setAsyncContextStrategy","_INTERNAL_createTracingChannelBinding"],"mappings":";;;;;AAoBO,SAAS,wCAAA,GAAiD;AAC/D,EAAA,MAAM,YAAA,GAAe,IAAIA,kCAAA,EAGtB;AAEH,EAAA,SAAS,SAAA,GAAqD;AAC5D,IAAA,MAAM,MAAA,GAAS,aAAa,QAAA,EAAS;AAErC,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,OAAO,MAAA;AAAA,IACT;AAIA,IAAA,OAAO;AAAA,MACL,OAAOC,2BAAA,EAAuB;AAAA,MAC9B,gBAAgBC,6BAAA;AAAyB,KAC3C;AAAA,EACF;AAEA,EAAA,SAAS,UAAa,QAAA,EAAkC;AACtD,IAAA,MAAM,KAAA,GAAQ,SAAA,EAAU,CAAE,KAAA,CAAM,KAAA,EAAM;AACtC,IAAA,MAAM,cAAA,GAAiB,WAAU,CAAE,cAAA;AACnC,IAAA,OAAO,aAAa,GAAA,CAAI,EAAE,KAAA,EAAO,cAAA,IAAkB,MAAM;AACvD,MAAA,OAAO,SAAS,KAAK,CAAA;AAAA,IACvB,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,SAAS,YAAA,CAAgB,OAAc,QAAA,EAAkC;AACvE,IAAA,MAAM,cAAA,G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,0CAAA,CAAsC,YAAA,EAAc,SAAS;AAAA,GAC9F,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"async.js","sources":["../../src/async.ts"],"sourcesContent":["// Need to use node: prefix for cloudflare workers compatibility\n// Note: Because we are using node:async_hooks, we need to set `node_compat` in the wrangler.toml\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport type { Scope } from '@sentry/core';\nimport {\n _INTERNAL_createTracingChannelBinding,\n getDefaultCurrentScope,\n getDefaultIsolationScope,\n setAsyncContextStrategy,\n} from '@sentry/core';\n\n/**\n * Sets the async context strategy to use AsyncLocalStorage.\n *\n * AsyncLocalStorage is only available in the cloudflare workers runtime if you set\n * compatibility_flags = [\"nodejs_compat\"]\n *\n * @internal Only exported to be used in higher-level Sentry packages\n * @hidden Only exported to be used in higher-level Sentry packages\n */\nexport function setAsyncLocalStorageAsyncContextStrategy(): void {\n const asyncStorage = new AsyncLocalStorage<{\n scope: Scope;\n isolationScope: Scope;\n }>();\n\n function getScopes(): { scope: Scope; isolationScope: Scope } {\n const scopes = asyncStorage.getStore();\n\n if (scopes) {\n return scopes;\n }\n\n // fallback behavior:\n // if, for whatever reason, we can't find scopes on the context here, we have to fix this somehow\n return {\n scope: getDefaultCurrentScope(),\n isolationScope: getDefaultIsolationScope(),\n };\n }\n\n function withScope<T>(callback: (scope: Scope) => T): T {\n const scope = getScopes().scope.clone();\n const isolationScope = getScopes().isolationScope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withSetScope<T>(scope: Scope, callback: (scope: Scope) => T): T {\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope;\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n function withSetIsolationScope<T>(isolationScope: Scope, callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n // In contrast to the browser, we can rely on async context isolation here\n function suppressTracing<T>(callback: () => T): T {\n return withScope(scope => {\n scope.setSDKProcessingMetadata({ __SENTRY_SUPPRESS_TRACING__: true });\n return callback();\n });\n }\n\n setAsyncContextStrategy({\n suppressTracing,\n withScope,\n withSetScope,\n withIsolationScope,\n withSetIsolationScope,\n getCurrentScope: () => getScopes().scope,\n getIsolationScope: () => getScopes().isolationScope,\n getTracingChannelBinding: () => _INTERNAL_createTracingChannelBinding(asyncStorage, getScopes),\n });\n}\n"],"names":["AsyncLocalStorage","getDefaultCurrentScope","getDefaultIsolationScope","setAsyncContextStrategy","_INTERNAL_createTracingChannelBinding"],"mappings":";;;;;AAoBO,SAAS,wCAAA,GAAiD;AAC/D,EAAA,MAAM,YAAA,GAAe,IAAIA,kCAAA,EAGtB;AAEH,EAAA,SAAS,SAAA,GAAqD;AAC5D,IAAA,MAAM,MAAA,GAAS,aAAa,QAAA,EAAS;AAErC,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,OAAO,MAAA;AAAA,IACT;AAIA,IAAA,OAAO;AAAA,MACL,OAAOC,2BAAA,EAAuB;AAAA,MAC9B,gBAAgBC,6BAAA;AAAyB,KAC3C;AAAA,EACF;AAEA,EAAA,SAAS,UAAa,QAAA,EAAkC;AACtD,IAAA,MAAM,KAAA,GAAQ,SAAA,EAAU,CAAE,KAAA,CAAM,KAAA,EAAM;AACtC,IAAA,MAAM,cAAA,GAAiB,WAAU,CAAE,cAAA;AACnC,IAAA,OAAO,aAAa,GAAA,CAAI,EAAE,KAAA,EAAO,cAAA,IAAkB,MAAM;AACvD,MAAA,OAAO,SAAS,KAAK,CAAA;AAAA,IACvB,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,SAAS,YAAA,CAAgB,OAAc,QAAA,EAAkC;AACvE,IAAA,MAAM,cAAA,GAAiB,SAA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AAsC,YAAA,EAAc,SAAS;AAAA,GAC9F,CAAA;AACH;;;;"}
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const core = require('@sentry/core');
4
+ const debugBuild = require('./debug-build.js');
4
5
 
5
6
  const flushLockRegistries = /* @__PURE__ */ new WeakMap();
6
7
  function getOriginalWaitUntil(context) {
@@ -63,12 +64,21 @@ function getOrCreateFlushLockRegistry(context) {
63
64
  return registry;
64
65
  }
65
66
  async function flushAndDispose(client, timeout = 2e3) {
66
- if (!client) {
67
- await core.flush(timeout);
68
- return;
67
+ try {
68
+ if (!client) {
69
+ await core.flush(timeout);
70
+ return;
71
+ }
72
+ await client.flush(timeout);
73
+ } catch (e) {
74
+ debugBuild.DEBUG_BUILD && core.debug.warn("Failed to flush client", e);
75
+ } finally {
76
+ try {
77
+ client?.dispose();
78
+ } catch (e) {
79
+ debugBuild.DEBUG_BUILD && core.debug.warn("Failed to dispose client", e);
80
+ }
69
81
  }
70
- await client.flush(timeout);
71
- client.dispose();
72
82
  }
73
83
 
74
84
  exports.flushAndDispose = flushAndDispose;
@@ -1 +1 @@
1
- {"version":3,"file":"flush.js","sources":["../../src/flush.ts"],"sourcesContent":["import type { ExecutionContext } from '@cloudflare/workers-types';\nimport type { Client } from '@sentry/core';\nimport { flush } from '@sentry/core';\n\ntype FlushLock = {\n readonly ready: Promise<void>;\n readonly finalize: () => Promise<void>;\n};\n\ntype FlushLockRegistry = {\n readonly locks: Set<FlushLockInternal>;\n readonly originalWaitUntil: ExecutionContext['waitUntil'];\n};\n\ntype FlushLockInternal = FlushLock & {\n readonly acquire: () => void;\n readonly release: () => void;\n};\n\nconst flushLockRegistries = new WeakMap<ExecutionContext['waitUntil'], FlushLockRegistry>();\n\n/**\n * Returns the original (un-instrumented) waitUntil function for a context.\n * This should be used when calling waitUntil with flushAndDispose to avoid deadlock.\n *\n * The flush lock mechanism wraps context.waitUntil to track pending tasks.\n * If we call waitUntil(flushAndDispose(client)) through the instrumented version,\n * it creates a deadlock because:\n * 1. The instrumented waitUntil acquires the flush lock\n * 2. flushAndDispose calls client.flush() which waits for the lock to be released\n * 3. The lock won't be released until the waitUntil promise completes\n * 4. The waitUntil promise won't complete until flush() returns\n *\n * By using the original waitUntil for flush operations, we bypass this issue.\n */\nexport function getOriginalWaitUntil(context: ExecutionContext): ExecutionContext['waitUntil'] | undefined {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const currentWaitUntil = context.waitUntil;\n const original = flushLockRegistries.get(currentWaitUntil)?.originalWaitUntil;\n return original ?? currentWaitUntil;\n}\n\n/**\n * Enhances the given execution context by wrapping its `waitUntil` method with a proxy\n * to monitor pending tasks, and provides a flusher function to ensure all tasks\n * have been completed before executing any subsequent logic.\n *\n * @param {ExecutionContext} context - The execution context to be enhanced. If no context is provided, the function returns undefined.\n * @return {FlushLock} Returns a flusher function if a valid context is provided, otherwise undefined.\n */\nexport function makeFlushLock(context: ExecutionContext): FlushLock {\n const registry = getOrCreateFlushLockRegistry(context);\n let resolveAllDone: () => void = () => undefined;\n const allDone = new Promise<void>(res => {\n resolveAllDone = res;\n });\n let pending = 0;\n\n const lock: FlushLockInternal = {\n ready: allDone,\n acquire: () => {\n pending++;\n },\n release: () => {\n if (--pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n },\n finalize: () => {\n if (pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n return allDone;\n },\n };\n\n registry.locks.add(lock);\n return Object.freeze(lock);\n}\n\nfunction getOrCreateFlushLockRegistry(context: ExecutionContext): FlushLockRegistry {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const waitUntil = context.waitUntil;\n const existingRegistry = flushLockRegistries.get(waitUntil);\n\n if (existingRegistry) {\n return existingRegistry;\n }\n\n const originalWaitUntil = context.waitUntil.bind(context) as typeof context.waitUntil;\n const registry: FlushLockRegistry = { locks: new Set(), originalWaitUntil };\n const instrumentedWaitUntil: typeof context.waitUntil = promise => {\n // Snapshot active locks so locks created after this call do not wait for earlier waitUntil work.\n const locks = [...registry.locks];\n\n for (const lock of locks) {\n lock.acquire();\n }\n\n return originalWaitUntil(\n promise.finally(() => {\n for (const lock of locks) {\n lock.release();\n }\n }),\n );\n };\n\n flushLockRegistries.set(instrumentedWaitUntil, registry);\n context.waitUntil = instrumentedWaitUntil;\n\n return registry;\n}\n\n/**\n * Flushes the client and then disposes of it to allow garbage collection.\n * This should be called at the end of each request to prevent memory leaks.\n *\n * @param client - The CloudflareClient instance to flush and dispose\n * @param timeout - Timeout in milliseconds for the flush operation\n * @returns A promise that resolves when flush and dispose are complete\n */\nexport async function flushAndDispose(client: Client | undefined, timeout = 2000): Promise<void> {\n if (!client) {\n await flush(timeout);\n\n return;\n }\n\n await client.flush(timeout);\n client.dispose();\n}\n"],"names":["flush"],"mappings":";;;;AAmBA,MAAM,mBAAA,uBAA0B,OAAA,EAA0D;AAgBnF,SAAS,qBAAqB,OAAA,EAAsE;AAEzG,EAAA,MAAM,mBAAmB,OAAA,CAAQ,SAAA;AACjC,EAAA,MAAM,QAAA,GAAW,mBAAA,CAAoB,GAAA,CAAI,gBAAgB,CAAA,EAAG,iBAAA;AAC5D,EAAA,OAAO,QAAA,IAAY,gBAAA;AACrB;AAUO,SAAS,cAAc,OAAA,EAAsC;AAClE,EAAA,MAAM,QAAA,GAAW,6BAA6B,OAAO,CAAA;AACrD,EAAA,IAAI,iBAA6B,MAAM,MAAA;AACvC,EAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAc,CAAA,GAAA,KAAO;AACvC,IAAA,cAAA,GAAiB,GAAA;AAAA,EACnB,CAAC,CAAA;AACD,EAAA,IAAI,OAAA,GAAU,CAAA;AAEd,EAAA,MAAM,IAAA,GAA0B;AAAA,IAC9B,KAAA,EAAO,OAAA;AAAA,IACP,SAAS,MAAM;AACb,MAAA,OAAA,EAAA;AAAA,IACF,CAAA;AAAA,IACA,SAAS,MAAM;AACb,MAAA,IAAI,E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AAA,CAAoB,GAAA,CAAI,uBAAuB,QAAQ,CAAA;AACvD,EAAA,OAAA,CAAQ,SAAA,GAAY,qBAAA;AAEpB,EAAA,OAAO,QAAA;AACT;AAUA,eAAsB,eAAA,CAAgB,MAAA,EAA4B,OAAA,GAAU,GAAA,EAAqB;AAC/F,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAMA,WAAM,OAAO,CAAA;AAEnB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,MAAA,CAAO,MAAM,OAAO,CAAA;AAC1B,EAAA,MAAA,CAAO,OAAA,EAAQ;AACjB;;;;;;"}
1
+ {"version":3,"file":"flush.js","sources":["../../src/flush.ts"],"sourcesContent":["import type { ExecutionContext } from '@cloudflare/workers-types';\nimport type { Client } from '@sentry/core';\nimport { debug, flush } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\n\ntype FlushLock = {\n readonly ready: Promise<void>;\n readonly finalize: () => Promise<void>;\n};\n\ntype FlushLockRegistry = {\n readonly locks: Set<FlushLockInternal>;\n readonly originalWaitUntil: ExecutionContext['waitUntil'];\n};\n\ntype FlushLockInternal = FlushLock & {\n readonly acquire: () => void;\n readonly release: () => void;\n};\n\nconst flushLockRegistries = new WeakMap<ExecutionContext['waitUntil'], FlushLockRegistry>();\n\n/**\n * Returns the original (un-instrumented) waitUntil function for a context.\n * This should be used when calling waitUntil with flushAndDispose to avoid deadlock.\n *\n * The flush lock mechanism wraps context.waitUntil to track pending tasks.\n * If we call waitUntil(flushAndDispose(client)) through the instrumented version,\n * it creates a deadlock because:\n * 1. The instrumented waitUntil acquires the flush lock\n * 2. flushAndDispose calls client.flush() which waits for the lock to be released\n * 3. The lock won't be released until the waitUntil promise completes\n * 4. The waitUntil promise won't complete until flush() returns\n *\n * By using the original waitUntil for flush operations, we bypass this issue.\n */\nexport function getOriginalWaitUntil(context: ExecutionContext): ExecutionContext['waitUntil'] | undefined {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const currentWaitUntil = context.waitUntil;\n const original = flushLockRegistries.get(currentWaitUntil)?.originalWaitUntil;\n return original ?? currentWaitUntil;\n}\n\n/**\n * Enhances the given execution context by wrapping its `waitUntil` method with a proxy\n * to monitor pending tasks, and provides a flusher function to ensure all tasks\n * have been completed before executing any subsequent logic.\n *\n * @param {ExecutionContext} context - The execution context to be enhanced. If no context is provided, the function returns undefined.\n * @return {FlushLock} Returns a flusher function if a valid context is provided, otherwise undefined.\n */\nexport function makeFlushLock(context: ExecutionContext): FlushLock {\n const registry = getOrCreateFlushLockRegistry(context);\n let resolveAllDone: () => void = () => undefined;\n const allDone = new Promise<void>(res => {\n resolveAllDone = res;\n });\n let pending = 0;\n\n const lock: FlushLockInternal = {\n ready: allDone,\n acquire: () => {\n pending++;\n },\n release: () => {\n if (--pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n },\n finalize: () => {\n if (pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n return allDone;\n },\n };\n\n registry.locks.add(lock);\n return Object.freeze(lock);\n}\n\nfunction getOrCreateFlushLockRegistry(context: ExecutionContext): FlushLockRegistry {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const waitUntil = context.waitUntil;\n const existingRegistry = flushLockRegistries.get(waitUntil);\n\n if (existingRegistry) {\n return existingRegistry;\n }\n\n const originalWaitUntil = context.waitUntil.bind(context) as typeof context.waitUntil;\n const registry: FlushLockRegistry = { locks: new Set(), originalWaitUntil };\n const instrumentedWaitUntil: typeof context.waitUntil = promise => {\n // Snapshot active locks so locks created after this call do not wait for earlier waitUntil work.\n const locks = [...registry.locks];\n\n for (const lock of locks) {\n lock.acquire();\n }\n\n return originalWaitUntil(\n promise.finally(() => {\n for (const lock of locks) {\n lock.release();\n }\n }),\n );\n };\n\n flushLockRegistries.set(instrumentedWaitUntil, registry);\n context.waitUntil = instrumentedWaitUntil;\n\n return registry;\n}\n\n/**\n * Flushes the client and then disposes of it to allow garbage collection.\n * This should be called at the end of each request to prevent memory leaks.\n *\n * This function never rejects. On Workers, a rejected promise passed to\n * `ctx.waitUntil` marks the whole invocation as `outcome: exception` even when\n * the handler itself completed successfully. Since flush/dispose is internal\n * SDK housekeeping, a failure here must not fail the user's invocation.\n *\n * @param client - The CloudflareClient instance to flush and dispose\n * @param timeout - Timeout in milliseconds for the flush operation\n * @returns A promise that resolves when flush and dispose are complete\n */\nexport async function flushAndDispose(client: Client | undefined, timeout = 2000): Promise<void> {\n try {\n if (!client) {\n await flush(timeout);\n return;\n }\n await client.flush(timeout);\n } catch (e) {\n DEBUG_BUILD && debug.warn('Failed to flush client', e);\n } finally {\n try {\n client?.dispose();\n } catch (e) {\n DEBUG_BUILD && debug.warn('Failed to dispose client', e);\n }\n }\n}\n"],"names":["flush","DEBUG_BUILD","debug"],"mappings":";;;;;AAoBA,MAAM,mBAAA,uBAA0B,OAAA,EAA0D;AAgBnF,SAAS,qBAAqB,OAAA,EAAsE;AAEzG,EAAA,MAAM,mBAAmB,OAAA,CAAQ,SAAA;AACjC,EAAA,MAAM,QAAA,GAAW,mBAAA,CAAoB,GAAA,CAAI,gBAAgB,CAAA,EAAG,iBAAA;AAC5D,EAAA,OAAO,QAAA,IAAY,gBAAA;AACrB;AAUO,SAAS,cAAc,OAAA,EAAsC;AAClE,EAAA,MAAM,QAAA,GAAW,6BAA6B,OAAO,CAAA;AACrD,EAAA,IAAI,iBAA6B,MAAM,MAAA;AACvC,EAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAc,CAAA,GAAA,KAAO;AACvC,IAAA,cAAA,GAAiB,GAAA;AAAA,EACnB,CAAC,CAAA;AACD,EAAA,IAAI,OAAA,GAAU,CAAA;AAEd,EAAA,MAAM,IAAA,GAA0B;AAAA,IAC9B,KAAA,EAAO,OAAA;AAAA,IACP,SAAS,MAAM;AACb,MAAA,OAAA,EAAA;AAAA,IACF,CAAA;AAAA,IACA,SAAS,MAAM;AACb,MAAA,IAAI,EAAE,YAAY,CAAA,EAAG;AACnB,QAAA,QAA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,CAAA;AACvD,EAAA,OAAA,CAAQ,SAAA,GAAY,qBAAA;AAEpB,EAAA,OAAO,QAAA;AACT;AAeA,eAAsB,eAAA,CAAgB,MAAA,EAA4B,OAAA,GAAU,GAAA,EAAqB;AAC/F,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAMA,WAAM,OAAO,CAAA;AACnB,MAAA;AAAA,IACF;AACA,IAAA,MAAM,MAAA,CAAO,MAAM,OAAO,CAAA;AAAA,EAC5B,SAAS,CAAA,EAAG;AACV,IAAAC,sBAAA,IAAeC,UAAA,CAAM,IAAA,CAAK,wBAAA,EAA0B,CAAC,CAAA;AAAA,EACvD,CAAA,SAAE;AACA,IAAA,IAAI;AACF,MAAA,MAAA,EAAQ,OAAA,EAAQ;AAAA,IAClB,SAAS,CAAA,EAAG;AACV,MAAAD,sBAAA,IAAeC,UAAA,CAAM,IAAA,CAAK,0BAAA,EAA4B,CAAC,CAAA;AAAA,IACzD;AAAA,EACF;AACF;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sources":["../../../src/integrations/fetch.ts"],"sourcesContent":["import type {\n Client,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataFetch,\n IntegrationFn,\n Span,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addFetchInstrumentationHandler,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n instrumentFetchRequest,\n isSentryRequestUrl,\n LRUMap,\n stringMatchesSomePattern,\n} from '@sentry/core';\n\nconst INTEGRATION_NAME = 'Fetch';\n\nconst HAS_CLIENT_MAP = new WeakMap<Client, boolean>();\n\nexport interface Options {\n /**\n * Whether breadcrumbs should be recorded for requests\n * Defaults to true\n */\n breadcrumbs: boolean;\n\n /**\n * Function determining whether or not to create spans to track outgoing requests to the given URL.\n * By default, spans will be created for all outgoing requests.\n */\n shouldCreateSpanForRequest?: (url: string) => boolean;\n}\n\nconst _fetchIntegration = ((options: Partial<Options> = {}) => {\n const breadcrumbs = options.breadcrumbs === undefined ? true : options.breadcrumbs;\n const shouldCreateSpanForRequest = options.shouldCreateSpanForRequest;\n\n const _createSpanUrlMap = new LRUMap<string, boolean>(100);\n const _headersUrlMap = new LRUMap<string, boolean>(100);\n\n const spans: Record<string, Span> = {};\n\n /** Decides whether to attach trace data to the outgoing fetch request */\n function _shouldAttachTraceData(url: string): boolean {\n const client = getClient();\n\n if (!client) {\n return false;\n }\n\n const clientOptions = client.getOptions();\n\n if (clientOptions.tracePropagationTargets === undefined) {\n return true;\n }\n\n const cachedDecision = _headersUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = stringMatchesSomePattern(url, clientOptions.tracePropagationTargets);\n _headersUrlMap.set(url, decision);\n return decision;\n }\n\n /** Helper that wraps shouldCreateSpanForRequest option */\n function _shouldCreateSpan(url: string): boolean {\n if (shouldCreateSpanForRequest === undefined) {\n return true;\n }\n\n const cachedDecision = _createSpanUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = shouldCreateSpanForRequest(url);\n _createSpanUrlMap.set(url, decision);\n return decision;\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n addFetchInstrumentationHandler(handlerData => {\n const client = getClient();\n const { propagateTraceparent } = client?.getOptions() || {};\n if (!client || !HAS_CLIENT_MAP.get(client)) {\n return;\n }\n\n if (isSentryRequestUrl(handlerData.fetchData.url, client)) {\n return;\n }\n\n instrumentFetchRequest(handlerData, _shouldCreateSpan, _shouldAttachTraceData, spans, {\n spanOrigin: 'auto.http.fetch',\n propagateTraceparent,\n });\n\n if (breadcrumbs) {\n createBreadcrumb(handlerData);\n }\n }, true);\n },\n setup(client) {\n HAS_CLIENT_MAP.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Creates spans and attaches tracing headers to fetch requests.\n */\nexport const fetchIntegration = defineIntegration(_fetchIntegration);\n\nfunction createBreadcrumb(handlerData: HandlerDataFetch): void {\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n const breadcrumbData: FetchBreadcrumbData = {\n method: handlerData.fetchData.method,\n url: handlerData.fetchData.url,\n };\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n level: 'error',\n type: 'http',\n },\n hint,\n );\n } else {\n const response = handlerData.response as Response | undefined;\n\n breadcrumbData.request_body_size = handlerData.fetchData.request_body_size;\n breadcrumbData.response_body_size = handlerData.fetchData.response_body_size;\n breadcrumbData.status_code = response?.status;\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n const level = getBreadcrumbLogLevelFromHttpStatusCode(breadcrumbData.status_code);\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n type: 'http',\n level,\n },\n hint,\n );\n }\n}\n"],"names":["LRUMap","getClient","stringMatchesSomePattern","addFetchInstrumentationHandler","isSentryRequestUrl","instrumentFetchRequest","defineIntegration","addBreadcrumb","getBreadcrumbLogLevelFromHttpStatusCode"],"mappings":";;;;AAoBA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,cAAA,uBAAqB,OAAA,EAAyB;AAgBpD,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAA4B,EAAC,KAAM;AAC7D,EAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,WAAA,KAAgB,MAAA,GAAY,OAAO,OAAA,CAAQ,WAAA;AACvE,EAAA,MAAM,6BAA6B,OAAA,CAAQ,0BAAA;AAE3C,EAAA,MAAM,iBAAA,GAAoB,IAAIA,WAAA,CAAwB,GAAG,CAAA;AACzD,EAAA,MAAM,cAAA,GAAiB,IAAIA,WAAA,CAAwB,GAAG,CAAA;AAEtD,EAAA,M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,cAAA;AAAA,QACN,KAAA,EAAO,OAAA;AAAA,QACP,IAAA,EAAM;AAAA,OACR;AAAA,MACA;AAAA,KACF;AAAA,EACF,CAAA,MAAO;AACL,IAAA,MAAM,WAAW,WAAA,CAAY,QAAA;AAE7B,IAAA,cAAA,CAAe,iBAAA,GAAoB,YAAY,SAAA,CAAU,iBAAA;AACzD,IAAA,cAAA,CAAe,kBAAA,GAAqB,YAAY,SAAA,CAAU,kBAAA;AAC1D,IAAA,cAAA,CAAe,cAAc,QAAA,EAAU,MAAA;AAEvC,IAAA,MAAM,IAAA,GAA4B;AAAA,MAChC,OAAO,WAAA,CAAY,IAAA;AAAA,MACnB,QAAA;AAAA,MACA,cAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAM,KAAA,GAAQC,4CAAA,CAAwC,cAAA,CAAe,WAAW,CAAA;AAEhF,IAAAD,kBAAA;AAAA,MACE;AAAA,QACE,QAAA,EAAU,OAAA;AAAA,QACV,IAAA,EAAM,cAAA;AAAA,QACN,IAAA,EAAM,MAAA;AAAA,QACN;AAAA,OACF;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"fetch.js","sources":["../../../src/integrations/fetch.ts"],"sourcesContent":["import type {\n Client,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataFetch,\n IntegrationFn,\n Span,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addFetchInstrumentationHandler,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n instrumentFetchRequest,\n isSentryRequestUrl,\n LRUMap,\n stringMatchesSomePattern,\n} from '@sentry/core';\n\nconst INTEGRATION_NAME = 'Fetch' as const;\n\nconst HAS_CLIENT_MAP = new WeakMap<Client, boolean>();\n\nexport interface Options {\n /**\n * Whether breadcrumbs should be recorded for requests\n * Defaults to true\n */\n breadcrumbs: boolean;\n\n /**\n * Function determining whether or not to create spans to track outgoing requests to the given URL.\n * By default, spans will be created for all outgoing requests.\n */\n shouldCreateSpanForRequest?: (url: string) => boolean;\n}\n\nconst _fetchIntegration = ((options: Partial<Options> = {}) => {\n const breadcrumbs = options.breadcrumbs === undefined ? true : options.breadcrumbs;\n const shouldCreateSpanForRequest = options.shouldCreateSpanForRequest;\n\n const _createSpanUrlMap = new LRUMap<string, boolean>(100);\n const _headersUrlMap = new LRUMap<string, boolean>(100);\n\n const spans: Record<string, Span> = {};\n\n /** Decides whether to attach trace data to the outgoing fetch request */\n function _shouldAttachTraceData(url: string): boolean {\n const client = getClient();\n\n if (!client) {\n return false;\n }\n\n const clientOptions = client.getOptions();\n\n if (clientOptions.tracePropagationTargets === undefined) {\n return true;\n }\n\n const cachedDecision = _headersUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = stringMatchesSomePattern(url, clientOptions.tracePropagationTargets);\n _headersUrlMap.set(url, decision);\n return decision;\n }\n\n /** Helper that wraps shouldCreateSpanForRequest option */\n function _shouldCreateSpan(url: string): boolean {\n if (shouldCreateSpanForRequest === undefined) {\n return true;\n }\n\n const cachedDecision = _createSpanUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = shouldCreateSpanForRequest(url);\n _createSpanUrlMap.set(url, decision);\n return decision;\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n addFetchInstrumentationHandler(handlerData => {\n const client = getClient();\n const { propagateTraceparent } = client?.getOptions() || {};\n if (!client || !HAS_CLIENT_MAP.get(client)) {\n return;\n }\n\n if (isSentryRequestUrl(handlerData.fetchData.url, client)) {\n return;\n }\n\n instrumentFetchRequest(handlerData, _shouldCreateSpan, _shouldAttachTraceData, spans, {\n spanOrigin: 'auto.http.fetch',\n propagateTraceparent,\n });\n\n if (breadcrumbs) {\n createBreadcrumb(handlerData);\n }\n }, true);\n },\n setup(client) {\n HAS_CLIENT_MAP.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Creates spans and attaches tracing headers to fetch requests.\n */\nexport const fetchIntegration = defineIntegration(_fetchIntegration);\n\nfunction createBreadcrumb(handlerData: HandlerDataFetch): void {\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n const breadcrumbData: FetchBreadcrumbData = {\n method: handlerData.fetchData.method,\n url: handlerData.fetchData.url,\n };\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n level: 'error',\n type: 'http',\n },\n hint,\n );\n } else {\n const response = handlerData.response as Response | undefined;\n\n breadcrumbData.request_body_size = handlerData.fetchData.request_body_size;\n breadcrumbData.response_body_size = handlerData.fetchData.response_body_size;\n breadcrumbData.status_code = response?.status;\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n const level = getBreadcrumbLogLevelFromHttpStatusCode(breadcrumbData.status_code);\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n type: 'http',\n level,\n },\n hint,\n );\n }\n}\n"],"names":["LRUMap","getClient","stringMatchesSomePattern","addFetchInstrumentationHandler","isSentryRequestUrl","instrumentFetchRequest","defineIntegration","addBreadcrumb","getBreadcrumbLogLevelFromHttpStatusCode"],"mappings":";;;;AAoBA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,cAAA,uBAAqB,OAAA,EAAyB;AAgBpD,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAA4B,EAAC,KAAM;AAC7D,EAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,WAAA,KAAgB,MAAA,GAAY,OAAO,OAAA,CAAQ,WAAA;AACvE,EAAA,MAAM,6BAA6B,OAAA,CAAQ,0BAAA;AAE3C,EAAA,MAAM,iBAAA,GAAoB,IAAIA,WAAA,CAAwB,GAAG,CAAA;AACzD,EAAA,MA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A;AAAA,MACE;AAAA,QACE,QAAA,EAAU,OAAA;AAAA,QACV,IAAA,EAAM,cAAA;AAAA,QACN,KAAA,EAAO,OAAA;AAAA,QACP,IAAA,EAAM;AAAA,OACR;AAAA,MACA;AAAA,KACF;AAAA,EACF,CAAA,MAAO;AACL,IAAA,MAAM,WAAW,WAAA,CAAY,QAAA;AAE7B,IAAA,cAAA,CAAe,iBAAA,GAAoB,YAAY,SAAA,CAAU,iBAAA;AACzD,IAAA,cAAA,CAAe,kBAAA,GAAqB,YAAY,SAAA,CAAU,kBAAA;AAC1D,IAAA,cAAA,CAAe,cAAc,QAAA,EAAU,MAAA;AAEvC,IAAA,MAAM,IAAA,GAA4B;AAAA,MAChC,OAAO,WAAA,CAAY,IAAA;AAAA,MACnB,QAAA;AAAA,MACA,cAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAM,KAAA,GAAQC,4CAAA,CAAwC,cAAA,CAAe,WAAW,CAAA;AAEhF,IAAAD,kBAAA;AAAA,MACE;AAAA,QACE,QAAA,EAAU,OAAA;AAAA,QACV,IAAA,EAAM,cAAA;AAAA,QACN,IAAA,EAAM,MAAA;AAAA,QACN;AAAA,OACF;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF;;;;"}
@@ -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 * @deprecated Use the `@sentry/hono` package instead. The `sentry()` middleware from `@sentry/hono/cloudflare`\n * handles error capturing automatically without needing this integration.\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":["getClient","DEBUG_BUILD","debug","getActiveSpan","updateSpanName","getRootSpan","getIsolationScope","captureException","defineIntegration"],"mappings":";;;;;AAaA,MAAM,gBAAA,GAAmB,MAAA;AAoBlB,SAAS,kBAAA,GAAsE;AACpF,EAAA,OAAOA,cAAA,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,QAAAC,sBAAA,IAAeC,UAAA,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,aAAaC,kBAAA,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,YAAAC,mBAAA,CAAeC,gBAAA,CAAY,UAAU,CAAA,EAAG,QAAQ,CAAA;AAAA,UAClD;AAEA,UAAAC,sBAAA,EAAkB,CAAE,mBAAmB,QAAQ,CAAA;AAAA,QACjD;AAEA,QAAAC,qBAAA,CAAiB,GAAA,EAAK,EAAE,SAAA,EAAW,EAAE,SAAS,KAAA,EAAO,IAAA,EAAM,8BAAA,EAA+B,EAAG,CAAA;AAAA,MAC/F,CAAA,MAAO;AACL,QAAAN,sBAAA,IAAeC,UAAA,CAAM,GAAA,CAAI,8EAAA,EAAgF,GAAG,CAAA;AAAA,MAC9G;AAAA,IACF;AAAA,GACF;AACF,CAAA,CAAA;AAiBO,MAAM,eAAA,GAAkBM,uBAAkB,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
+ {"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' as const;\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 * @deprecated Use the `@sentry/hono` package instead. The `sentry()` middleware from `@sentry/hono/cloudflare`\n * handles error capturing automatically without needing this integration.\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":["getClient","DEBUG_BUILD","debug","getActiveSpan","updateSpanName","getRootSpan","getIsolationScope","captureException","defineIntegration"],"mappings":";;;;;AAaA,MAAM,gBAAA,GAAmB,MAAA;AAoBlB,SAAS,kBAAA,GAAsE;AACpF,EAAA,OAAOA,cAAA,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,QAAAC,sBAAA,IAAeC,UAAA,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,aAAaC,kBAAA,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,YAAAC,mBAAA,CAAeC,gBAAA,CAAY,UAAU,CAAA,EAAG,QAAQ,CAAA;AAAA,UAClD;AAEA,UAAAC,sBAAA,EAAkB,CAAE,mBAAmB,QAAQ,CAAA;AAAA,QACjD;AAEA,QAAAC,qBAAA,CAAiB,GAAA,EAAK,EAAE,SAAA,EAAW,EAAE,SAAS,KAAA,EAAO,IAAA,EAAM,8BAAA,EAA+B,EAAG,CAAA;AAAA,MAC/F,CAAA,MAAO;AACL,QAAAN,sBAAA,IAAeC,UAAA,CAAM,GAAA,CAAI,8EAAA,EAAgF,GAAG,CAAA;AAAA,MAC9G;AAAA,IACF;AAAA,GACF;AACF,CAAA,CAAA;AAiBO,MAAM,eAAA,GAAkBM,uBAAkB,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 +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 // TODO(v11): Gate incoming request body capture on `dataCollection.httpBodies` (capture only when\n // `'incomingRequest'` is listed) instead of defaulting to `'medium'`.\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":["defineIntegration","getIsolationScope","captureBodyFromWinterCGRequest"],"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,GAAwBA,uBAAkB,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;AAIA,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,iBAAiBC,sBAAA,EAAkB;AACzC,EAAA,MAAMC,mCAAA,CAA+B,OAAA,EAAS,cAAA,EAAgB,kBAAkB,CAAA;AAClF;;;;;"}
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' as const;\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 // TODO(v11): Gate incoming request body capture on `dataCollection.httpBodies` (capture only when\n // `'incomingRequest'` is listed) instead of defaulting to `'medium'`.\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":["defineIntegration","getIsolationScope","captureBodyFromWinterCGRequest"],"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,GAAwBA,uBAAkB,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;AAIA,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,iBAAiBC,sBAAA,EAAkB;AACzC,EAAA,MAAMC,mCAAA,CAA+B,OAAA,EAAS,cAAA,EAAgB,kBAAkB,CAAA;AAClF;;;;;"}
@@ -0,0 +1,124 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const node = require('@sentry/node');
4
+ const vercelai = require('./integrations/tracing/vercelai.js');
5
+ const client = require('../client.js');
6
+ const core = require('@sentry/core');
7
+ const fetch = require('../integrations/fetch.js');
8
+ const sdk = require('../sdk.js');
9
+ const hono = require('../integrations/hono.js');
10
+ const httpServer = require('../integrations/httpServer.js');
11
+ const instrumentD1 = require('../instrumentations/worker/instrumentD1.js');
12
+ const durableobject = require('../durableobject.js');
13
+ const workflows = require('../workflows.js');
14
+ const pagesPlugin = require('../pages-plugin.js');
15
+ const async = require('../async.js');
16
+ const withSentry = require('../withSentry.js');
17
+ const request = require('../request.js');
18
+
19
+
20
+
21
+ exports.prismaIntegration = node.prismaIntegration;
22
+ exports.vercelAIIntegration = vercelai.vercelAIIntegration;
23
+ exports.CloudflareClient = client.CloudflareClient;
24
+ exports.SDK_VERSION = core.SDK_VERSION;
25
+ exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = core.SEMANTIC_ATTRIBUTE_SENTRY_OP;
26
+ exports.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN;
27
+ exports.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = core.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE;
28
+ exports.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE;
29
+ exports.Scope = core.Scope;
30
+ exports.addBreadcrumb = core.addBreadcrumb;
31
+ exports.addEventProcessor = core.addEventProcessor;
32
+ exports.addIntegration = core.addIntegration;
33
+ exports.bindScopeToEmitter = core.bindScopeToEmitter;
34
+ exports.captureCheckIn = core.captureCheckIn;
35
+ exports.captureConsoleIntegration = core.captureConsoleIntegration;
36
+ exports.captureEvent = core.captureEvent;
37
+ exports.captureException = core.captureException;
38
+ exports.captureFeedback = core.captureFeedback;
39
+ exports.captureMessage = core.captureMessage;
40
+ exports.close = core.close;
41
+ exports.consoleIntegration = core.consoleIntegration;
42
+ exports.consoleLoggingIntegration = core.consoleLoggingIntegration;
43
+ exports.continueTrace = core.continueTrace;
44
+ exports.createConsolaReporter = core.createConsolaReporter;
45
+ exports.createLangChainCallbackHandler = core.createLangChainCallbackHandler;
46
+ exports.createTransport = core.createTransport;
47
+ exports.dedupeIntegration = core.dedupeIntegration;
48
+ exports.eventFiltersIntegration = core.eventFiltersIntegration;
49
+ exports.extraErrorDataIntegration = core.extraErrorDataIntegration;
50
+ exports.featureFlagsIntegration = core.featureFlagsIntegration;
51
+ exports.flush = core.flush;
52
+ exports.functionToStringIntegration = core.functionToStringIntegration;
53
+ exports.getActiveSpan = core.getActiveSpan;
54
+ exports.getClient = core.getClient;
55
+ exports.getCurrentScope = core.getCurrentScope;
56
+ exports.getGlobalScope = core.getGlobalScope;
57
+ exports.getIsolationScope = core.getIsolationScope;
58
+ exports.getRootSpan = core.getRootSpan;
59
+ exports.getSpanDescendants = core.getSpanDescendants;
60
+ exports.getSpanStatusFromHttpCode = core.getSpanStatusFromHttpCode;
61
+ exports.getTraceData = core.getTraceData;
62
+ exports.getTraceMetaTags = core.getTraceMetaTags;
63
+ exports.growthbookIntegration = core.growthbookIntegration;
64
+ exports.inboundFiltersIntegration = core.inboundFiltersIntegration;
65
+ exports.instrumentAnthropicAiClient = core.instrumentAnthropicAiClient;
66
+ exports.instrumentCreateReactAgent = core.instrumentCreateReactAgent;
67
+ exports.instrumentGoogleGenAIClient = core.instrumentGoogleGenAIClient;
68
+ exports.instrumentLangChainEmbeddings = core.instrumentLangChainEmbeddings;
69
+ exports.instrumentLangGraph = core.instrumentLangGraph;
70
+ exports.instrumentOpenAiClient = core.instrumentOpenAiClient;
71
+ exports.instrumentPostgresJsSql = core.instrumentPostgresJsSql;
72
+ exports.instrumentSupabaseClient = core.instrumentSupabaseClient;
73
+ exports.isEnabled = core.isEnabled;
74
+ exports.isInitialized = core.isInitialized;
75
+ exports.lastEventId = core.lastEventId;
76
+ exports.linkedErrorsIntegration = core.linkedErrorsIntegration;
77
+ exports.logger = core.logger;
78
+ exports.metrics = core.metrics;
79
+ exports.moduleMetadataIntegration = core.moduleMetadataIntegration;
80
+ exports.requestDataIntegration = core.requestDataIntegration;
81
+ exports.rewriteFramesIntegration = core.rewriteFramesIntegration;
82
+ exports.setAttribute = core.setAttribute;
83
+ exports.setAttributes = core.setAttributes;
84
+ exports.setContext = core.setContext;
85
+ exports.setConversationId = core.setConversationId;
86
+ exports.setCurrentClient = core.setCurrentClient;
87
+ exports.setExtra = core.setExtra;
88
+ exports.setExtras = core.setExtras;
89
+ exports.setHttpStatus = core.setHttpStatus;
90
+ exports.setMeasurement = core.setMeasurement;
91
+ exports.setTag = core.setTag;
92
+ exports.setTags = core.setTags;
93
+ exports.setUser = core.setUser;
94
+ exports.spanStreamingIntegration = core.spanStreamingIntegration;
95
+ exports.spanToBaggageHeader = core.spanToBaggageHeader;
96
+ exports.spanToJSON = core.spanToJSON;
97
+ exports.spanToTraceHeader = core.spanToTraceHeader;
98
+ exports.startInactiveSpan = core.startInactiveSpan;
99
+ exports.startNewTrace = core.startNewTrace;
100
+ exports.startSpan = core.startSpan;
101
+ exports.startSpanManual = core.startSpanManual;
102
+ exports.supabaseIntegration = core.supabaseIntegration;
103
+ exports.suppressTracing = core.suppressTracing;
104
+ exports.trpcMiddleware = core.trpcMiddleware;
105
+ exports.updateSpanName = core.updateSpanName;
106
+ exports.withActiveSpan = core.withActiveSpan;
107
+ exports.withIsolationScope = core.withIsolationScope;
108
+ exports.withMonitor = core.withMonitor;
109
+ exports.withScope = core.withScope;
110
+ exports.withStreamedSpan = core.withStreamedSpan;
111
+ exports.wrapMcpServerWithSentry = core.wrapMcpServerWithSentry;
112
+ exports.zodErrorsIntegration = core.zodErrorsIntegration;
113
+ exports.fetchIntegration = fetch.fetchIntegration;
114
+ exports.getDefaultIntegrations = sdk.getDefaultIntegrations;
115
+ exports.honoIntegration = hono.honoIntegration;
116
+ exports.httpServerIntegration = httpServer.httpServerIntegration;
117
+ exports.instrumentD1WithSentry = instrumentD1.instrumentD1WithSentry;
118
+ exports.instrumentDurableObjectWithSentry = durableobject.instrumentDurableObjectWithSentry;
119
+ exports.instrumentWorkflowWithSentry = workflows.instrumentWorkflowWithSentry;
120
+ exports.sentryPagesPlugin = pagesPlugin.sentryPagesPlugin;
121
+ exports.setAsyncLocalStorageAsyncContextStrategy = async.setAsyncLocalStorageAsyncContextStrategy;
122
+ exports.withSentry = withSentry.withSentry;
123
+ exports.wrapRequestHandler = request.wrapRequestHandler;
124
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,18 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const serverUtils = require('@sentry/server-utils');
5
+ const vercelai = require('../../../integrations/tracing/vercelai.js');
6
+
7
+ const _vercelAIIntegration = ((options = {}) => {
8
+ const inner = serverUtils.vercelAiIntegration(options);
9
+ const instrumentation = vercelai.vercelAIIntegration(options);
10
+ return {
11
+ ...inner,
12
+ ...instrumentation
13
+ };
14
+ });
15
+ const vercelAIIntegration = core.defineIntegration(_vercelAIIntegration);
16
+
17
+ exports.vercelAIIntegration = vercelAIIntegration;
18
+ //# sourceMappingURL=vercelai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercelai.js","sources":["../../../../../src/nodejs_compat/integrations/tracing/vercelai.ts"],"sourcesContent":["/**\n * This is a copy of the Vercel AI integration from the Cloudflare SDK (src/integrations/tracing/vercelai.ts).\n *\n * The only difference is that it includes tracing channel support\n * because the default Vercel AI integration needs `nodejs_als`, while this one uses `nodejs_compat`.\n */\n\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { vercelAiIntegration as serverUtilsVercelAiIntegration } from '@sentry/server-utils';\nimport { vercelAIIntegration as cloudflareVercelAIIntegration } from '../../../integrations/tracing/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 const inner = serverUtilsVercelAiIntegration(options);\n const instrumentation = cloudflareVercelAIIntegration(options);\n\n return {\n ...inner,\n ...instrumentation,\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":["serverUtilsVercelAiIntegration","cloudflareVercelAIIntegration","defineIntegration"],"mappings":";;;;;;AAoBA,MAAM,oBAAA,IAAwB,CAAC,OAAA,GAA2B,EAAC,KAAM;AAC/D,EAAA,MAAM,KAAA,GAAQA,gCAA+B,OAAO,CAAA;AACpD,EAAA,MAAM,eAAA,GAAkBC,6BAA8B,OAAO,CAAA;AAE7D,EAAA,OAAO;AAAA,IACL,GAAG,KAAA;AAAA,IACH,GAAG;AAAA,GACL;AACF,CAAA,CAAA;AA4BO,MAAM,mBAAA,GAAsBC,uBAAkB,oBAAoB;;;;"}
package/build/cjs/sdk.js CHANGED
@@ -36,14 +36,10 @@ function init(options) {
36
36
  }
37
37
  const flushLock = options.ctx ? flush.makeFlushLock(options.ctx) : void 0;
38
38
  delete options.ctx;
39
- const resolvedIntegrations = core.getIntegrationsToSetup(options);
40
- if (options.traceLifecycle === "stream" && !resolvedIntegrations.some((i) => i.name === "SpanStreaming")) {
41
- resolvedIntegrations.push(core.spanStreamingIntegration());
42
- }
43
39
  const clientOptions = {
44
40
  ...options,
45
41
  stackParser: core.stackParserFromStackParserOptions(options.stackParser || stacktrace.defaultStackParser),
46
- integrations: resolvedIntegrations,
42
+ integrations: core.getIntegrationsToSetup(options),
47
43
  transport: options.transport || transport.makeCloudflareTransport,
48
44
  flushLock
49
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {\n consoleIntegration,\n conversationIdIntegration,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n spanStreamingIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\nimport { makeFlushLock } from './flush';\nimport { httpServerIntegration } from './integrations/httpServer';\nimport { fetchIntegration } from './integrations/fetch';\nimport { honoIntegration } from './integrations/hono';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/** Get the default integrations for the Cloudflare SDK. */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n // TODO(v11): Drop this transitional gating and let `requestDataIntegration` rely on the resolved\n // `dataCollection` defaults directly. Until then, preserve the historical Cloudflare behavior of not\n // attaching cookies unless the user explicitly opts in via `sendDefaultPii` or `dataCollection.cookies`.\n // eslint-disable-next-line typescript/no-deprecated\n const cookiesEnabled = options.sendDefaultPii || options.dataCollection?.cookies != null;\n return [\n // The Dedupe integration should not be used in workflows because we want to\n // capture all step failures, even if they are the same error.\n ...(options.enableDedupe === false ? [] : [dedupeIntegration()]),\n // TODO(v11): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line typescript/no-deprecated\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n // eslint-disable-next-line typescript/no-deprecated\n honoIntegration(),\n httpServerIntegration(),\n requestDataIntegration(cookiesEnabled ? undefined : { include: { cookies: false } }),\n consoleIntegration(),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n const flushLock = options.ctx ? makeFlushLock(options.ctx) : undefined;\n delete options.ctx;\n\n const resolvedIntegrations = getIntegrationsToSetup(options);\n if (options.traceLifecycle === 'stream' && !resolvedIntegrations.some(i => i.name === 'SpanStreaming')) {\n resolvedIntegrations.push(spanStreamingIntegration());\n }\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: resolvedIntegrations,\n transport: options.transport || makeCloudflareTransport,\n flushLock,\n };\n\n /**\n * The Cloudflare SDK is not OpenTelemetry native, however, we set up some OpenTelemetry compatibility\n * via a custom trace provider.\n * This ensures that any spans emitted via `@opentelemetry/api` will be captured by Sentry.\n * HOWEVER, big caveat: This does not handle custom context handling, it will always work off the current scope.\n * This should be good enough for many, but not all integrations.\n */\n if (!options.skipOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n}\n"],"names":["dedupeIntegration","inboundFiltersIntegration","functionToStringIntegration","conversationIdIntegration","linkedErrorsIntegration","fetchIntegration","honoIntegration","httpServerIntegration","requestDataIntegration","consoleIntegration","makeFlushLock","getIntegrationsToSetup","spanStreamingIntegration","stackParserFromStackParserOptions","defaultStackParser","makeCloudflareTransport","setupOpenTelemetryTracer","initAndBind","CloudflareClient"],"mappings":";;;;;;;;;;;;AAyBO,SAAS,uBAAuB,OAAA,EAA2C;AAKhF,EAAA,MAAM,cAAA,GAAiB,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,gBAAgB,OAAA,IAAW,IAAA;AACpF,EAAA,OAAO;AAAA;AAAA;AAAA,IAGL,GAAI,QAAQ,YAAA,KAAiB,KAAA,GAAQ,EAAC,GAAI,CAACA,wBAAmB,CAAA;AAAA;AAAA;AAAA,IAG9DC,8BAAA,EAA0B;AAAA,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C,yBAAkB,aAAa,CAAA;AACpD;;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {\n consoleIntegration,\n conversationIdIntegration,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\nimport { makeFlushLock } from './flush';\nimport { httpServerIntegration } from './integrations/httpServer';\nimport { fetchIntegration } from './integrations/fetch';\nimport { honoIntegration } from './integrations/hono';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/** Get the default integrations for the Cloudflare SDK. */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n // TODO(v11): Drop this transitional gating and let `requestDataIntegration` rely on the resolved\n // `dataCollection` defaults directly. Until then, preserve the historical Cloudflare behavior of not\n // attaching cookies unless the user explicitly opts in via `sendDefaultPii` or `dataCollection.cookies`.\n // eslint-disable-next-line typescript/no-deprecated\n const cookiesEnabled = options.sendDefaultPii || options.dataCollection?.cookies != null;\n return [\n // The Dedupe integration should not be used in workflows because we want to\n // capture all step failures, even if they are the same error.\n ...(options.enableDedupe === false ? [] : [dedupeIntegration()]),\n // TODO(v11): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line typescript/no-deprecated\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n // eslint-disable-next-line typescript/no-deprecated\n honoIntegration(),\n httpServerIntegration(),\n requestDataIntegration(cookiesEnabled ? undefined : { include: { cookies: false } }),\n consoleIntegration(),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n const flushLock = options.ctx ? makeFlushLock(options.ctx) : undefined;\n delete options.ctx;\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeCloudflareTransport,\n flushLock,\n };\n\n /**\n * The Cloudflare SDK is not OpenTelemetry native, however, we set up some OpenTelemetry compatibility\n * via a custom trace provider.\n * This ensures that any spans emitted via `@opentelemetry/api` will be captured by Sentry.\n * HOWEVER, big caveat: This does not handle custom context handling, it will always work off the current scope.\n * This should be good enough for many, but not all integrations.\n */\n if (!options.skipOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n}\n"],"names":["dedupeIntegration","inboundFiltersIntegration","functionToStringIntegration","conversationIdIntegration","linkedErrorsIntegration","fetchIntegration","honoIntegration","httpServerIntegration","requestDataIntegration","consoleIntegration","makeFlushLock","stackParserFromStackParserOptions","defaultStackParser","getIntegrationsToSetup","makeCloudflareTransport","setupOpenTelemetryTracer","initAndBind","CloudflareClient"],"mappings":";;;;;;;;;;;;AAwBO,SAAS,uBAAuB,OAAA,EAA2C;AAKhF,EAAA,MAAM,cAAA,GAAiB,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,gBAAgB,OAAA,IAAW,IAAA;AACpF,EAAA,OAAO;AAAA;AAAA;AAAA,IAGL,GAAI,QAAQ,YAAA,KAAiB,KAAA,GAAQ,EAAC,GAAI,CAACA,wBAAmB,CAAA;AAAA;AAAA;AAAA,IAG9DC,8BAAA,EAA0B;AAAA,IAC1BC,gCAAA,EAA4B;AAAA,IAC5BC,8BAAA,EAA0B;AAAA,IAC1BC,4BAAA,EAAwB;AAAA,IACxBC,sBAAA,EAAiB;AAAA;AAAA,IAEjBC,oBAAA,EAAgB;AAAA,IAChBC,gCAAA,EAAsB;AAAA,IACtBC,2BAAA,CAAuB,iBAAiB,MAAA,GAAY,EAAE,SAAS,EAAE,OAAA,EAAS,KAAA,EAAM,EAAG,CAAA;AAAA,IACnFC,uBAAA;AAAmB,GACrB;AACF;AAKO,SAAS,KAAK,OAAA,EAA0D;AAC7E,EAAA,IAAI,OAAA,CAAQ,wBAAwB,MAAA,EAAW;AAC7C,IAAA,OAAA,CAAQ,mBAAA,GAAsB,uBAAuB,OAAO,CAAA;AAAA,EAC9D;AAEA,EAAA,MAAM,YAAY,OAAA,CAAQ,GAAA,GAAMC,mBAAA,CAAc,OAAA,CAAQ,GAAG,CAAA,GAAI,MAAA;AAC7D,EAAA,OAAO,OAAA,CAAQ,GAAA;AAEf,EAAA,MAAM,aAAA,GAAyC;AAAA,IAC7C,GAAG,OAAA;AAAA,IACH,WAAA,EAAaC,sCAAA,CAAkC,OAAA,CAAQ,WAAA,IAAeC,6BAAkB,CAAA;AAAA,IACxF,YAAA,EAAcC,4BAAuB,OAAO,CAAA;AAAA,IAC5C,SAAA,EAAW,QAAQ,SAAA,IAAaC,iCAAA;AAAA,IAChC;AAAA,GACF;AASA,EAAA,IAAI,CAAC,QAAQ,sBAAA,EAAwB;AACnC,IAAAC,+BAAA,EAAyB;AAAA,EAC3B;AAEA,EAAA,OAAOC,gBAAA,CAAYC,yBAAkB,aAAa,CAAA;AACpD;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"async.js","sources":["../../src/async.ts"],"sourcesContent":["// Need to use node: prefix for cloudflare workers compatibility\n// Note: Because we are using node:async_hooks, we need to set `node_compat` in the wrangler.toml\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport type { Scope } from '@sentry/core';\nimport {\n _INTERNAL_createTracingChannelBinding,\n getDefaultCurrentScope,\n getDefaultIsolationScope,\n setAsyncContextStrategy,\n} from '@sentry/core';\n\n/**\n * Sets the async context strategy to use AsyncLocalStorage.\n *\n * AsyncLocalStorage is only available in the cloudflare workers runtime if you set\n * compatibility_flags = [\"nodejs_compat\"] or compatibility_flags = [\"nodejs_als\"]\n *\n * @internal Only exported to be used in higher-level Sentry packages\n * @hidden Only exported to be used in higher-level Sentry packages\n */\nexport function setAsyncLocalStorageAsyncContextStrategy(): void {\n const asyncStorage = new AsyncLocalStorage<{\n scope: Scope;\n isolationScope: Scope;\n }>();\n\n function getScopes(): { scope: Scope; isolationScope: Scope } {\n const scopes = asyncStorage.getStore();\n\n if (scopes) {\n return scopes;\n }\n\n // fallback behavior:\n // if, for whatever reason, we can't find scopes on the context here, we have to fix this somehow\n return {\n scope: getDefaultCurrentScope(),\n isolationScope: getDefaultIsolationScope(),\n };\n }\n\n function withScope<T>(callback: (scope: Scope) => T): T {\n const scope = getScopes().scope.clone();\n const isolationScope = getScopes().isolationScope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withSetScope<T>(scope: Scope, callback: (scope: Scope) => T): T {\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope;\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n function withSetIsolationScope<T>(isolationScope: Scope, callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n // In contrast to the browser, we can rely on async context isolation here\n function suppressTracing<T>(callback: () => T): T {\n return withScope(scope => {\n scope.setSDKProcessingMetadata({ __SENTRY_SUPPRESS_TRACING__: true });\n return callback();\n });\n }\n\n setAsyncContextStrategy({\n suppressTracing,\n withScope,\n withSetScope,\n withIsolationScope,\n withSetIsolationScope,\n getCurrentScope: () => getScopes().scope,\n getIsolationScope: () => getScopes().isolationScope,\n getTracingChannelBinding: () =>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,CAAA;AAAA,IAChC,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,SAAS,qBAAA,CAAyB,gBAAuB,QAAA,EAA2C;AAClG,IAAA,MAAM,KAAA,GAAQ,WAAU,CAAE,KAAA;AAC1B,IAAA,OAAO,aAAa,GAAA,CAAI,EAAE,KAAA,EAAO,cAAA,IAAkB,MAAM;AACvD,MAAA,OAAO,SAAS,cAAc,CAAA;AAAA,IAChC,CAAC,CAAA;AAAA,EACH;AAGA,EAAA,SAAS,gBAAmB,QAAA,EAAsB;AAChD,IAAA,OAAO,UAAU,CAAA,KAAA,KAAS;AACxB,MAAA,KAAA,CAAM,wBAAA,CAAyB,EAAE,2BAAA,EAA6B,IAAA,EAAM,CAAA;AACpE,MAAA,OAAO,QAAA,EAAS;AAAA,IAClB,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,uBAAA,CAAwB;AAAA,IACtB,eAAA;AAAA,IACA,SAAA;AAAA,IACA,YAAA;AAAA,IACA,kBAAA;AAAA,IACA,qBAAA;AAAA,IACA,eAAA,EAAiB,MAAM,SAAA,EAAU,CAAE,KAAA;AAAA,IACnC,iBAAA,EAAmB,MAAM,SAAA,EAAU,CAAE,cAAA;AAAA,IACrC,wBAAA,EAA0B,MAAM,qCAAA,CAAsC,YAAA,EAAc,SAAS;AAAA,GAC9F,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"async.js","sources":["../../src/async.ts"],"sourcesContent":["// Need to use node: prefix for cloudflare workers compatibility\n// Note: Because we are using node:async_hooks, we need to set `node_compat` in the wrangler.toml\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport type { Scope } from '@sentry/core';\nimport {\n _INTERNAL_createTracingChannelBinding,\n getDefaultCurrentScope,\n getDefaultIsolationScope,\n setAsyncContextStrategy,\n} from '@sentry/core';\n\n/**\n * Sets the async context strategy to use AsyncLocalStorage.\n *\n * AsyncLocalStorage is only available in the cloudflare workers runtime if you set\n * compatibility_flags = [\"nodejs_compat\"]\n *\n * @internal Only exported to be used in higher-level Sentry packages\n * @hidden Only exported to be used in higher-level Sentry packages\n */\nexport function setAsyncLocalStorageAsyncContextStrategy(): void {\n const asyncStorage = new AsyncLocalStorage<{\n scope: Scope;\n isolationScope: Scope;\n }>();\n\n function getScopes(): { scope: Scope; isolationScope: Scope } {\n const scopes = asyncStorage.getStore();\n\n if (scopes) {\n return scopes;\n }\n\n // fallback behavior:\n // if, for whatever reason, we can't find scopes on the context here, we have to fix this somehow\n return {\n scope: getDefaultCurrentScope(),\n isolationScope: getDefaultIsolationScope(),\n };\n }\n\n function withScope<T>(callback: (scope: Scope) => T): T {\n const scope = getScopes().scope.clone();\n const isolationScope = getScopes().isolationScope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withSetScope<T>(scope: Scope, callback: (scope: Scope) => T): T {\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope;\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n function withSetIsolationScope<T>(isolationScope: Scope, callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n // In contrast to the browser, we can rely on async context isolation here\n function suppressTracing<T>(callback: () => T): T {\n return withScope(scope => {\n scope.setSDKProcessingMetadata({ __SENTRY_SUPPRESS_TRACING__: true });\n return callback();\n });\n }\n\n setAsyncContextStrategy({\n suppressTracing,\n withScope,\n withSetScope,\n withIsolationScope,\n withSetIsolationScope,\n getCurrentScope: () => getScopes().scope,\n getIsolationScope: () => getScopes().isolationScope,\n getTracingChannelBinding: () => _INTERNAL_createTracingChannelBinding(asyncStorage, getScopes),\n });\n}\n"],"names":[],"mappings":";;;AAoBO,SAAS,wCAAA,GAAiD;AAC/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AClG,IAAA,MAAM,KAAA,GAAQ,WAAU,CAAE,KAAA;AAC1B,IAAA,OAAO,aAAa,GAAA,CAAI,EAAE,KAAA,EAAO,cAAA,IAAkB,MAAM;AACvD,MAAA,OAAO,SAAS,cAAc,CAAA;AAAA,IAChC,CAAC,CAAA;AAAA,EACH;AAGA,EAAA,SAAS,gBAAmB,QAAA,EAAsB;AAChD,IAAA,OAAO,UAAU,CAAA,KAAA,KAAS;AACxB,MAAA,KAAA,CAAM,wBAAA,CAAyB,EAAE,2BAAA,EAA6B,IAAA,EAAM,CAAA;AACpE,MAAA,OAAO,QAAA,EAAS;AAAA,IAClB,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,uBAAA,CAAwB;AAAA,IACtB,eAAA;AAAA,IACA,SAAA;AAAA,IACA,YAAA;AAAA,IACA,kBAAA;AAAA,IACA,qBAAA;AAAA,IACA,eAAA,EAAiB,MAAM,SAAA,EAAU,CAAE,KAAA;AAAA,IACnC,iBAAA,EAAmB,MAAM,SAAA,EAAU,CAAE,cAAA;AAAA,IACrC,wBAAA,EAA0B,MAAM,qCAAA,CAAsC,YAAA,EAAc,SAAS;AAAA,GAC9F,CAAA;AACH;;;;"}
@@ -1,4 +1,5 @@
1
- import { flush } from '@sentry/core';
1
+ import { flush, debug } from '@sentry/core';
2
+ import { DEBUG_BUILD } from './debug-build.js';
2
3
 
3
4
  const flushLockRegistries = /* @__PURE__ */ new WeakMap();
4
5
  function getOriginalWaitUntil(context) {
@@ -61,12 +62,21 @@ function getOrCreateFlushLockRegistry(context) {
61
62
  return registry;
62
63
  }
63
64
  async function flushAndDispose(client, timeout = 2e3) {
64
- if (!client) {
65
- await flush(timeout);
66
- return;
65
+ try {
66
+ if (!client) {
67
+ await flush(timeout);
68
+ return;
69
+ }
70
+ await client.flush(timeout);
71
+ } catch (e) {
72
+ DEBUG_BUILD && debug.warn("Failed to flush client", e);
73
+ } finally {
74
+ try {
75
+ client?.dispose();
76
+ } catch (e) {
77
+ DEBUG_BUILD && debug.warn("Failed to dispose client", e);
78
+ }
67
79
  }
68
- await client.flush(timeout);
69
- client.dispose();
70
80
  }
71
81
 
72
82
  export { flushAndDispose, getOriginalWaitUntil, makeFlushLock };
@@ -1 +1 @@
1
- {"version":3,"file":"flush.js","sources":["../../src/flush.ts"],"sourcesContent":["import type { ExecutionContext } from '@cloudflare/workers-types';\nimport type { Client } from '@sentry/core';\nimport { flush } from '@sentry/core';\n\ntype FlushLock = {\n readonly ready: Promise<void>;\n readonly finalize: () => Promise<void>;\n};\n\ntype FlushLockRegistry = {\n readonly locks: Set<FlushLockInternal>;\n readonly originalWaitUntil: ExecutionContext['waitUntil'];\n};\n\ntype FlushLockInternal = FlushLock & {\n readonly acquire: () => void;\n readonly release: () => void;\n};\n\nconst flushLockRegistries = new WeakMap<ExecutionContext['waitUntil'], FlushLockRegistry>();\n\n/**\n * Returns the original (un-instrumented) waitUntil function for a context.\n * This should be used when calling waitUntil with flushAndDispose to avoid deadlock.\n *\n * The flush lock mechanism wraps context.waitUntil to track pending tasks.\n * If we call waitUntil(flushAndDispose(client)) through the instrumented version,\n * it creates a deadlock because:\n * 1. The instrumented waitUntil acquires the flush lock\n * 2. flushAndDispose calls client.flush() which waits for the lock to be released\n * 3. The lock won't be released until the waitUntil promise completes\n * 4. The waitUntil promise won't complete until flush() returns\n *\n * By using the original waitUntil for flush operations, we bypass this issue.\n */\nexport function getOriginalWaitUntil(context: ExecutionContext): ExecutionContext['waitUntil'] | undefined {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const currentWaitUntil = context.waitUntil;\n const original = flushLockRegistries.get(currentWaitUntil)?.originalWaitUntil;\n return original ?? currentWaitUntil;\n}\n\n/**\n * Enhances the given execution context by wrapping its `waitUntil` method with a proxy\n * to monitor pending tasks, and provides a flusher function to ensure all tasks\n * have been completed before executing any subsequent logic.\n *\n * @param {ExecutionContext} context - The execution context to be enhanced. If no context is provided, the function returns undefined.\n * @return {FlushLock} Returns a flusher function if a valid context is provided, otherwise undefined.\n */\nexport function makeFlushLock(context: ExecutionContext): FlushLock {\n const registry = getOrCreateFlushLockRegistry(context);\n let resolveAllDone: () => void = () => undefined;\n const allDone = new Promise<void>(res => {\n resolveAllDone = res;\n });\n let pending = 0;\n\n const lock: FlushLockInternal = {\n ready: allDone,\n acquire: () => {\n pending++;\n },\n release: () => {\n if (--pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n },\n finalize: () => {\n if (pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n return allDone;\n },\n };\n\n registry.locks.add(lock);\n return Object.freeze(lock);\n}\n\nfunction getOrCreateFlushLockRegistry(context: ExecutionContext): FlushLockRegistry {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const waitUntil = context.waitUntil;\n const existingRegistry = flushLockRegistries.get(waitUntil);\n\n if (existingRegistry) {\n return existingRegistry;\n }\n\n const originalWaitUntil = context.waitUntil.bind(context) as typeof context.waitUntil;\n const registry: FlushLockRegistry = { locks: new Set(), originalWaitUntil };\n const instrumentedWaitUntil: typeof context.waitUntil = promise => {\n // Snapshot active locks so locks created after this call do not wait for earlier waitUntil work.\n const locks = [...registry.locks];\n\n for (const lock of locks) {\n lock.acquire();\n }\n\n return originalWaitUntil(\n promise.finally(() => {\n for (const lock of locks) {\n lock.release();\n }\n }),\n );\n };\n\n flushLockRegistries.set(instrumentedWaitUntil, registry);\n context.waitUntil = instrumentedWaitUntil;\n\n return registry;\n}\n\n/**\n * Flushes the client and then disposes of it to allow garbage collection.\n * This should be called at the end of each request to prevent memory leaks.\n *\n * @param client - The CloudflareClient instance to flush and dispose\n * @param timeout - Timeout in milliseconds for the flush operation\n * @returns A promise that resolves when flush and dispose are complete\n */\nexport async function flushAndDispose(client: Client | undefined, timeout = 2000): Promise<void> {\n if (!client) {\n await flush(timeout);\n\n return;\n }\n\n await client.flush(timeout);\n client.dispose();\n}\n"],"names":[],"mappings":";;AAmBA,MAAM,mBAAA,uBAA0B,OAAA,EAA0D;AAgBnF,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E1D,EAAA,IAAI,gBAAA,EAAkB;AACpB,IAAA,OAAO,gBAAA;AAAA,EACT;AAEA,EAAA,MAAM,iBAAA,GAAoB,OAAA,CAAQ,SAAA,CAAU,IAAA,CAAK,OAAO,CAAA;AACxD,EAAA,MAAM,WAA8B,EAAE,KAAA,kBAAO,IAAI,GAAA,IAAO,iBAAA,EAAkB;AAC1E,EAAA,MAAM,wBAAkD,CAAA,OAAA,KAAW;AAEjE,IAAA,MAAM,KAAA,GAAQ,CAAC,GAAG,QAAA,CAAS,KAAK,CAAA;AAEhC,IAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,MAAA,IAAA,CAAK,OAAA,EAAQ;AAAA,IACf;AAEA,IAAA,OAAO,iBAAA;AAAA,MACL,OAAA,CAAQ,QAAQ,MAAM;AACpB,QAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,UAAA,IAAA,CAAK,OAAA,EAAQ;AAAA,QACf;AAAA,MACF,CAAC;AAAA,KACH;AAAA,EACF,CAAA;AAEA,EAAA,mBAAA,CAAoB,GAAA,CAAI,uBAAuB,QAAQ,CAAA;AACvD,EAAA,OAAA,CAAQ,SAAA,GAAY,qBAAA;AAEpB,EAAA,OAAO,QAAA;AACT;AAUA,eAAsB,eAAA,CAAgB,MAAA,EAA4B,OAAA,GAAU,GAAA,EAAqB;AAC/F,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,MAAM,OAAO,CAAA;AAEnB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,MAAA,CAAO,MAAM,OAAO,CAAA;AAC1B,EAAA,MAAA,CAAO,OAAA,EAAQ;AACjB;;;;"}
1
+ {"version":3,"file":"flush.js","sources":["../../src/flush.ts"],"sourcesContent":["import type { ExecutionContext } from '@cloudflare/workers-types';\nimport type { Client } from '@sentry/core';\nimport { debug, flush } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\n\ntype FlushLock = {\n readonly ready: Promise<void>;\n readonly finalize: () => Promise<void>;\n};\n\ntype FlushLockRegistry = {\n readonly locks: Set<FlushLockInternal>;\n readonly originalWaitUntil: ExecutionContext['waitUntil'];\n};\n\ntype FlushLockInternal = FlushLock & {\n readonly acquire: () => void;\n readonly release: () => void;\n};\n\nconst flushLockRegistries = new WeakMap<ExecutionContext['waitUntil'], FlushLockRegistry>();\n\n/**\n * Returns the original (un-instrumented) waitUntil function for a context.\n * This should be used when calling waitUntil with flushAndDispose to avoid deadlock.\n *\n * The flush lock mechanism wraps context.waitUntil to track pending tasks.\n * If we call waitUntil(flushAndDispose(client)) through the instrumented version,\n * it creates a deadlock because:\n * 1. The instrumented waitUntil acquires the flush lock\n * 2. flushAndDispose calls client.flush() which waits for the lock to be released\n * 3. The lock won't be released until the waitUntil promise completes\n * 4. The waitUntil promise won't complete until flush() returns\n *\n * By using the original waitUntil for flush operations, we bypass this issue.\n */\nexport function getOriginalWaitUntil(context: ExecutionContext): ExecutionContext['waitUntil'] | undefined {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const currentWaitUntil = context.waitUntil;\n const original = flushLockRegistries.get(currentWaitUntil)?.originalWaitUntil;\n return original ?? currentWaitUntil;\n}\n\n/**\n * Enhances the given execution context by wrapping its `waitUntil` method with a proxy\n * to monitor pending tasks, and provides a flusher function to ensure all tasks\n * have been completed before executing any subsequent logic.\n *\n * @param {ExecutionContext} context - The execution context to be enhanced. If no context is provided, the function returns undefined.\n * @return {FlushLock} Returns a flusher function if a valid context is provided, otherwise undefined.\n */\nexport function makeFlushLock(context: ExecutionContext): FlushLock {\n const registry = getOrCreateFlushLockRegistry(context);\n let resolveAllDone: () => void = () => undefined;\n const allDone = new Promise<void>(res => {\n resolveAllDone = res;\n });\n let pending = 0;\n\n const lock: FlushLockInternal = {\n ready: allDone,\n acquire: () => {\n pending++;\n },\n release: () => {\n if (--pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n },\n finalize: () => {\n if (pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n return allDone;\n },\n };\n\n registry.locks.add(lock);\n return Object.freeze(lock);\n}\n\nfunction getOrCreateFlushLockRegistry(context: ExecutionContext): FlushLockRegistry {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const waitUntil = context.waitUntil;\n const existingRegistry = flushLockRegistries.get(waitUntil);\n\n if (existingRegistry) {\n return existingRegistry;\n }\n\n const originalWaitUntil = context.waitUntil.bind(context) as typeof context.waitUntil;\n const registry: FlushLockRegistry = { locks: new Set(), originalWaitUntil };\n const instrumentedWaitUntil: typeof context.waitUntil = promise => {\n // Snapshot active locks so locks created after this call do not wait for earlier waitUntil work.\n const locks = [...registry.locks];\n\n for (const lock of locks) {\n lock.acquire();\n }\n\n return originalWaitUntil(\n promise.finally(() => {\n for (const lock of locks) {\n lock.release();\n }\n }),\n );\n };\n\n flushLockRegistries.set(instrumentedWaitUntil, registry);\n context.waitUntil = instrumentedWaitUntil;\n\n return registry;\n}\n\n/**\n * Flushes the client and then disposes of it to allow garbage collection.\n * This should be called at the end of each request to prevent memory leaks.\n *\n * This function never rejects. On Workers, a rejected promise passed to\n * `ctx.waitUntil` marks the whole invocation as `outcome: exception` even when\n * the handler itself completed successfully. Since flush/dispose is internal\n * SDK housekeeping, a failure here must not fail the user's invocation.\n *\n * @param client - The CloudflareClient instance to flush and dispose\n * @param timeout - Timeout in milliseconds for the flush operation\n * @returns A promise that resolves when flush and dispose are complete\n */\nexport async function flushAndDispose(client: Client | undefined, timeout = 2000): Promise<void> {\n try {\n if (!client) {\n await flush(timeout);\n return;\n }\n await client.flush(timeout);\n } catch (e) {\n DEBUG_BUILD && debug.warn('Failed to flush client', e);\n } finally {\n try {\n client?.dispose();\n } catch (e) {\n DEBUG_BUILD && debug.warn('Failed to dispose client', e);\n }\n }\n}\n"],"names":[],"mappings":";;;AAoBA,MAAM,mBAAA,uBAA0B,OAAA,EAA0D;AAgBnF,SAAS,qBAAqB,OAAA,EAAsE;AAEzG,EAAA,MAAM,mBAAmB,OAAA,CAA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ACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sources":["../../../src/integrations/fetch.ts"],"sourcesContent":["import type {\n Client,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataFetch,\n IntegrationFn,\n Span,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addFetchInstrumentationHandler,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n instrumentFetchRequest,\n isSentryRequestUrl,\n LRUMap,\n stringMatchesSomePattern,\n} from '@sentry/core';\n\nconst INTEGRATION_NAME = 'Fetch';\n\nconst HAS_CLIENT_MAP = new WeakMap<Client, boolean>();\n\nexport interface Options {\n /**\n * Whether breadcrumbs should be recorded for requests\n * Defaults to true\n */\n breadcrumbs: boolean;\n\n /**\n * Function determining whether or not to create spans to track outgoing requests to the given URL.\n * By default, spans will be created for all outgoing requests.\n */\n shouldCreateSpanForRequest?: (url: string) => boolean;\n}\n\nconst _fetchIntegration = ((options: Partial<Options> = {}) => {\n const breadcrumbs = options.breadcrumbs === undefined ? true : options.breadcrumbs;\n const shouldCreateSpanForRequest = options.shouldCreateSpanForRequest;\n\n const _createSpanUrlMap = new LRUMap<string, boolean>(100);\n const _headersUrlMap = new LRUMap<string, boolean>(100);\n\n const spans: Record<string, Span> = {};\n\n /** Decides whether to attach trace data to the outgoing fetch request */\n function _shouldAttachTraceData(url: string): boolean {\n const client = getClient();\n\n if (!client) {\n return false;\n }\n\n const clientOptions = client.getOptions();\n\n if (clientOptions.tracePropagationTargets === undefined) {\n return true;\n }\n\n const cachedDecision = _headersUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = stringMatchesSomePattern(url, clientOptions.tracePropagationTargets);\n _headersUrlMap.set(url, decision);\n return decision;\n }\n\n /** Helper that wraps shouldCreateSpanForRequest option */\n function _shouldCreateSpan(url: string): boolean {\n if (shouldCreateSpanForRequest === undefined) {\n return true;\n }\n\n const cachedDecision = _createSpanUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = shouldCreateSpanForRequest(url);\n _createSpanUrlMap.set(url, decision);\n return decision;\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n addFetchInstrumentationHandler(handlerData => {\n const client = getClient();\n const { propagateTraceparent } = client?.getOptions() || {};\n if (!client || !HAS_CLIENT_MAP.get(client)) {\n return;\n }\n\n if (isSentryRequestUrl(handlerData.fetchData.url, client)) {\n return;\n }\n\n instrumentFetchRequest(handlerData, _shouldCreateSpan, _shouldAttachTraceData, spans, {\n spanOrigin: 'auto.http.fetch',\n propagateTraceparent,\n });\n\n if (breadcrumbs) {\n createBreadcrumb(handlerData);\n }\n }, true);\n },\n setup(client) {\n HAS_CLIENT_MAP.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Creates spans and attaches tracing headers to fetch requests.\n */\nexport const fetchIntegration = defineIntegration(_fetchIntegration);\n\nfunction createBreadcrumb(handlerData: HandlerDataFetch): void {\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n const breadcrumbData: FetchBreadcrumbData = {\n method: handlerData.fetchData.method,\n url: handlerData.fetchData.url,\n };\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n level: 'error',\n type: 'http',\n },\n hint,\n );\n } else {\n const response = handlerData.response as Response | undefined;\n\n breadcrumbData.request_body_size = handlerData.fetchData.request_body_size;\n breadcrumbData.response_body_size = handlerData.fetchData.response_body_size;\n breadcrumbData.status_code = response?.status;\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n const level = getBreadcrumbLogLevelFromHttpStatusCode(breadcrumbData.status_code);\n\n addBreadcrumb(\n {\n category: 'fetch',\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ts"],"sourcesContent":["import type {\n Client,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataFetch,\n IntegrationFn,\n Span,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addFetchInstrumentationHandler,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n instrumentFetchRequest,\n isSentryRequestUrl,\n LRUMap,\n stringMatchesSomePattern,\n} from '@sentry/core';\n\nconst INTEGRATION_NAME = 'Fetch' as const;\n\nconst HAS_CLIENT_MAP = new WeakMap<Client, boolean>();\n\nexport interface Options {\n /**\n * Whether breadcrumbs should be recorded for requests\n * Defaults to true\n */\n breadcrumbs: boolean;\n\n /**\n * Function determining whether or not to create spans to track outgoing requests to the given URL.\n * By default, spans will be created for all outgoing requests.\n */\n shouldCreateSpanForRequest?: (url: string) => boolean;\n}\n\nconst _fetchIntegration = ((options: Partial<Options> = {}) => {\n const breadcrumbs = options.breadcrumbs === undefined ? true : options.breadcrumbs;\n const shouldCreateSpanForRequest = options.shouldCreateSpanForRequest;\n\n const _createSpanUrlMap = new LRUMap<string, boolean>(100);\n const _headersUrlMap = new LRUMap<string, boolean>(100);\n\n const spans: Record<string, Span> = {};\n\n /** Decides whether to attach trace data to the outgoing fetch request */\n function _shouldAttachTraceData(url: string): boolean {\n const client = getClient();\n\n if (!client) {\n return false;\n }\n\n const clientOptions = client.getOptions();\n\n if (clientOptions.tracePropagationTargets === undefined) {\n return true;\n }\n\n const cachedDecision = _headersUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = stringMatchesSomePattern(url, clientOptions.tracePropagationTargets);\n _headersUrlMap.set(url, decision);\n return decision;\n }\n\n /** Helper that wraps shouldCreateSpanForRequest option */\n function _shouldCreateSpan(url: string): boolean {\n if (shouldCreateSpanForRequest === undefined) {\n return true;\n }\n\n const cachedDecision = _createSpanUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = shouldCreateSpanForRequest(url);\n _createSpanUrlMap.set(url, decision);\n return decision;\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n addFetchInstrumentationHandler(handlerData => {\n const client = getClient();\n const { propagateTraceparent } = client?.getOptions() || {};\n if (!client || !HAS_CLIENT_MAP.get(client)) {\n return;\n }\n\n if (isSentryRequestUrl(handlerData.fetchData.url, client)) {\n return;\n }\n\n instrumentFetchRequest(handlerData, _shouldCreateSpan, _shouldAttachTraceData, spans, {\n spanOrigin: 'auto.http.fetch',\n propagateTraceparent,\n });\n\n if (breadcrumbs) {\n createBreadcrumb(handlerData);\n }\n }, true);\n },\n setup(client) {\n HAS_CLIENT_MAP.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Creates spans and attaches tracing headers to fetch requests.\n */\nexport const fetchIntegration = defineIntegration(_fetchIntegration);\n\nfunction createBreadcrumb(handlerData: HandlerDataFetch): void {\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n const breadcrumbData: FetchBreadcrumbData = {\n method: handlerData.fetchData.method,\n url: handlerData.fetchData.url,\n };\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n level: 'error',\n type: 'http',\n },\n hint,\n );\n } else {\n const response = handlerData.response as Response | undefined;\n\n breadcrumbData.request_body_size = handlerData.fetchData.request_body_size;\n breadcrumbData.response_body_size = handlerData.fetchData.response_body_size;\n breadcrumbData.status_code = response?.status;\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n const level = getBreadcrumbLogLevelFromHttpStatusCode(breadcrumbData.status_code);\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n type: 'http',\n level,\n },\n hint,\n );\n }\n}\n"],"names":[],"mappings":";;AA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AAAA,EACF;AAEA,EAAA,MAAM,cAAA,GAAsC;AAAA,IAC1C,MAAA,EAAQ,YAAY,SAAA,CAAU,MAAA;AAAA,IAC9B,GAAA,EAAK,YAAY,SAAA,CAAU;AAAA,GAC7B;AAEA,EAAA,IAAI,YAAY,KAAA,EAAO;AACrB,IAAA,MAAM,IAAA,GAA4B;AAAA,MAChC,MAAM,WAAA,CAAY,KAAA;AAAA,MAClB,OAAO,WAAA,CAAY,IAAA;AAAA,MACnB,cAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,aAAA;AAAA,MACE;AAAA,QACE,QAAA,EAAU,OAAA;AAAA,QACV,IAAA,EAAM,cAAA;AAAA,QACN,KAAA,EAAO,OAAA;AAAA,QACP,IAAA,EAAM;AAAA,OACR;AAAA,MACA;AAAA,KACF;AAAA,EACF,CAAA,MAAO;AACL,IAAA,MAAM,WAAW,WAAA,CAAY,QAAA;AAE7B,IAAA,cAAA,CAAe,iBAAA,GAAoB,YAAY,SAAA,CAAU,iBAAA;AACzD,IAAA,cAAA,CAAe,kBAAA,GAAqB,YAAY,SAAA,CAAU,kBAAA;AAC1D,IAAA,cAAA,CAAe,cAAc,QAAA,EAAU,MAAA;AAEvC,IAAA,MAAM,IAAA,GAA4B;AAAA,MAChC,OAAO,WAAA,CAAY,IAAA;AAAA,MACnB,QAAA;AAAA,MACA,cAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAM,KAAA,GAAQ,uCAAA,CAAwC,cAAA,CAAe,WAAW,CAAA;AAEhF,IAAA,aAAA;AAAA,MACE;AAAA,QACE,QAAA,EAAU,OAAA;AAAA,QACV,IAAA,EAAM,cAAA;AAAA,QACN,IAAA,EAAM,MAAA;AAAA,QACN;AAAA,OACF;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF;;;;"}
@@ -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 * @deprecated Use the `@sentry/hono` package instead. The `sentry()` middleware from `@sentry/hono/cloudflare`\n * handles error capturing automatically without needing this integration.\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;AAiBO,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
+ {"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' as const;\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 * @deprecated Use the `@sentry/hono` package instead. The `sentry()` middleware from `@sentry/hono/cloudflare`\n * handles error capturing automatically without needing this integration.\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;AAiBO,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 +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 // TODO(v11): Gate incoming request body capture on `dataCollection.httpBodies` (capture only when\n // `'incomingRequest'` is listed) instead of defaulting to `'medium'`.\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;AAIA,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
+ {"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' as const;\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 // TODO(v11): Gate incoming request body capture on `dataCollection.httpBodies` (capture only when\n // `'incomingRequest'` is listed) instead of defaulting to `'medium'`.\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;AAIA,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;;;;"}
@@ -0,0 +1,16 @@
1
+ export { prismaIntegration } from '@sentry/node';
2
+ export { vercelAIIntegration } from './integrations/tracing/vercelai.js';
3
+ export { CloudflareClient } from '../client.js';
4
+ export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, bindScopeToEmitter, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, close, consoleIntegration, consoleLoggingIntegration, continueTrace, createConsolaReporter, createLangChainCallbackHandler, createTransport, dedupeIntegration, eventFiltersIntegration, extraErrorDataIntegration, featureFlagsIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, growthbookIntegration, inboundFiltersIntegration, instrumentAnthropicAiClient, instrumentCreateReactAgent, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentLangGraph, instrumentOpenAiClient, instrumentPostgresJsSql, instrumentSupabaseClient, isEnabled, isInitialized, lastEventId, linkedErrorsIntegration, logger, metrics, moduleMetadataIntegration, requestDataIntegration, rewriteFramesIntegration, setAttribute, setAttributes, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSpan, startSpanManual, supabaseIntegration, suppressTracing, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, withStreamedSpan, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/core';
5
+ export { fetchIntegration } from '../integrations/fetch.js';
6
+ export { getDefaultIntegrations } from '../sdk.js';
7
+ export { honoIntegration } from '../integrations/hono.js';
8
+ export { httpServerIntegration } from '../integrations/httpServer.js';
9
+ export { instrumentD1WithSentry } from '../instrumentations/worker/instrumentD1.js';
10
+ export { instrumentDurableObjectWithSentry } from '../durableobject.js';
11
+ export { instrumentWorkflowWithSentry } from '../workflows.js';
12
+ export { sentryPagesPlugin } from '../pages-plugin.js';
13
+ export { setAsyncLocalStorageAsyncContextStrategy } from '../async.js';
14
+ export { withSentry } from '../withSentry.js';
15
+ export { wrapRequestHandler } from '../request.js';
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -0,0 +1,16 @@
1
+ import { defineIntegration } from '@sentry/core';
2
+ import { vercelAiIntegration } from '@sentry/server-utils';
3
+ import { vercelAIIntegration as vercelAIIntegration$1 } from '../../../integrations/tracing/vercelai.js';
4
+
5
+ const _vercelAIIntegration = ((options = {}) => {
6
+ const inner = vercelAiIntegration(options);
7
+ const instrumentation = vercelAIIntegration$1(options);
8
+ return {
9
+ ...inner,
10
+ ...instrumentation
11
+ };
12
+ });
13
+ const vercelAIIntegration = defineIntegration(_vercelAIIntegration);
14
+
15
+ export { vercelAIIntegration };
16
+ //# sourceMappingURL=vercelai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercelai.js","sources":["../../../../../src/nodejs_compat/integrations/tracing/vercelai.ts"],"sourcesContent":["/**\n * This is a copy of the Vercel AI integration from the Cloudflare SDK (src/integrations/tracing/vercelai.ts).\n *\n * The only difference is that it includes tracing channel support\n * because the default Vercel AI integration needs `nodejs_als`, while this one uses `nodejs_compat`.\n */\n\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { vercelAiIntegration as serverUtilsVercelAiIntegration } from '@sentry/server-utils';\nimport { vercelAIIntegration as cloudflareVercelAIIntegration } from '../../../integrations/tracing/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 const inner = serverUtilsVercelAiIntegration(options);\n const instrumentation = cloudflareVercelAIIntegration(options);\n\n return {\n ...inner,\n ...instrumentation,\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":["serverUtilsVercelAiIntegration","cloudflareVercelAIIntegration"],"mappings":";;;;AAoBA,MAAM,oBAAA,IAAwB,CAAC,OAAA,GAA2B,EAAC,KAAM;AAC/D,EAAA,MAAM,KAAA,GAAQA,oBAA+B,OAAO,CAAA;AACpD,EAAA,MAAM,eAAA,GAAkBC,sBAA8B,OAAO,CAAA;AAE7D,EAAA,OAAO;AAAA,IACL,GAAG,KAAA;AAAA,IACH,GAAG;AAAA,GACL;AACF,CAAA,CAAA;AA4BO,MAAM,mBAAA,GAAsB,kBAAkB,oBAAoB;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"10.62.0","sideEffects":false}
1
+ {"type":"module","version":"10.64.0","sideEffects":false}
package/build/esm/sdk.js CHANGED
@@ -1,4 +1,4 @@
1
- import { dedupeIntegration, inboundFiltersIntegration, functionToStringIntegration, conversationIdIntegration, linkedErrorsIntegration, requestDataIntegration, consoleIntegration, getIntegrationsToSetup, spanStreamingIntegration, stackParserFromStackParserOptions, initAndBind } from '@sentry/core';
1
+ import { dedupeIntegration, inboundFiltersIntegration, functionToStringIntegration, conversationIdIntegration, linkedErrorsIntegration, requestDataIntegration, consoleIntegration, getIntegrationsToSetup, stackParserFromStackParserOptions, initAndBind } from '@sentry/core';
2
2
  import { CloudflareClient } from './client.js';
3
3
  import { makeFlushLock } from './flush.js';
4
4
  import { httpServerIntegration } from './integrations/httpServer.js';
@@ -34,14 +34,10 @@ function init(options) {
34
34
  }
35
35
  const flushLock = options.ctx ? makeFlushLock(options.ctx) : void 0;
36
36
  delete options.ctx;
37
- const resolvedIntegrations = getIntegrationsToSetup(options);
38
- if (options.traceLifecycle === "stream" && !resolvedIntegrations.some((i) => i.name === "SpanStreaming")) {
39
- resolvedIntegrations.push(spanStreamingIntegration());
40
- }
41
37
  const clientOptions = {
42
38
  ...options,
43
39
  stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),
44
- integrations: resolvedIntegrations,
40
+ integrations: getIntegrationsToSetup(options),
45
41
  transport: options.transport || makeCloudflareTransport,
46
42
  flushLock
47
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {\n consoleIntegration,\n conversationIdIntegration,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n spanStreamingIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\nimport { makeFlushLock } from './flush';\nimport { httpServerIntegration } from './integrations/httpServer';\nimport { fetchIntegration } from './integrations/fetch';\nimport { honoIntegration } from './integrations/hono';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/** Get the default integrations for the Cloudflare SDK. */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n // TODO(v11): Drop this transitional gating and let `requestDataIntegration` rely on the resolved\n // `dataCollection` defaults directly. Until then, preserve the historical Cloudflare behavior of not\n // attaching cookies unless the user explicitly opts in via `sendDefaultPii` or `dataCollection.cookies`.\n // eslint-disable-next-line typescript/no-deprecated\n const cookiesEnabled = options.sendDefaultPii || options.dataCollection?.cookies != null;\n return [\n // The Dedupe integration should not be used in workflows because we want to\n // capture all step failures, even if they are the same error.\n ...(options.enableDedupe === false ? [] : [dedupeIntegration()]),\n // TODO(v11): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line typescript/no-deprecated\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n // eslint-disable-next-line typescript/no-deprecated\n honoIntegration(),\n httpServerIntegration(),\n requestDataIntegration(cookiesEnabled ? undefined : { include: { cookies: false } }),\n consoleIntegration(),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n const flushLock = options.ctx ? makeFlushLock(options.ctx) : undefined;\n delete options.ctx;\n\n const resolvedIntegrations = getIntegrationsToSetup(options);\n if (options.traceLifecycle === 'stream' && !resolvedIntegrations.some(i => i.name === 'SpanStreaming')) {\n resolvedIntegrations.push(spanStreamingIntegration());\n }\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: resolvedIntegrations,\n transport: options.transport || makeCloudflareTransport,\n flushLock,\n };\n\n /**\n * The Cloudflare SDK is not OpenTelemetry native, however, we set up some OpenTelemetry compatibility\n * via a custom trace provider.\n * This ensures that any spans emitted via `@opentelemetry/api` will be captured by Sentry.\n * HOWEVER, big caveat: This does not handle custom context handling, it will always work off the current scope.\n * This should be good enough for many, but not all integrations.\n */\n if (!options.skipOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAyBO,SAAS,uBAAuB,OAAA,EAA2C;AAKhF,EAAA,MAAM,cAAA,GAAiB,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,gBAAgB,OAAA,IAAW,IAAA;AACpF,EAAA,OAAO;AAAA;AAAA;AAAA,IAGL,GAAI,QAAQ,YAAA,KAAiB,KAAA,GAAQ,EAAC,GAAI,CAAC,mBAAmB,CAAA;AAAA;AAAA;AAAA,IAG9D,yBAAA,EAA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a,CAAA;AACpD;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {\n consoleIntegration,\n conversationIdIntegration,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\nimport { makeFlushLock } from './flush';\nimport { httpServerIntegration } from './integrations/httpServer';\nimport { fetchIntegration } from './integrations/fetch';\nimport { honoIntegration } from './integrations/hono';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/** Get the default integrations for the Cloudflare SDK. */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n // TODO(v11): Drop this transitional gating and let `requestDataIntegration` rely on the resolved\n // `dataCollection` defaults directly. Until then, preserve the historical Cloudflare behavior of not\n // attaching cookies unless the user explicitly opts in via `sendDefaultPii` or `dataCollection.cookies`.\n // eslint-disable-next-line typescript/no-deprecated\n const cookiesEnabled = options.sendDefaultPii || options.dataCollection?.cookies != null;\n return [\n // The Dedupe integration should not be used in workflows because we want to\n // capture all step failures, even if they are the same error.\n ...(options.enableDedupe === false ? [] : [dedupeIntegration()]),\n // TODO(v11): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line typescript/no-deprecated\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n // eslint-disable-next-line typescript/no-deprecated\n honoIntegration(),\n httpServerIntegration(),\n requestDataIntegration(cookiesEnabled ? undefined : { include: { cookies: false } }),\n consoleIntegration(),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n const flushLock = options.ctx ? makeFlushLock(options.ctx) : undefined;\n delete options.ctx;\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeCloudflareTransport,\n flushLock,\n };\n\n /**\n * The Cloudflare SDK is not OpenTelemetry native, however, we set up some OpenTelemetry compatibility\n * via a custom trace provider.\n * This ensures that any spans emitted via `@opentelemetry/api` will be captured by Sentry.\n * HOWEVER, big caveat: This does not handle custom context handling, it will always work off the current scope.\n * This should be good enough for many, but not all integrations.\n */\n if (!options.skipOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAwBO,SAAS,uBAAuB,OAAA,EAA2C;AAKhF,EAAA,MAAM,cAAA,GAAiB,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,gBAAgB,OAAA,IAAW,IAAA;AACpF,EAAA,OAAO;AAAA;AAAA;AAAA,IAGL,GAAI,QAAQ,YAAA,KAAiB,KAAA,GAAQ,EAAC,GAAI,CAAC,mBAAmB,CAAA;AAAA;AAAA;AAAA,IAG9D,yBAAA,EAA0B;AAAA,IAC1B,2BAAA,EAA4B;AAAA,IAC5B,yBAAA,EAA0B;AAAA,IAC1B,uBAAA,EAAwB;AAAA,IACxB,gBAAA,EAAiB;AAAA;AAAA,IAEjB,eAAA,EAAgB;AAAA,IAChB,qBAAA,EAAsB;AAAA,IACtB,sBAAA,CAAuB,iBAAiB,MAAA,GAAY,EAAE,SAAS,EAAE,OAAA,EAAS,KAAA,EAAM,EAAG,CAAA;AAAA,IACnF,kBAAA;AAAmB,GACrB;AACF;AAKO,SAAS,KAAK,OAAA,EAA0D;AAC7E,EAAA,IAAI,OAAA,CAAQ,wBAAwB,MAAA,EAAW;AAC7C,IAAA,OAAA,CAAQ,mBAAA,GAAsB,uBAAuB,OAAO,CAAA;AAAA,EAC9D;AAEA,EAAA,MAAM,YAAY,OAAA,CAAQ,GAAA,GAAM,aAAA,CAAc,OAAA,CAAQ,GAAG,CAAA,GAAI,MAAA;AAC7D,EAAA,OAAO,OAAA,CAAQ,GAAA;AAEf,EAAA,MAAM,aAAA,GAAyC;AAAA,IAC7C,GAAG,OAAA;AAAA,IACH,WAAA,EAAa,iCAAA,CAAkC,OAAA,CAAQ,WAAA,IAAe,kBAAkB,CAAA;AAAA,IACxF,YAAA,EAAc,uBAAuB,OAAO,CAAA;AAAA,IAC5C,SAAA,EAAW,QAAQ,SAAA,IAAa,uBAAA;AAAA,IAChC;AAAA,GACF;AASA,EAAA,IAAI,CAAC,QAAQ,sBAAA,EAAwB;AACnC,IAAA,wBAAA,EAAyB;AAAA,EAC3B;AAEA,EAAA,OAAO,WAAA,CAAY,kBAAkB,aAAa,CAAA;AACpD;;;;"}
@@ -2,7 +2,7 @@
2
2
  * Sets the async context strategy to use AsyncLocalStorage.
3
3
  *
4
4
  * AsyncLocalStorage is only available in the cloudflare workers runtime if you set
5
- * compatibility_flags = ["nodejs_compat"] or compatibility_flags = ["nodejs_als"]
5
+ * compatibility_flags = ["nodejs_compat"]
6
6
  *
7
7
  * @internal Only exported to be used in higher-level Sentry packages
8
8
  * @hidden Only exported to be used in higher-level Sentry packages
@@ -32,6 +32,11 @@ export declare function makeFlushLock(context: ExecutionContext): FlushLock;
32
32
  * Flushes the client and then disposes of it to allow garbage collection.
33
33
  * This should be called at the end of each request to prevent memory leaks.
34
34
  *
35
+ * This function never rejects. On Workers, a rejected promise passed to
36
+ * `ctx.waitUntil` marks the whole invocation as `outcome: exception` even when
37
+ * the handler itself completed successfully. Since flush/dispose is internal
38
+ * SDK housekeeping, a failure here must not fail the user's invocation.
39
+ *
35
40
  * @param client - The CloudflareClient instance to flush and dispose
36
41
  * @param timeout - Timeout in milliseconds for the flush operation
37
42
  * @returns A promise that resolves when flush and dispose are complete
@@ -1 +1 @@
1
- {"version":3,"file":"flush.d.ts","sourceRoot":"","sources":["../../src/flush.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC,CAAC;AAcF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,WAAW,CAAC,GAAG,SAAS,CAKzG;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CA8BlE;AAoCD;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAS/F"}
1
+ {"version":3,"file":"flush.d.ts","sourceRoot":"","sources":["../../src/flush.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC,CAAC;AAcF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,WAAW,CAAC,GAAG,SAAS,CAKzG;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CA8BlE;AAoCD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB/F"}
@@ -13,5 +13,7 @@ export interface Options {
13
13
  /**
14
14
  * Creates spans and attaches tracing headers to fetch requests.
15
15
  */
16
- export declare const fetchIntegration: (options?: Partial<Options> | undefined) => import("@sentry/core").Integration;
16
+ export declare const fetchIntegration: (options?: Partial<Options> | undefined) => import("@sentry/core").Integration & {
17
+ name: "Fetch";
18
+ };
17
19
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/integrations/fetch.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,0BAA0B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CACvD;AAiFD;;GAEG;AACH,eAAO,MAAM,gBAAgB,gFAAuC,CAAC"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/integrations/fetch.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,0BAA0B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CACvD;AAiFD;;GAEG;AACH,eAAO,MAAM,gBAAgB;;CAAuC,CAAC"}
@@ -17,7 +17,7 @@ export interface Options {
17
17
  /** Only exported for internal use */
18
18
  export declare function getHonoIntegration(): ReturnType<typeof _honoIntegration> | undefined;
19
19
  declare const _honoIntegration: (options?: Partial<Options>) => {
20
- name: string;
20
+ name: "Hono";
21
21
  handleHonoException(err: HonoError, context: HonoContext): void;
22
22
  };
23
23
  /**
@@ -35,6 +35,8 @@ declare const _honoIntegration: (options?: Partial<Options>) => {
35
35
  * })
36
36
  * ]
37
37
  */
38
- export declare const honoIntegration: (options?: Partial<Options> | undefined) => import("@sentry/core").Integration;
38
+ export declare const honoIntegration: (options?: Partial<Options> | undefined) => import("@sentry/core").Integration & {
39
+ name: "Hono";
40
+ };
39
41
  export {};
40
42
  //# sourceMappingURL=hono.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../../src/integrations/hono.ts"],"names":[],"mappings":"AAeA,UAAU,SAAU,SAAQ,KAAK;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAED,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,iBAAiB,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;CAC3D;AAED,qCAAqC;AACrC,wBAAgB,kBAAkB,IAAI,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAAG,SAAS,CAEpF;AAYD,QAAA,MAAM,gBAAgB,aAAc,OAAO,CAAC,OAAO,CAAC;;6BAIvB,SAAS,WAAW,WAAW,GAAG,IAAI;CA2BzC,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,gFAAsC,CAAC"}
1
+ {"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../../src/integrations/hono.ts"],"names":[],"mappings":"AAeA,UAAU,SAAU,SAAQ,KAAK;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAED,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,iBAAiB,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;CAC3D;AAED,qCAAqC;AACrC,wBAAgB,kBAAkB,IAAI,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAAG,SAAS,CAEpF;AAYD,QAAA,MAAM,gBAAgB,aAAc,OAAO,CAAC,OAAO,CAAC;;6BAIvB,SAAS,WAAW,WAAW,GAAG,IAAI;CA2BzC,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe;;CAAsC,CAAC"}
@@ -52,7 +52,9 @@ export interface HttpServerIntegrationOptions {
52
52
  * });
53
53
  * ```
54
54
  */
55
- export declare const httpServerIntegration: (options?: HttpServerIntegrationOptions | undefined) => import("@sentry/core").Integration;
55
+ export declare const httpServerIntegration: (options?: HttpServerIntegrationOptions | undefined) => import("@sentry/core").Integration & {
56
+ name: string;
57
+ };
56
58
  /**
57
59
  * Capture the request body based on the HttpServer integration config.
58
60
  * Called internally by `wrapRequestHandler`.
@@ -1 +1 @@
1
- {"version":3,"file":"httpServer.d.ts","sourceRoot":"","sources":["../../../src/integrations/httpServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAiB,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAK9E,MAAM,WAAW,4BAA4B;IAC3C;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC;;;;;;;;;;;;;;;OAeG;IACH,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;CAChE;AAgBD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,4FAA4C,CAAC;AAE/E;;;GAGG;AACH,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BhG"}
1
+ {"version":3,"file":"httpServer.d.ts","sourceRoot":"","sources":["../../../src/integrations/httpServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAiB,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAK9E,MAAM,WAAW,4BAA4B;IAC3C;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC;;;;;;;;;;;;;;;OAeG;IACH,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;CAChE;AAgBD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB;;CAA4C,CAAC;AAE/E;;;GAGG;AACH,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BhG"}
@@ -40,6 +40,8 @@ interface VercelAiOptions {
40
40
  * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },
41
41
  * });
42
42
  */
43
- export declare const vercelAIIntegration: (options?: VercelAiOptions | undefined) => import("@sentry/core").Integration;
43
+ export declare const vercelAIIntegration: (options?: VercelAiOptions | undefined) => import("@sentry/core").Integration & {
44
+ name: string;
45
+ };
44
46
  export {};
45
47
  //# sourceMappingURL=vercelai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vercelai.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/vercelai.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,UAAU,eAAe;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,mBAAmB,+EAA0C,CAAC"}
1
+ {"version":3,"file":"vercelai.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/vercelai.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,UAAU,eAAe;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,mBAAmB;;CAA0C,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from '../index';
2
+ export { prismaIntegration } from '@sentry/node';
3
+ export { vercelAIIntegration } from './integrations/tracing/vercelai';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/nodejs_compat/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * This is a copy of the Vercel AI integration from the Cloudflare SDK (src/integrations/tracing/vercelai.ts).
3
+ *
4
+ * The only difference is that it includes tracing channel support
5
+ * because the default Vercel AI integration needs `nodejs_als`, while this one uses `nodejs_compat`.
6
+ */
7
+ interface VercelAiOptions {
8
+ /**
9
+ * Enable or disable truncation of recorded input messages.
10
+ * Defaults to `true`.
11
+ */
12
+ enableTruncation?: boolean;
13
+ }
14
+ /**
15
+ * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
16
+ * This integration is not enabled by default, you need to manually add it.
17
+ *
18
+ * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
19
+ *
20
+ * You need to enable collecting spans for a specific call by setting
21
+ * `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
22
+ *
23
+ * ```javascript
24
+ * const result = await generateText({
25
+ * model: openai('gpt-4-turbo'),
26
+ * experimental_telemetry: { isEnabled: true },
27
+ * });
28
+ * ```
29
+ *
30
+ * If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each
31
+ * function call by setting `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs`
32
+ * to `true`.
33
+ *
34
+ * ```javascript
35
+ * const result = await generateText({
36
+ * model: openai('gpt-4-turbo'),
37
+ * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },
38
+ * });
39
+ */
40
+ export declare const vercelAIIntegration: (options?: VercelAiOptions | undefined) => import("@sentry/core").Integration & {
41
+ name: string;
42
+ };
43
+ export {};
44
+ //# sourceMappingURL=vercelai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercelai.d.ts","sourceRoot":"","sources":["../../../../../src/nodejs_compat/integrations/tracing/vercelai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,UAAU,eAAe;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,mBAAmB;;CAA0C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAchD,OAAO,KAAK,EAA2B,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAS5C,2DAA2D;AAC3D,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,EAAE,CAuBhF;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,SAAS,CAiC7E"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAahD,OAAO,KAAK,EAA2B,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAS5C,2DAA2D;AAC3D,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,EAAE,CAuBhF;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,SAAS,CA4B7E"}
@@ -2,7 +2,7 @@
2
2
  * Sets the async context strategy to use AsyncLocalStorage.
3
3
  *
4
4
  * AsyncLocalStorage is only available in the cloudflare workers runtime if you set
5
- * compatibility_flags = ["nodejs_compat"] or compatibility_flags = ["nodejs_als"]
5
+ * compatibility_flags = ["nodejs_compat"]
6
6
  *
7
7
  * @internal Only exported to be used in higher-level Sentry packages
8
8
  * @hidden Only exported to be used in higher-level Sentry packages
@@ -32,6 +32,11 @@ export declare function makeFlushLock(context: ExecutionContext): FlushLock;
32
32
  * Flushes the client and then disposes of it to allow garbage collection.
33
33
  * This should be called at the end of each request to prevent memory leaks.
34
34
  *
35
+ * This function never rejects. On Workers, a rejected promise passed to
36
+ * `ctx.waitUntil` marks the whole invocation as `outcome: exception` even when
37
+ * the handler itself completed successfully. Since flush/dispose is internal
38
+ * SDK housekeeping, a failure here must not fail the user's invocation.
39
+ *
35
40
  * @param client - The CloudflareClient instance to flush and dispose
36
41
  * @param timeout - Timeout in milliseconds for the flush operation
37
42
  * @returns A promise that resolves when flush and dispose are complete
@@ -13,5 +13,7 @@ export interface Options {
13
13
  /**
14
14
  * Creates spans and attaches tracing headers to fetch requests.
15
15
  */
16
- export declare const fetchIntegration: (options?: Partial<Options> | undefined) => import("@sentry/core").Integration;
16
+ export declare const fetchIntegration: (options?: Partial<Options> | undefined) => import("@sentry/core").Integration & {
17
+ name: "Fetch";
18
+ };
17
19
  //# sourceMappingURL=fetch.d.ts.map
@@ -17,7 +17,7 @@ export interface Options {
17
17
  /** Only exported for internal use */
18
18
  export declare function getHonoIntegration(): ReturnType<typeof _honoIntegration> | undefined;
19
19
  declare const _honoIntegration: (options?: Partial<Options>) => {
20
- name: string;
20
+ name: "Hono";
21
21
  handleHonoException(err: HonoError, context: HonoContext): void;
22
22
  };
23
23
  /**
@@ -35,6 +35,8 @@ declare const _honoIntegration: (options?: Partial<Options>) => {
35
35
  * })
36
36
  * ]
37
37
  */
38
- export declare const honoIntegration: (options?: Partial<Options> | undefined) => import("@sentry/core").Integration;
38
+ export declare const honoIntegration: (options?: Partial<Options> | undefined) => import("@sentry/core").Integration & {
39
+ name: "Hono";
40
+ };
39
41
  export {};
40
42
  //# sourceMappingURL=hono.d.ts.map
@@ -52,7 +52,9 @@ export interface HttpServerIntegrationOptions {
52
52
  * });
53
53
  * ```
54
54
  */
55
- export declare const httpServerIntegration: (options?: HttpServerIntegrationOptions | undefined) => import("@sentry/core").Integration;
55
+ export declare const httpServerIntegration: (options?: HttpServerIntegrationOptions | undefined) => import("@sentry/core").Integration & {
56
+ name: string;
57
+ };
56
58
  /**
57
59
  * Capture the request body based on the HttpServer integration config.
58
60
  * Called internally by `wrapRequestHandler`.
@@ -40,6 +40,8 @@ interface VercelAiOptions {
40
40
  * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },
41
41
  * });
42
42
  */
43
- export declare const vercelAIIntegration: (options?: VercelAiOptions | undefined) => import("@sentry/core").Integration;
43
+ export declare const vercelAIIntegration: (options?: VercelAiOptions | undefined) => import("@sentry/core").Integration & {
44
+ name: string;
45
+ };
44
46
  export {};
45
47
  //# sourceMappingURL=vercelai.d.ts.map
@@ -0,0 +1,4 @@
1
+ export * from '../index';
2
+ export { prismaIntegration } from '@sentry/node';
3
+ export { vercelAIIntegration } from './integrations/tracing/vercelai';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * This is a copy of the Vercel AI integration from the Cloudflare SDK (src/integrations/tracing/vercelai.ts).
3
+ *
4
+ * The only difference is that it includes tracing channel support
5
+ * because the default Vercel AI integration needs `nodejs_als`, while this one uses `nodejs_compat`.
6
+ */
7
+ interface VercelAiOptions {
8
+ /**
9
+ * Enable or disable truncation of recorded input messages.
10
+ * Defaults to `true`.
11
+ */
12
+ enableTruncation?: boolean;
13
+ }
14
+ /**
15
+ * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
16
+ * This integration is not enabled by default, you need to manually add it.
17
+ *
18
+ * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
19
+ *
20
+ * You need to enable collecting spans for a specific call by setting
21
+ * `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
22
+ *
23
+ * ```javascript
24
+ * const result = await generateText({
25
+ * model: openai('gpt-4-turbo'),
26
+ * experimental_telemetry: { isEnabled: true },
27
+ * });
28
+ * ```
29
+ *
30
+ * If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each
31
+ * function call by setting `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs`
32
+ * to `true`.
33
+ *
34
+ * ```javascript
35
+ * const result = await generateText({
36
+ * model: openai('gpt-4-turbo'),
37
+ * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },
38
+ * });
39
+ */
40
+ export declare const vercelAIIntegration: (options?: VercelAiOptions | undefined) => import("@sentry/core").Integration & {
41
+ name: string;
42
+ };
43
+ export {};
44
+ //# sourceMappingURL=vercelai.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/cloudflare",
3
- "version": "10.62.0",
3
+ "version": "10.64.0",
4
4
  "description": "Official Sentry SDK for Cloudflare Workers and Pages",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/cloudflare",
@@ -36,6 +36,16 @@
36
36
  "types": "./build/types/request.d.ts",
37
37
  "default": "./build/cjs/request.js"
38
38
  }
39
+ },
40
+ "./nodejs_compat": {
41
+ "import": {
42
+ "types": "./build/types/nodejs_compat/index.d.ts",
43
+ "default": "./build/esm/nodejs_compat/index.js"
44
+ },
45
+ "require": {
46
+ "types": "./build/types/nodejs_compat/index.d.ts",
47
+ "default": "./build/cjs/nodejs_compat/index.js"
48
+ }
39
49
  }
40
50
  },
41
51
  "typesVersions": {
@@ -50,7 +60,9 @@
50
60
  },
51
61
  "dependencies": {
52
62
  "@opentelemetry/api": "^1.9.1",
53
- "@sentry/core": "10.62.0"
63
+ "@sentry/core": "10.64.0",
64
+ "@sentry/node": "10.64.0",
65
+ "@sentry/server-utils": "10.64.0"
54
66
  },
55
67
  "peerDependencies": {
56
68
  "@cloudflare/workers-types": "^4.x"