@sentry/cloudflare 10.47.0 → 10.49.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 (171) hide show
  1. package/build/cjs/client.js.map +1 -1
  2. package/build/cjs/durableobject.js +42 -16
  3. package/build/cjs/durableobject.js.map +1 -1
  4. package/build/cjs/index.js +3 -0
  5. package/build/cjs/index.js.map +1 -1
  6. package/build/cjs/instrument.js +72 -8
  7. package/build/cjs/instrument.js.map +1 -1
  8. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js +56 -0
  9. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  10. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +38 -3
  11. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  12. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js +101 -0
  13. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  14. package/build/cjs/instrumentations/worker/instrumentEmail.js +16 -13
  15. package/build/cjs/instrumentations/worker/instrumentEmail.js.map +1 -1
  16. package/build/cjs/instrumentations/worker/instrumentEnv.js +83 -0
  17. package/build/cjs/instrumentations/worker/instrumentEnv.js.map +1 -0
  18. package/build/cjs/instrumentations/worker/instrumentFetch.js +36 -10
  19. package/build/cjs/instrumentations/worker/instrumentFetch.js.map +1 -1
  20. package/build/cjs/instrumentations/worker/instrumentFetcher.js +38 -0
  21. package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +1 -0
  22. package/build/cjs/instrumentations/worker/instrumentQueue.js +36 -10
  23. package/build/cjs/instrumentations/worker/instrumentQueue.js.map +1 -1
  24. package/build/cjs/instrumentations/worker/instrumentScheduled.js +36 -13
  25. package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +1 -1
  26. package/build/cjs/instrumentations/worker/instrumentTail.js +34 -10
  27. package/build/cjs/instrumentations/worker/instrumentTail.js.map +1 -1
  28. package/build/cjs/integrations/tracing/vercelai.js +2 -1
  29. package/build/cjs/integrations/tracing/vercelai.js.map +1 -1
  30. package/build/cjs/request.js +5 -6
  31. package/build/cjs/request.js.map +1 -1
  32. package/build/cjs/scope-utils.js.map +1 -1
  33. package/build/cjs/sdk.js +6 -1
  34. package/build/cjs/sdk.js.map +1 -1
  35. package/build/cjs/utils/instrumentContext.js +2 -1
  36. package/build/cjs/utils/instrumentContext.js.map +1 -1
  37. package/build/cjs/utils/isBinding.js +32 -0
  38. package/build/cjs/utils/isBinding.js.map +1 -0
  39. package/build/cjs/utils/isCloudflareClass.js +29 -0
  40. package/build/cjs/utils/isCloudflareClass.js.map +1 -0
  41. package/build/cjs/utils/rpcOptions.js +84 -0
  42. package/build/cjs/utils/rpcOptions.js.map +1 -0
  43. package/build/cjs/utils/traceLinks.js +78 -0
  44. package/build/cjs/utils/traceLinks.js.map +1 -0
  45. package/build/cjs/withSentry.js +31 -20
  46. package/build/cjs/withSentry.js.map +1 -1
  47. package/build/cjs/workflows.js +3 -2
  48. package/build/cjs/workflows.js.map +1 -1
  49. package/build/cjs/wrapMethodWithSentry.js +157 -112
  50. package/build/cjs/wrapMethodWithSentry.js.map +1 -1
  51. package/build/esm/client.js.map +1 -1
  52. package/build/esm/durableobject.js +43 -17
  53. package/build/esm/durableobject.js.map +1 -1
  54. package/build/esm/index.js +1 -1
  55. package/build/esm/instrument.js +71 -8
  56. package/build/esm/instrument.js.map +1 -1
  57. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js +54 -0
  58. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  59. package/build/esm/instrumentations/instrumentDurableObjectStorage.js +39 -4
  60. package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  61. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js +99 -0
  62. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  63. package/build/esm/instrumentations/worker/instrumentEmail.js +17 -14
  64. package/build/esm/instrumentations/worker/instrumentEmail.js.map +1 -1
  65. package/build/esm/instrumentations/worker/instrumentEnv.js +81 -0
  66. package/build/esm/instrumentations/worker/instrumentEnv.js.map +1 -0
  67. package/build/esm/instrumentations/worker/instrumentFetch.js +37 -12
  68. package/build/esm/instrumentations/worker/instrumentFetch.js.map +1 -1
  69. package/build/esm/instrumentations/worker/instrumentFetcher.js +36 -0
  70. package/build/esm/instrumentations/worker/instrumentFetcher.js.map +1 -0
  71. package/build/esm/instrumentations/worker/instrumentQueue.js +37 -12
  72. package/build/esm/instrumentations/worker/instrumentQueue.js.map +1 -1
  73. package/build/esm/instrumentations/worker/instrumentScheduled.js +37 -15
  74. package/build/esm/instrumentations/worker/instrumentScheduled.js.map +1 -1
  75. package/build/esm/instrumentations/worker/instrumentTail.js +35 -12
  76. package/build/esm/instrumentations/worker/instrumentTail.js.map +1 -1
  77. package/build/esm/integrations/tracing/vercelai.js +2 -1
  78. package/build/esm/integrations/tracing/vercelai.js.map +1 -1
  79. package/build/esm/package.json +1 -1
  80. package/build/esm/request.js +5 -6
  81. package/build/esm/request.js.map +1 -1
  82. package/build/esm/scope-utils.js.map +1 -1
  83. package/build/esm/sdk.js +7 -2
  84. package/build/esm/sdk.js.map +1 -1
  85. package/build/esm/utils/instrumentContext.js +2 -1
  86. package/build/esm/utils/instrumentContext.js.map +1 -1
  87. package/build/esm/utils/isBinding.js +29 -0
  88. package/build/esm/utils/isBinding.js.map +1 -0
  89. package/build/esm/utils/isCloudflareClass.js +27 -0
  90. package/build/esm/utils/isCloudflareClass.js.map +1 -0
  91. package/build/esm/utils/rpcOptions.js +81 -0
  92. package/build/esm/utils/rpcOptions.js.map +1 -0
  93. package/build/esm/utils/traceLinks.js +73 -0
  94. package/build/esm/utils/traceLinks.js.map +1 -0
  95. package/build/esm/withSentry.js +32 -21
  96. package/build/esm/withSentry.js.map +1 -1
  97. package/build/esm/workflows.js +3 -2
  98. package/build/esm/workflows.js.map +1 -1
  99. package/build/esm/wrapMethodWithSentry.js +159 -114
  100. package/build/esm/wrapMethodWithSentry.js.map +1 -1
  101. package/build/types/client.d.ts +39 -10
  102. package/build/types/client.d.ts.map +1 -1
  103. package/build/types/durableobject.d.ts.map +1 -1
  104. package/build/types/index.d.ts +1 -1
  105. package/build/types/index.d.ts.map +1 -1
  106. package/build/types/instrument.d.ts +15 -4
  107. package/build/types/instrument.d.ts.map +1 -1
  108. package/build/types/instrumentations/instrumentDurableObjectNamespace.d.ts +12 -0
  109. package/build/types/instrumentations/instrumentDurableObjectNamespace.d.ts.map +1 -0
  110. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts +8 -1
  111. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
  112. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +42 -0
  113. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -0
  114. package/build/types/instrumentations/worker/instrumentEmail.d.ts +2 -1
  115. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  116. package/build/types/instrumentations/worker/instrumentEnv.d.ts +16 -0
  117. package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -0
  118. package/build/types/instrumentations/worker/instrumentFetch.d.ts +6 -1
  119. package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
  120. package/build/types/instrumentations/worker/instrumentFetcher.d.ts +10 -0
  121. package/build/types/instrumentations/worker/instrumentFetcher.d.ts.map +1 -0
  122. package/build/types/instrumentations/worker/instrumentQueue.d.ts +6 -1
  123. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  124. package/build/types/instrumentations/worker/instrumentScheduled.d.ts +6 -1
  125. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  126. package/build/types/instrumentations/worker/instrumentTail.d.ts +6 -1
  127. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  128. package/build/types/integrations/tracing/vercelai.d.ts +9 -1
  129. package/build/types/integrations/tracing/vercelai.d.ts.map +1 -1
  130. package/build/types/request.d.ts +3 -3
  131. package/build/types/request.d.ts.map +1 -1
  132. package/build/types/scope-utils.d.ts +2 -2
  133. package/build/types/scope-utils.d.ts.map +1 -1
  134. package/build/types/sdk.d.ts.map +1 -1
  135. package/build/types/utils/instrumentContext.d.ts.map +1 -1
  136. package/build/types/utils/isBinding.d.ts +49 -0
  137. package/build/types/utils/isBinding.d.ts.map +1 -0
  138. package/build/types/utils/isCloudflareClass.d.ts +30 -0
  139. package/build/types/utils/isCloudflareClass.d.ts.map +1 -0
  140. package/build/types/utils/rpcOptions.d.ts +24 -0
  141. package/build/types/utils/rpcOptions.d.ts.map +1 -0
  142. package/build/types/utils/traceLinks.d.ts +27 -0
  143. package/build/types/utils/traceLinks.d.ts.map +1 -0
  144. package/build/types/withSentry.d.ts +3 -2
  145. package/build/types/withSentry.d.ts.map +1 -1
  146. package/build/types/workflows.d.ts.map +1 -1
  147. package/build/types/wrapMethodWithSentry.d.ts +19 -2
  148. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  149. package/build/types-ts3.8/client.d.ts +39 -10
  150. package/build/types-ts3.8/index.d.ts +1 -1
  151. package/build/types-ts3.8/instrument.d.ts +15 -4
  152. package/build/types-ts3.8/instrumentations/instrumentDurableObjectNamespace.d.ts +12 -0
  153. package/build/types-ts3.8/instrumentations/instrumentDurableObjectStorage.d.ts +8 -1
  154. package/build/types-ts3.8/instrumentations/instrumentWorkerEntrypoint.d.ts +42 -0
  155. package/build/types-ts3.8/instrumentations/worker/instrumentEmail.d.ts +2 -1
  156. package/build/types-ts3.8/instrumentations/worker/instrumentEnv.d.ts +16 -0
  157. package/build/types-ts3.8/instrumentations/worker/instrumentFetch.d.ts +6 -1
  158. package/build/types-ts3.8/instrumentations/worker/instrumentFetcher.d.ts +10 -0
  159. package/build/types-ts3.8/instrumentations/worker/instrumentQueue.d.ts +6 -1
  160. package/build/types-ts3.8/instrumentations/worker/instrumentScheduled.d.ts +6 -1
  161. package/build/types-ts3.8/instrumentations/worker/instrumentTail.d.ts +6 -1
  162. package/build/types-ts3.8/integrations/tracing/vercelai.d.ts +9 -1
  163. package/build/types-ts3.8/request.d.ts +3 -3
  164. package/build/types-ts3.8/scope-utils.d.ts +2 -2
  165. package/build/types-ts3.8/utils/isBinding.d.ts +49 -0
  166. package/build/types-ts3.8/utils/isCloudflareClass.d.ts +30 -0
  167. package/build/types-ts3.8/utils/rpcOptions.d.ts +24 -0
  168. package/build/types-ts3.8/utils/traceLinks.d.ts +27 -0
  169. package/build/types-ts3.8/withSentry.d.ts +3 -2
  170. package/build/types-ts3.8/wrapMethodWithSentry.d.ts +19 -2
  171. package/package.json +2 -2
@@ -0,0 +1,16 @@
1
+ import { CloudflareOptions } from '../../client';
2
+ /**
3
+ * Wraps the Cloudflare `env` object in a Proxy that detects binding types
4
+ * on property access and returns instrumented versions.
5
+ *
6
+ * Currently detects:
7
+ * - DurableObjectNamespace (via `idFromName` duck-typing)
8
+ * - Service bindings / JSRPC proxies (wraps `fetch` for trace propagation)
9
+ *
10
+ * Extensible for future binding types (KV, D1, Queue, etc.).
11
+ *
12
+ * @param env - The Cloudflare env object to instrument
13
+ * @param options - Optional CloudflareOptions to control RPC trace propagation
14
+ */
15
+ export declare function instrumentEnv<Env extends Record<string, unknown>>(env: Env, options?: CloudflareOptions): Env;
16
+ //# sourceMappingURL=instrumentEnv.d.ts.map
@@ -1,7 +1,12 @@
1
1
  import { ExportedHandler } from '@cloudflare/workers-types';
2
+ import { env as cloudflareEnv, WorkerEntrypoint } from 'cloudflare:workers';
2
3
  import { CloudflareOptions } from '../../client';
3
4
  /**
4
5
  * Instruments a fetch handler for ExportedHandler (env/ctx come from args).
5
6
  */
6
- export declare function instrumentExportedHandlerFetch<T extends ExportedHandler<any, any, any>>(handler: T, optionsCallback: (env: Parameters<NonNullable<T['fetch']>>[1]) => CloudflareOptions | undefined): void;
7
+ export declare function instrumentExportedHandlerFetch<T extends ExportedHandler<any, any, any>>(handler: T, optionsCallback: (env: typeof cloudflareEnv) => CloudflareOptions | undefined): void;
8
+ /**
9
+ * Instruments a fetch method for WorkerEntrypoint (options/context already available).
10
+ */
11
+ export declare function instrumentWorkerEntrypointFetch<T extends WorkerEntrypoint>(instance: T, options: CloudflareOptions, context: ExecutionContext): void;
7
12
  //# sourceMappingURL=instrumentFetch.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { Fetcher } from '@cloudflare/workers-types';
2
+ /**
3
+ * Wraps a fetch-like function to create a span and propagate trace headers
4
+ * (`sentry-trace` and `baggage`) on the outgoing request.
5
+ *
6
+ * Useful for instrumenting Cloudflare bindings that expose a `fetch` method
7
+ * (e.g. Durable Object stubs, Service bindings).
8
+ */
9
+ export declare function instrumentFetcher(fetchFn: Fetcher['fetch']): Fetcher['fetch'];
10
+ //# sourceMappingURL=instrumentFetcher.d.ts.map
@@ -1,7 +1,12 @@
1
1
  import { ExportedHandler } from '@cloudflare/workers-types';
2
+ import { env as cloudflareEnv, WorkerEntrypoint } from 'cloudflare:workers';
2
3
  import { CloudflareOptions } from '../../client';
3
4
  /**
4
5
  * Instruments a queue handler for ExportedHandler (env/ctx come from args).
5
6
  */
6
- export declare function instrumentExportedHandlerQueue<T extends ExportedHandler<any, any, any>>(handler: T, optionsCallback: (env: Parameters<NonNullable<T['queue']>>[1]) => CloudflareOptions | undefined): void;
7
+ export declare function instrumentExportedHandlerQueue<T extends ExportedHandler<any, any, any>>(handler: T, optionsCallback: (env: typeof cloudflareEnv) => CloudflareOptions | undefined): void;
8
+ /**
9
+ * Instruments a queue method for WorkerEntrypoint (options/context already available).
10
+ */
11
+ export declare function instrumentWorkerEntrypointQueue<T extends WorkerEntrypoint>(instance: T, options: CloudflareOptions, context: ExecutionContext): void;
7
12
  //# sourceMappingURL=instrumentQueue.d.ts.map
@@ -1,7 +1,12 @@
1
1
  import { ExportedHandler } from '@cloudflare/workers-types';
2
+ import { env as cloudflareEnv, WorkerEntrypoint } from 'cloudflare:workers';
2
3
  import { CloudflareOptions } from '../../client';
3
4
  /**
4
5
  * Instruments a scheduled handler for ExportedHandler (env/ctx come from args).
5
6
  */
6
- export declare function instrumentExportedHandlerScheduled<T extends ExportedHandler<any, any, any>>(handler: T, optionsCallback: (env: Parameters<NonNullable<T['scheduled']>>[1]) => CloudflareOptions | undefined): void;
7
+ export declare function instrumentExportedHandlerScheduled<T extends ExportedHandler<any, any, any>>(handler: T, optionsCallback: (env: typeof cloudflareEnv) => CloudflareOptions | undefined): void;
8
+ /**
9
+ * Instruments a scheduled method for WorkerEntrypoint (options/context already available).
10
+ */
11
+ export declare function instrumentWorkerEntrypointScheduled<T extends WorkerEntrypoint>(instance: T, options: CloudflareOptions, context: ExecutionContext): void;
7
12
  //# sourceMappingURL=instrumentScheduled.d.ts.map
@@ -1,7 +1,12 @@
1
1
  import { ExportedHandler } from '@cloudflare/workers-types';
2
+ import { env as cloudflareEnv, WorkerEntrypoint } from 'cloudflare:workers';
2
3
  import { CloudflareOptions } from '../../client';
3
4
  /**
4
5
  * Instruments a tail handler for ExportedHandler (env/ctx come from args).
5
6
  */
6
- export declare function instrumentExportedHandlerTail<T extends ExportedHandler<any, any, any>>(handler: T, optionsCallback: (env: Parameters<NonNullable<T['tail']>>[1]) => CloudflareOptions | undefined): void;
7
+ export declare function instrumentExportedHandlerTail<T extends ExportedHandler<any, any, any>>(handler: T, optionsCallback: (env: typeof cloudflareEnv) => CloudflareOptions | undefined): void;
8
+ /**
9
+ * Instruments a tail method for WorkerEntrypoint (options/context already available).
10
+ */
11
+ export declare function instrumentWorkerEntrypointTail<T extends WorkerEntrypoint>(instance: T, options: CloudflareOptions, context: ExecutionContext): void;
7
12
  //# sourceMappingURL=instrumentTail.d.ts.map
@@ -7,6 +7,13 @@
7
7
  * Therefore, we cannot automatically patch setting `experimental_telemetry: { isEnabled: true }`
8
8
  * and users have to manually set this to get spans.
9
9
  */
10
+ interface VercelAiOptions {
11
+ /**
12
+ * Enable or disable truncation of recorded input messages.
13
+ * Defaults to `true`.
14
+ */
15
+ enableTruncation?: boolean;
16
+ }
10
17
  /**
11
18
  * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
12
19
  * This integration is not enabled by default, you need to manually add it.
@@ -33,5 +40,6 @@
33
40
  * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },
34
41
  * });
35
42
  */
36
- export declare const vercelAIIntegration: () => import("@sentry/core").Integration;
43
+ export declare const vercelAIIntegration: (options?: VercelAiOptions | undefined) => import("@sentry/core").Integration;
44
+ export {};
37
45
  //# sourceMappingURL=vercelai.d.ts.map
@@ -1,9 +1,9 @@
1
- import { ExecutionContext, IncomingRequestCfProperties } from '@cloudflare/workers-types';
1
+ import { CfProperties, ExecutionContext, IncomingRequestCfProperties } from '@cloudflare/workers-types';
2
2
  import { CloudflareOptions } from './client';
3
3
  interface RequestHandlerWrapperOptions {
4
4
  options: CloudflareOptions;
5
- request: Request<unknown, IncomingRequestCfProperties<unknown>>;
6
- context: ExecutionContext;
5
+ request: Request<unknown, IncomingRequestCfProperties<unknown> | CfProperties<unknown>>;
6
+ context: ExecutionContext | undefined;
7
7
  /**
8
8
  * If true, errors will be captured, rethrown and sent to Sentry.
9
9
  * Otherwise, errors are rethrown but not captured.
@@ -1,4 +1,4 @@
1
- import { IncomingRequestCfProperties } from '@cloudflare/workers-types';
1
+ import { CfProperties, IncomingRequestCfProperties } from '@cloudflare/workers-types';
2
2
  import { Scope } from '@sentry/core';
3
3
  /**
4
4
  * Set cloud resource context on scope.
@@ -7,7 +7,7 @@ export declare function addCloudResourceContext(scope: Scope): void;
7
7
  /**
8
8
  * Set culture context on scope
9
9
  */
10
- export declare function addCultureContext(scope: Scope, cf: IncomingRequestCfProperties): void;
10
+ export declare function addCultureContext(scope: Scope, cf: IncomingRequestCfProperties | CfProperties): void;
11
11
  /**
12
12
  * Set request data on scope
13
13
  */
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Adapted from https://github.com/evanderkoogh/otel-cf-workers/blob/effeb549f0a4ed1c55ea0c4f0d8e8e37e5494fb3/src/instrumentation/env.ts
3
+ *
4
+ * BSD 3-Clause License
5
+ *
6
+ * Copyright (c) 2023, Erwin van der Koogh
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without
9
+ * modification, are permitted provided that the following conditions are met:
10
+ *
11
+ * 1. Redistributions of source code must retain the above copyright notice, this
12
+ * list of conditions and the following disclaimer.
13
+ *
14
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
15
+ * this list of conditions and the following disclaimer in the documentation
16
+ * and/or other materials provided with the distribution.
17
+ *
18
+ * 3. Neither the name of the copyright holder nor the names of its
19
+ * contributors may be used to endorse or promote products derived from
20
+ * this software without specific prior written permission.
21
+ *
22
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+ import { DurableObjectNamespace } from '@cloudflare/workers-types';
34
+ /**
35
+ * Checks if a value is a JSRPC proxy (service binding).
36
+ *
37
+ * JSRPC proxies return a truthy value for ANY property access, including
38
+ * properties that don't exist. This makes other duck-type checks unreliable
39
+ * unless we exclude JSRPC first.
40
+ *
41
+ * Must be checked before other binding type checks.
42
+ */
43
+ export declare function isJSRPC(item: unknown): item is Service;
44
+ /**
45
+ * Duck-type check for DurableObjectNamespace bindings.
46
+ * DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.
47
+ */
48
+ export declare function isDurableObjectNamespace(item: unknown): item is DurableObjectNamespace;
49
+ //# sourceMappingURL=isBinding.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { DurableObject, WorkflowEntrypoint } from 'cloudflare:workers';
2
+ import { WorkerEntrypointConstructor } from '../instrumentations/instrumentWorkerEntrypoint';
3
+ /**
4
+ * Checks if a class constructor extends a specific Cloudflare base class.
5
+ *
6
+ * Uses prototype chain walking with constructor names rather than instanceof,
7
+ * so it works in Node at build time without requiring the cloudflare:workers
8
+ * module (which only exists in the Workers runtime).
9
+ *
10
+ * This is used to differentiate between different Cloudflare worker types:
11
+ * - WorkerEntrypoint: Class-based workers (used with instrumentWorkerEntrypoint)
12
+ * - DurableObject: Durable Object classes
13
+ * - Workflow: Workflow classes
14
+ *
15
+ * For ExportedHandler (plain objects), this will return false for all types.
16
+ *
17
+ * @param value - The value to check (typically a class constructor)
18
+ * @param className - The Cloudflare base class name to check against
19
+ * @returns true if the value is a class that extends the specified Cloudflare class
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * isCloudflareClass(MyWorker, 'WorkerEntrypoint') // true if MyWorker extends WorkerEntrypoint
24
+ * isCloudflareClass(MyDO, 'DurableObject') // true if MyDO extends DurableObject
25
+ * ```
26
+ */
27
+ export declare function isCloudflareClass(value: unknown, className: 'WorkerEntrypoint'): value is WorkerEntrypointConstructor;
28
+ export declare function isCloudflareClass(value: unknown, className: 'DurableObject'): value is new (...args: unknown[]) => DurableObject;
29
+ export declare function isCloudflareClass(value: unknown, className: 'WorkflowEntrypoint'): value is new (...args: unknown[]) => WorkflowEntrypoint;
30
+ //# sourceMappingURL=isCloudflareClass.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { CloudflareOptions } from '../client';
2
+ /**
3
+ * Gets the effective RPC propagation setting, handling deprecation of `instrumentPrototypeMethods`.
4
+ *
5
+ * Priority:
6
+ * 1. If `enableRpcTracePropagation` is set, use it (ignore `instrumentPrototypeMethods`)
7
+ * 2. If only `instrumentPrototypeMethods` is set, use it with deprecation warning (converted to boolean)
8
+ * 3. If neither is set, return `false`
9
+ *
10
+ * @returns The effective setting for RPC trace propagation
11
+ */
12
+ export declare function getEffectiveRpcPropagation(options: CloudflareOptions): boolean;
13
+ /**
14
+ * Gets the method filter for prototype method instrumentation.
15
+ *
16
+ * Returns:
17
+ * - `null` if no instrumentation should occur
18
+ * - `true` if all methods should be instrumented
19
+ * - `string[]` if only specific methods should be instrumented (deprecated behavior)
20
+ *
21
+ * @returns The method filter or null if no instrumentation
22
+ */
23
+ export declare function getPrototypeMethodFilter(options: CloudflareOptions): boolean | string[];
24
+ //# sourceMappingURL=rpcOptions.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { DurableObjectStorage } from '@cloudflare/workers-types';
2
+ import { SpanLink } from '@sentry/core';
3
+ /** Stored span context for creating span links */
4
+ export interface StoredSpanContext {
5
+ traceId: string;
6
+ spanId: string;
7
+ sampled: boolean;
8
+ }
9
+ /**
10
+ * Gets the storage key for a specific method's trace link.
11
+ */
12
+ export declare function getTraceLinkKey(methodName: string): string;
13
+ /**
14
+ * Stores the current span context in Durable Object storage for trace linking.
15
+ * Uses the original uninstrumented storage to avoid creating spans for internal operations.
16
+ * Errors are silently ignored to prevent internal storage failures from propagating to user code.
17
+ */
18
+ export declare function storeSpanContext(originalStorage: DurableObjectStorage, methodName: string): Promise<void>;
19
+ /**
20
+ * Retrieves a stored span context from Durable Object storage.
21
+ */
22
+ export declare function getStoredSpanContext(originalStorage: DurableObjectStorage, methodName: string): Promise<StoredSpanContext | undefined>;
23
+ /**
24
+ * Builds span links from a stored span context.
25
+ */
26
+ export declare function buildSpanLinks(storedContext: StoredSpanContext): SpanLink[];
27
+ //# sourceMappingURL=traceLinks.d.ts.map
@@ -1,5 +1,6 @@
1
- import { env } from 'cloudflare:workers';
1
+ import { env as cloudflareEnv } from 'cloudflare:workers';
2
2
  import { CloudflareOptions } from './client';
3
+ import { WorkerEntrypointConstructor } from './instrumentations/instrumentWorkerEntrypoint';
3
4
  /**
4
5
  * Wrapper for Cloudflare handlers.
5
6
  *
@@ -11,5 +12,5 @@ import { CloudflareOptions } from './client';
11
12
  * @param handler {ExportedHandler} The handler to wrap.
12
13
  * @returns The wrapped handler.
13
14
  */
14
- export declare function withSentry<Env = typeof env, QueueHandlerMessage = unknown, CfHostMetadata = unknown, T extends ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata> = ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata>>(optionsCallback: (env: Env) => CloudflareOptions | undefined, handler: T): T;
15
+ export declare function withSentry<Env = typeof cloudflareEnv, QueueHandlerMessage = unknown, CfHostMetadata = unknown, T extends ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata> | WorkerEntrypointConstructor = ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata>>(optionsCallback: (env: Env) => CloudflareOptions | undefined, handler: T): T;
15
16
  //# sourceMappingURL=withSentry.d.ts.map
@@ -1,14 +1,31 @@
1
+ import { DurableObjectStorage } from '@cloudflare/workers-types';
1
2
  import { CloudflareOptions } from './client';
3
+ /** Extended DurableObjectState with originalStorage exposed by instrumentContext */
4
+ interface InstrumentedDurableObjectState extends DurableObjectState {
5
+ originalStorage?: DurableObjectStorage;
6
+ }
2
7
  type MethodWrapperOptions = {
3
8
  spanName?: string;
4
9
  spanOp?: string;
5
10
  options: CloudflareOptions;
6
- context: ExecutionContext | DurableObjectState;
11
+ context: ExecutionContext | InstrumentedDurableObjectState;
12
+ /**
13
+ * If true, starts a fresh trace instead of inheriting from a parent trace.
14
+ * Useful for scheduled/independent invocations like alarms.
15
+ *
16
+ * If true, it also stores the current span context and links to the previous invocation's span.
17
+ * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`
18
+ * in a `waitUntil` to avoid blocking.
19
+ *
20
+ * @default false
21
+ */
22
+ startNewTrace?: boolean;
7
23
  };
8
24
  export type UncheckedMethod = (...args: any[]) => any;
9
25
  type OriginalMethod = UncheckedMethod;
10
26
  /**
11
- * Wraps a method with Sentry tracing.
27
+ * Wraps a method with Sentry error tracking and optional tracing.
28
+ * Supports starting new traces and linking to previous invocations via Durable Object storage.
12
29
  *
13
30
  * @param wrapperOptions - The options for the wrapper.
14
31
  * @param handler - The method to wrap.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/cloudflare",
3
- "version": "10.47.0",
3
+ "version": "10.49.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",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@opentelemetry/api": "^1.9.1",
53
- "@sentry/core": "10.47.0"
53
+ "@sentry/core": "10.49.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@cloudflare/workers-types": "^4.x"