@sentry/cloudflare 10.66.0 → 10.67.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.
- package/build/cjs/client.js.map +1 -1
- package/build/cjs/durableobject.js +19 -9
- package/build/cjs/durableobject.js.map +1 -1
- package/build/cjs/instrumentations/instrumentSqlStorage.js +5 -0
- package/build/cjs/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js +89 -8
- package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentEnv.js +12 -0
- package/build/cjs/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentRateLimit.js +29 -0
- package/build/cjs/instrumentations/worker/instrumentRateLimit.js.map +1 -0
- package/build/cjs/utils/internalSqlQuery.js +19 -0
- package/build/cjs/utils/internalSqlQuery.js.map +1 -0
- package/build/cjs/utils/isBinding.js +8 -0
- package/build/cjs/utils/isBinding.js.map +1 -1
- package/build/cjs/wrapMethodWithSentry.js +4 -4
- package/build/cjs/wrapMethodWithSentry.js.map +1 -1
- package/build/esm/client.js.map +1 -1
- package/build/esm/durableobject.js +19 -9
- package/build/esm/durableobject.js.map +1 -1
- package/build/esm/instrumentations/instrumentSqlStorage.js +6 -1
- package/build/esm/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/esm/instrumentations/instrumentWorkerEntrypoint.js +89 -8
- package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentEnv.js +14 -2
- package/build/esm/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentRateLimit.js +27 -0
- package/build/esm/instrumentations/worker/instrumentRateLimit.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/utils/internalSqlQuery.js +17 -0
- package/build/esm/utils/internalSqlQuery.js.map +1 -0
- package/build/esm/utils/isBinding.js +7 -1
- package/build/esm/utils/isBinding.js.map +1 -1
- package/build/esm/wrapMethodWithSentry.js +5 -5
- package/build/esm/wrapMethodWithSentry.js.map +1 -1
- package/build/types/client.d.ts +31 -2
- package/build/types/client.d.ts.map +1 -1
- package/build/types/durableobject.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentSqlStorage.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +3 -3
- package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentEnv.d.ts +2 -0
- package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentRateLimit.d.ts +6 -0
- package/build/types/instrumentations/worker/instrumentRateLimit.d.ts.map +1 -0
- package/build/types/utils/internalSqlQuery.d.ts +18 -0
- package/build/types/utils/internalSqlQuery.d.ts.map +1 -0
- package/build/types/utils/isBinding.d.ts +14 -1
- package/build/types/utils/isBinding.d.ts.map +1 -1
- package/build/types/wrapMethodWithSentry.d.ts +5 -0
- package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
- package/build/types-ts3.8/client.d.ts +31 -2
- package/build/types-ts3.8/instrumentations/instrumentWorkerEntrypoint.d.ts +3 -3
- package/build/types-ts3.8/instrumentations/worker/instrumentEnv.d.ts +2 -0
- package/build/types-ts3.8/instrumentations/worker/instrumentRateLimit.d.ts +6 -0
- package/build/types-ts3.8/utils/internalSqlQuery.d.ts +18 -0
- package/build/types-ts3.8/utils/isBinding.d.ts +14 -1
- package/build/types-ts3.8/wrapMethodWithSentry.d.ts +5 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isBinding.js","sources":["../../../src/utils/isBinding.ts"],"sourcesContent":["/**\n * Adapted from https://github.com/evanderkoogh/otel-cf-workers/blob/effeb549f0a4ed1c55ea0c4f0d8e8e37e5494fb3/src/instrumentation/env.ts\n *\n * BSD 3-Clause License\n *\n * Copyright (c) 2023, Erwin van der Koogh\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * 3. Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { D1Database, DurableObjectNamespace, Queue, R2Bucket } from '@cloudflare/workers-types';\n\n/**\n * Checks if a value is a JSRPC proxy (service binding).\n *\n * JSRPC proxies return a truthy value for ANY property access, including\n * properties that don't exist. This makes other duck-type checks unreliable\n * unless we exclude JSRPC first.\n *\n * Must be checked before other binding type checks.\n */\nexport function isJSRPC(item: unknown): item is Service {\n try {\n return !!(item as Record<string, unknown>)[`__some_property_that_will_never_exist__${Math.random()}`];\n } catch {\n return false;\n }\n}\n\nconst isNotJSRPC = (item: unknown): item is Record<string, unknown> => !isJSRPC(item);\n\n/**\n * Duck-type check for DurableObjectNamespace bindings.\n * DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.\n */\nexport function isDurableObjectNamespace(item: unknown): item is DurableObjectNamespace {\n return item != null && isNotJSRPC(item) && typeof item.idFromName === 'function';\n}\n\n/**\n * Duck-type check for Queue producer bindings.\n * Queue has `send` and `sendBatch` async methods.\n */\nexport function isQueue(item: unknown): item is Queue {\n return item != null && isNotJSRPC(item) && typeof item.send === 'function' && typeof item.sendBatch === 'function';\n}\n\n/**\n * Duck-type check for D1Database bindings.\n * D1Database has `prepare`, `batch`, and `exec` methods.\n */\nexport function isD1Database(item: unknown): item is D1Database {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.prepare === 'function' &&\n typeof item.batch === 'function' &&\n typeof item.exec === 'function'\n );\n}\n\n/**\n * Duck-type check for R2 Bucket bindings.\n * R2Bucket has `head`, `put`, and `createMultipartUpload` methods.\n */\nexport function isR2Bucket(item: unknown): item is R2Bucket {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.head === 'function' &&\n typeof item.put === 'function' &&\n typeof item.createMultipartUpload === 'function'\n );\n}\n"],"names":[],"mappings":"AA4CO,SAAS,QAAQ,IAAA,EAAgC;AACtD,EAAA,IAAI;AACF,IAAA,OAAO,CAAC,CAAE,IAAA,CAAiC,0CAA0C,IAAA,CAAK,MAAA,EAAQ,CAAA,CAAE,CAAA;AAAA,EACtG,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEA,MAAM,UAAA,GAAa,CAAC,IAAA,KAAmD,CAAC,QAAQ,IAAI,CAAA;AAM7E,SAAS,yBAAyB,IAAA,EAA+C;AACtF,EAAA,OAAO,QAAQ,IAAA,IAAQ,UAAA,CAAW,IAAI,CAAA,IAAK,OAAO,KAAK,UAAA,KAAe,UAAA;AACxE;AAMO,SAAS,QAAQ,IAAA,EAA8B;AACpD,EAAA,OAAO,IAAA,IAAQ,IAAA,IAAQ,UAAA,CAAW,IAAI,CAAA,IAAK,OAAO,IAAA,CAAK,IAAA,KAAS,UAAA,IAAc,OAAO,IAAA,CAAK,SAAA,KAAc,UAAA;AAC1G;AAMO,SAAS,aAAa,IAAA,EAAmC;AAC9D,EAAA,OACE,IAAA,IAAQ,IAAA,IACR,UAAA,CAAW,IAAI,KACf,OAAO,IAAA,CAAK,OAAA,KAAY,UAAA,IACxB,OAAO,IAAA,CAAK,KAAA,KAAU,UAAA,IACtB,OAAO,KAAK,IAAA,KAAS,UAAA;AAEzB;AAMO,SAAS,WAAW,IAAA,EAAiC;AAC1D,EAAA,OACE,IAAA,IAAQ,IAAA,IACR,UAAA,CAAW,IAAI,KACf,OAAO,IAAA,CAAK,IAAA,KAAS,UAAA,IACrB,OAAO,IAAA,CAAK,GAAA,KAAQ,UAAA,IACpB,OAAO,KAAK,qBAAA,KAA0B,UAAA;AAE1C;;;;"}
|
|
1
|
+
{"version":3,"file":"isBinding.js","sources":["../../../src/utils/isBinding.ts"],"sourcesContent":["/**\n * Adapted from https://github.com/evanderkoogh/otel-cf-workers/blob/effeb549f0a4ed1c55ea0c4f0d8e8e37e5494fb3/src/instrumentation/env.ts\n *\n * BSD 3-Clause License\n *\n * Copyright (c) 2023, Erwin van der Koogh\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * 3. Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { Ai, D1Database, DurableObjectNamespace, Queue, R2Bucket, RateLimit } from '@cloudflare/workers-types';\n\n/**\n * Checks if a value is a JSRPC proxy (service binding).\n *\n * JSRPC proxies return a truthy value for ANY property access, including\n * properties that don't exist. This makes other duck-type checks unreliable\n * unless we exclude JSRPC first.\n *\n * Must be checked before other binding type checks.\n */\nexport function isJSRPC(item: unknown): item is Service {\n try {\n return !!(item as Record<string, unknown>)[`__some_property_that_will_never_exist__${Math.random()}`];\n } catch {\n return false;\n }\n}\n\nconst isNotJSRPC = (item: unknown): item is Record<string, unknown> => !isJSRPC(item);\n\n/**\n * Duck-type check for DurableObjectNamespace bindings.\n * DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.\n */\nexport function isDurableObjectNamespace(item: unknown): item is DurableObjectNamespace {\n return item != null && isNotJSRPC(item) && typeof item.idFromName === 'function';\n}\n\n/**\n * Duck-type check for Queue producer bindings.\n * Queue has `send` and `sendBatch` async methods.\n */\nexport function isQueue(item: unknown): item is Queue {\n return item != null && isNotJSRPC(item) && typeof item.send === 'function' && typeof item.sendBatch === 'function';\n}\n\n/**\n * Duck-type check for D1Database bindings.\n * D1Database has `prepare`, `batch`, and `exec` methods.\n */\nexport function isD1Database(item: unknown): item is D1Database {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.prepare === 'function' &&\n typeof item.batch === 'function' &&\n typeof item.exec === 'function'\n );\n}\n\n/**\n * Duck-type check for Workers AI bindings.\n * The Ai binding has `run`, `gateway`, and `toMarkdown` methods.\n */\nexport function isAiBinding(item: unknown): item is Ai {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.run === 'function' &&\n typeof item.gateway === 'function' &&\n typeof item.toMarkdown === 'function'\n );\n}\n\n/**\n * Duck-type check for R2 Bucket bindings.\n * R2Bucket has `head`, `put`, and `createMultipartUpload` methods.\n */\nexport function isR2Bucket(item: unknown): item is R2Bucket {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.head === 'function' &&\n typeof item.put === 'function' &&\n typeof item.createMultipartUpload === 'function'\n );\n}\n\n/**\n * Duck-type check for RateLimit bindings.\n * RateLimit only exposes a single `limit` method. Because that is a fairly\n * common method name, this check is intentionally run after the more specific\n * binding checks (Queue, R2, D1) in `instrumentEnv`, so those win when a binding\n * also happens to expose `limit`.\n */\nexport function isRateLimit(item: unknown): item is RateLimit {\n return item != null && isNotJSRPC(item) && typeof item.limit === 'function';\n}\n"],"names":[],"mappings":"AA4CO,SAAS,QAAQ,IAAA,EAAgC;AACtD,EAAA,IAAI;AACF,IAAA,OAAO,CAAC,CAAE,IAAA,CAAiC,0CAA0C,IAAA,CAAK,MAAA,EAAQ,CAAA,CAAE,CAAA;AAAA,EACtG,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEA,MAAM,UAAA,GAAa,CAAC,IAAA,KAAmD,CAAC,QAAQ,IAAI,CAAA;AAM7E,SAAS,yBAAyB,IAAA,EAA+C;AACtF,EAAA,OA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BUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
2
|
-
import { flushAndDispose } from './flush.js';
|
|
2
|
+
import { getOriginalWaitUntil, flushAndDispose } from './flush.js';
|
|
3
3
|
import { ensureInstrumented } from './instrument.js';
|
|
4
4
|
import { init } from './sdk.js';
|
|
5
5
|
import { extractRpcMeta } from './utils/rpcMeta.js';
|
|
@@ -22,7 +22,7 @@ function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
|
|
|
22
22
|
handler,
|
|
23
23
|
(original) => new Proxy(original, {
|
|
24
24
|
apply(target, thisArg, rawArgs) {
|
|
25
|
-
const { startNewTrace: startNewTrace$1 } = wrapperOptions;
|
|
25
|
+
const { startNewTrace: startNewTrace$1, origin } = wrapperOptions;
|
|
26
26
|
let args = rawArgs;
|
|
27
27
|
let rpcMeta;
|
|
28
28
|
if (wrapperOptions.spanOp === "rpc") {
|
|
@@ -34,7 +34,7 @@ function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
|
|
|
34
34
|
const sentryWithScope = startNewTrace$1 ? withIsolationScope : currentClient ? withScope : withIsolationScope;
|
|
35
35
|
const wrappedFunction = (scope) => {
|
|
36
36
|
const context = wrapperOptions.context;
|
|
37
|
-
const waitUntil = context?.
|
|
37
|
+
const waitUntil = context ? getOriginalWaitUntil(context)?.bind(context) : void 0;
|
|
38
38
|
const storage = resolveOriginalStorage(context, thisArg);
|
|
39
39
|
let scopeClient = scope.getClient();
|
|
40
40
|
if (startNewTrace$1 || !scopeClient?.getTransport()) {
|
|
@@ -60,7 +60,7 @@ function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
|
|
|
60
60
|
const onRejected = (e) => {
|
|
61
61
|
captureException(e, {
|
|
62
62
|
mechanism: {
|
|
63
|
-
type:
|
|
63
|
+
type: origin,
|
|
64
64
|
handled: false
|
|
65
65
|
}
|
|
66
66
|
});
|
|
@@ -84,7 +84,7 @@ function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
|
|
|
84
84
|
}
|
|
85
85
|
const attributes = wrapperOptions.spanOp ? {
|
|
86
86
|
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,
|
|
87
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]:
|
|
87
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin
|
|
88
88
|
} : {};
|
|
89
89
|
const executeSpan = () => {
|
|
90
90
|
return startSpan({ name: methodName, attributes }, (span) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapMethodWithSentry.js","sources":["../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport {\n isObjectLike,\n captureException,\n continueTrace,\n getClient,\n isThenable,\n type Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startNewTrace as startNewTraceCore,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { extractRpcMeta } from './utils/rpcMeta';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\ninterface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\n/**\n * Resolves uninstrumented DO storage for the current invocation.\n * Prefer `thisArg.ctx` (the live Durable Object instance) over the context captured at\n * construction time to avoid cross-DO I/O errors in the same isolate.\n */\nfunction resolveOriginalStorage(\n context: ExecutionContext | InstrumentedDurableObjectState | undefined,\n thisArg: unknown,\n): DurableObjectStorage | undefined {\n if (isObjectLike(thisArg) && 'ctx' in thisArg) {\n const doCtx = (thisArg as { ctx: InstrumentedDurableObjectState }).ctx;\n if (doCtx?.originalStorage) {\n return doCtx.originalStorage;\n }\n }\n\n if (context && 'originalStorage' in context && context.originalStorage) {\n return context.originalStorage;\n }\n\n return undefined;\n}\n\ntype MethodWrapperOptions = {\n spanName?: string;\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | InstrumentedDurableObjectState;\n /**\n * If true, starts a fresh trace instead of inheriting from a parent trace.\n * Useful for scheduled/independent invocations like alarms.\n *\n * If true, it also stores the current span context and links to the previous invocation's span.\n * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`\n * in a `waitUntil` to avoid blocking.\n *\n * @default false\n */\n startNewTrace?: boolean;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry error tracking and optional tracing.\n * Supports starting new traces and linking to previous invocations via Durable Object storage.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n return ensureInstrumented(\n handler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, rawArgs: Parameters<T>) {\n const { startNewTrace } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\n\n // For startNewTrace, always use withIsolationScope to ensure a fresh scope\n // Otherwise, use existing client's scope or isolation scope\n const currentClient = getClient();\n const sentryWithScope = startNewTrace ? withIsolationScope : currentClient ? withScope : withIsolationScope;\n\n const wrappedFunction = (scope: Scope): unknown | Promise<unknown> => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context: typeof wrapperOptions.context | undefined = wrapperOptions.context;\n\n const waitUntil = context?.waitUntil?.bind?.(context);\n const storage = resolveOriginalStorage(context, thisArg);\n\n let scopeClient = scope.getClient();\n // Check if client exists AND is still usable (transport not disposed)\n // This handles the case where a previous handler disposed the client\n // but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)\n // For startNewTrace, always create a fresh client\n if (startNewTrace || !scopeClient?.getTransport()) {\n const client = init({\n ...wrapperOptions.options,\n ctx: context as unknown as ExecutionContext | undefined,\n });\n scope.setClient(client);\n scopeClient = client;\n }\n\n const clientToDispose = scopeClient;\n const methodName = wrapperOptions.spanName || 'unknown';\n\n const teardown = async (): Promise<void> => {\n if (startNewTrace && storage) {\n storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n const onFulfilled = (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n };\n\n const onRejected = (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n };\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.durable_object',\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n if (startNewTrace && storage) {\n const storedContext = getStoredSpanContext(storage, methodName);\n\n if (storedContext) {\n span.addLinks(buildSpanLinks(storedContext));\n // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we\n // can obtain the previous trace information from the EAP store. Long-term, EAP will handle\n // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us\n // to check this at v11 time :)\n const sampledFlag = storedContext.sampled ? '1' : '0';\n span.setAttribute(\n 'sentry.previous_trace',\n `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,\n );\n }\n }\n\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n });\n };\n\n if (rpcMeta) {\n return continueTrace(\n { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },\n executeSpan,\n );\n }\n\n if (startNewTrace) {\n return startNewTraceCore(() => executeSpan());\n }\n\n return executeSpan();\n };\n\n return sentryWithScope(wrappedFunction);\n },\n }),\n noMark,\n );\n}\n"],"names":["startNewTrace","startNewTraceCore"],"mappings":";;;;;;;AAiCA,SAAS,sBAAA,CACP,SACA,OAAA,EACkC;AAClC,EAAA,IAAI,YAAA,CAAa,OAAO,CAAA,IAAK,KAAA,IAAS,OAAA,EAAS;AAC7C,IAAA,MAAM,QAAS,OAAA,CAAoD,GAAA;AACnE,IAAA,IAAI,OAAO,eAAA,EAAiB;AAC1B,MAAA,OAAO,KAAA,CAAM,eAAA;AAAA,IACf;AAAA,EACF;AAEA,EAAA,IAAI,OAAA,IAAW,iBAAA,IAAqB,OAAA,IAAW,OAAA,CAAQ,eAAA,EAAiB;AACtE,IAAA,OAAO,OAAA,CAAQ,eAAA;AAAA,EACjB;AAEA,EAAA,OAAO,MAAA;AACT;AAkCO,SAAS,oBAAA,CACd,cAAA,EACA,OAAA,EACA,QAAA,EACA,MAAA,EACG;AACH,EAAA,OAAO,kBAAA;AAAA,IACL,OAAA;AAAA,IACA,CAAA,QAAA,KACE,IAAI,KAAA,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O,WAAA,EAAY;AAAA,QACrB,CAAA;AAEA,QAAA,OAAO,gBAAgB,eAAe,CAAA;AAAA,MACxC;AAAA,KACD,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"wrapMethodWithSentry.js","sources":["../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport {\n isObjectLike,\n captureException,\n continueTrace,\n getClient,\n isThenable,\n type Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startNewTrace as startNewTraceCore,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { extractRpcMeta } from './utils/rpcMeta';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\ninterface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\n/**\n * Resolves uninstrumented DO storage for the current invocation.\n * Prefer `thisArg.ctx` (the live Durable Object instance) over the context captured at\n * construction time to avoid cross-DO I/O errors in the same isolate.\n */\nfunction resolveOriginalStorage(\n context: ExecutionContext | InstrumentedDurableObjectState | undefined,\n thisArg: unknown,\n): DurableObjectStorage | undefined {\n if (isObjectLike(thisArg) && 'ctx' in thisArg) {\n const doCtx = (thisArg as { ctx: InstrumentedDurableObjectState }).ctx;\n if (doCtx?.originalStorage) {\n return doCtx.originalStorage;\n }\n }\n\n if (context && 'originalStorage' in context && context.originalStorage) {\n return context.originalStorage;\n }\n\n return undefined;\n}\n\ntype MethodWrapperOptions = {\n spanName?: string;\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | InstrumentedDurableObjectState;\n /**\n * If true, starts a fresh trace instead of inheriting from a parent trace.\n * Useful for scheduled/independent invocations like alarms.\n *\n * If true, it also stores the current span context and links to the previous invocation's span.\n * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`\n * in a `waitUntil` to avoid blocking.\n *\n * @default false\n */\n startNewTrace?: boolean;\n /**\n * The trace origin identifying which instrumentation created the span, e.g. `auto.faas.cloudflare.durable_object`.\n * Used both as the span's `sentry.origin` attribute and as the `mechanism.type` for captured exceptions.\n */\n origin: string;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry error tracking and optional tracing.\n * Supports starting new traces and linking to previous invocations via Durable Object storage.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n return ensureInstrumented(\n handler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, rawArgs: Parameters<T>) {\n const { startNewTrace, origin } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\n\n // For startNewTrace, always use withIsolationScope to ensure a fresh scope\n // Otherwise, use existing client's scope or isolation scope\n const currentClient = getClient();\n const sentryWithScope = startNewTrace ? withIsolationScope : currentClient ? withScope : withIsolationScope;\n\n const wrappedFunction = (scope: Scope): unknown | Promise<unknown> => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context: typeof wrapperOptions.context | undefined = wrapperOptions.context;\n\n // see: https://github.com/getsentry/sentry-javascript/issues/22328\n const waitUntil = context\n ? getOriginalWaitUntil(context as ExecutionContextCompat)?.bind(context)\n : undefined;\n const storage = resolveOriginalStorage(context, thisArg);\n\n let scopeClient = scope.getClient();\n // Check if client exists AND is still usable (transport not disposed)\n // This handles the case where a previous handler disposed the client\n // but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)\n // For startNewTrace, always create a fresh client\n if (startNewTrace || !scopeClient?.getTransport()) {\n const client = init({\n ...wrapperOptions.options,\n ctx: context as unknown as ExecutionContext | undefined,\n });\n scope.setClient(client);\n scopeClient = client;\n }\n\n const clientToDispose = scopeClient;\n const methodName = wrapperOptions.spanName || 'unknown';\n\n const teardown = async (): Promise<void> => {\n if (startNewTrace && storage) {\n storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n const onFulfilled = (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n };\n\n const onRejected = (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: origin,\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n };\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n if (startNewTrace && storage) {\n const storedContext = getStoredSpanContext(storage, methodName);\n\n if (storedContext) {\n span.addLinks(buildSpanLinks(storedContext));\n // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we\n // can obtain the previous trace information from the EAP store. Long-term, EAP will handle\n // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us\n // to check this at v11 time :)\n const sampledFlag = storedContext.sampled ? '1' : '0';\n span.setAttribute(\n 'sentry.previous_trace',\n `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,\n );\n }\n }\n\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n });\n };\n\n if (rpcMeta) {\n return continueTrace(\n { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },\n executeSpan,\n );\n }\n\n if (startNewTrace) {\n return startNewTraceCore(() => executeSpan());\n }\n\n return executeSpan();\n };\n\n return sentryWithScope(wrappedFunction);\n },\n }),\n noMark,\n );\n}\n"],"names":["startNewTrace","startNewTraceCore"],"mappings":";;;;;;;AAkCA,SAAS,sBAAA,CACP,SACA,OAAA,EACkC;AAClC,EAAA,IAAI,YAAA,CAAa,OAAO,CAAA,IAAK,KAAA,IAAS,OAAA,EAAS;AAC7C,IAAA,MAAM,QAAS,OAAA,CAAoD,GAAA;AACnE,IAAA,IAAI,OAAO,eAAA,EAAiB;AAC1B,MAAA,OAAO,KAAA,CAAM,eAAA;AAAA,IACf;AAAA,EACF;AAEA,EAAA,IAAI,OAAA,IAAW,iBAAA,IAAqB,OAAA,IAAW,OAAA,CAAQ,eAAA,EAAiB;AACtE,IAAA,OAAO,OAAA,CAAQ,eAAA;AAAA,EACjB;AAEA,EAAA,OAAO,MAAA;AACT;AAuCO,SAAS,oBAAA,CACd,cAAA,EACA,OAAA,EACA,QAAA,EACA,MAAA,EACG;AACH,EAAA,OAAO,kBAAA;AAAA,IACL,OAAA;AAAA,IACA,CAAA,QAAA,KACE,IAAI,K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WAAA,EAAa,CAAA;AAAA,UAC9C;AAEA,UAAA,OAAO,WAAA,EAAY;AAAA,QACrB,CAAA;AAEA,QAAA,OAAO,gBAAgB,eAAe,CAAA;AAAA,MACxC;AAAA,KACD,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;"}
|
package/build/types/client.d.ts
CHANGED
|
@@ -71,9 +71,9 @@ interface BaseCloudflareOptions {
|
|
|
71
71
|
* When enabled, trace context (sentry-trace + baggage) is propagated across:
|
|
72
72
|
* - `stub.fetch()` calls to Durable Objects (via HTTP headers)
|
|
73
73
|
* - Service binding `fetch()` calls (via HTTP headers)
|
|
74
|
-
* - RPC method calls to Durable Objects (via trailing argument)
|
|
74
|
+
* - RPC method calls to Durable Objects and WorkerEntrypoints (via trailing argument)
|
|
75
75
|
*
|
|
76
|
-
* When enabled on the **receiver side** (DurableObject), the SDK will also:
|
|
76
|
+
* When enabled on the **receiver side** (DurableObject or WorkerEntrypoint), the SDK will also:
|
|
77
77
|
* - Extract and continue traces from incoming RPC calls
|
|
78
78
|
* - Create spans for each RPC method invocation
|
|
79
79
|
* - Capture errors thrown by RPC methods
|
|
@@ -100,9 +100,38 @@ interface BaseCloudflareOptions {
|
|
|
100
100
|
* }),
|
|
101
101
|
* MyDOBase,
|
|
102
102
|
* );
|
|
103
|
+
*
|
|
104
|
+
* // WorkerEntrypoint side (receiver)
|
|
105
|
+
* export const MyEntrypoint = Sentry.withSentry(
|
|
106
|
+
* env => ({ dsn: env.SENTRY_DSN, enableRpcTracePropagation: true }),
|
|
107
|
+
* MyEntrypointBase,
|
|
108
|
+
* );
|
|
103
109
|
* ```
|
|
104
110
|
*/
|
|
105
111
|
enableRpcTracePropagation?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Table names that should stay instrumented even though they match the reserved `cf_` prefix used
|
|
114
|
+
* by Durable Object frameworks (`agents`, `partyserver`, ...) for their internal SQLite tables.
|
|
115
|
+
*
|
|
116
|
+
* By default, `exec` queries against `cf_`-prefixed tables are treated as framework noise and no
|
|
117
|
+
* `db.query` span is created for them. If one of your own tables happens to use this prefix, add it
|
|
118
|
+
* here to opt it back into instrumentation. Entries are matched against each table name in the
|
|
119
|
+
* query summary — strings must match exactly, while regular expressions give you prefix/pattern
|
|
120
|
+
* matching.
|
|
121
|
+
*
|
|
122
|
+
* @default []
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* export default Sentry.withSentry(
|
|
126
|
+
* (env) => ({
|
|
127
|
+
* dsn: env.SENTRY_DSN,
|
|
128
|
+
* durableObjectSqlSpanAllowlist: ['cf_my_table', /^cf_reports_/],
|
|
129
|
+
* }),
|
|
130
|
+
* handler,
|
|
131
|
+
* );
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
durableObjectSqlSpanAllowlist?: Array<string | RegExp>;
|
|
106
135
|
/**
|
|
107
136
|
* @deprecated Use `enableRpcTracePropagation` instead. This option will be removed in a future major version.
|
|
108
137
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAA8B,MAAM,cAAc,CAAC;AACvF,OAAO,EAA2B,mBAAmB,EAAiB,MAAM,cAAc,CAAC;AAE3F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,mBAAmB;IACvD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0C;IACrE,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,sBAAsB,CAA8B;IAC5D,OAAO,CAAC,sBAAsB,CAA6B;IAE3D,OAAO,CAAC,qBAAqB,CAA6B;IAC1D,OAAO,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AAkB,EAAE,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"durableobject.d.ts","sourceRoot":"","sources":["../../src/durableobject.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAUlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,iCAAiC,CAC/C,CAAC,EACD,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,EAC1B,CAAC,SAAS,KAAK,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EACtD,eAAe,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,iBAAiB,EAAE,kBAAkB,EAAE,CAAC,GAAG,CAAC,CAuK1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentSqlStorage.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/instrumentSqlStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"instrumentSqlStorage.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/instrumentSqlStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAW5D;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAwChE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WorkerEntrypoint } from 'cloudflare:workers';
|
|
2
2
|
import type { CloudflareOptions } from '../client';
|
|
3
|
-
export type WorkerEntrypointConstructor<Env =
|
|
3
|
+
export type WorkerEntrypointConstructor<Env = unknown, Props = {}> = new (ctx: ExecutionContext, env: any) => InstanceType<typeof WorkerEntrypoint<Env, Props>>;
|
|
4
4
|
/**
|
|
5
5
|
* Instruments a WorkerEntrypoint class to capture errors and performance data.
|
|
6
6
|
*
|
|
@@ -38,5 +38,5 @@ export type WorkerEntrypointConstructor<Env = typeof cloudflareEnv, Props = {}>
|
|
|
38
38
|
* );
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
export declare function instrumentWorkerEntrypoint<T extends
|
|
41
|
+
export declare function instrumentWorkerEntrypoint<Env, Props, T extends InstanceType<typeof WorkerEntrypoint<Env, Props>>, C extends new (ctx: ExecutionContext, env: Env) => T>(optionsCallback: (env: Env) => CloudflareOptions | undefined, WorkerEntrypointClass: C): C;
|
|
42
42
|
//# sourceMappingURL=instrumentWorkerEntrypoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentWorkerEntrypoint.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/instrumentWorkerEntrypoint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instrumentWorkerEntrypoint.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/instrumentWorkerEntrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAsCnD,MAAM,MAAM,2BAA2B,CAAC,GAAG,GAAG,OAAO,EAAE,KAAK,GAAG,EAAE,IAAI,KACnE,GAAG,EAAE,gBAAgB,EAGrB,GAAG,EAAE,GAAG,KACL,YAAY,CAAC,OAAO,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAmEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EACH,KAAK,EACL,CAAC,SAAS,YAAY,CAAC,OAAO,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAC3D,CAAC,SAAS,KAAK,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,EACpD,eAAe,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,iBAAiB,GAAG,SAAS,EAAE,qBAAqB,EAAE,CAAC,GAAG,CAAC,CAkF3F"}
|
|
@@ -8,6 +8,8 @@ import type { CloudflareOptions } from '../../client';
|
|
|
8
8
|
* - Service bindings / JSRPC proxies
|
|
9
9
|
* - Queue producers (via `send` + `sendBatch` duck-typing)
|
|
10
10
|
* - R2 Buckets (via `head` + `put` + `createMultipartUpload` duck-typing)
|
|
11
|
+
* - Rate limiters (via `limit` duck-typing)
|
|
12
|
+
* - Workers AI (via `run` + `gateway` + `toMarkdown` duck-typing)
|
|
11
13
|
*
|
|
12
14
|
* @param env - The Cloudflare env object to instrument
|
|
13
15
|
* @param options - Optional CloudflareOptions to control RPC trace propagation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentEnv.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/worker/instrumentEnv.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instrumentEnv.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/worker/instrumentEnv.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAyBtD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,GAAG,CAwF7G"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RateLimit } from '@cloudflare/workers-types';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a Cloudflare rate limiter binding to create a span on each `limit()` call.
|
|
4
|
+
*/
|
|
5
|
+
export declare function instrumentRateLimit<T extends RateLimit>(rateLimit: T, bindingName: string): T;
|
|
6
|
+
//# sourceMappingURL=instrumentRateLimit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentRateLimit.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/worker/instrumentRateLimit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAsC,MAAM,2BAA2B,CAAC;AAK/F;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC,CAsB7F"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare frameworks that build on Durable Objects (`agents`, `partyserver`, ...) manage their
|
|
3
|
+
* own internal SQLite tables, all namespaced with a `cf_` prefix — e.g. `cf_agents_schedules`,
|
|
4
|
+
* `cf_agent_state`, `cf_ai_chat_stream_chunks`. Queries against them (schedule polling, chat-stream
|
|
5
|
+
* persistence, state bookkeeping) are framework implementation details that otherwise flood traces
|
|
6
|
+
* with dozens of zero-signal `db.query` spans per request. The exact set of tables even varies
|
|
7
|
+
* between framework versions, so we match the reserved prefix rather than an enumerated list.
|
|
8
|
+
*
|
|
9
|
+
* The `cf_` prefix is a reserved convention for framework-managed tables, so user tables should not
|
|
10
|
+
* use it. In case a user table does collide with the prefix, the `durableObjectSqlSpanAllowlist`
|
|
11
|
+
* option lets them opt those tables back into instrumentation.
|
|
12
|
+
*
|
|
13
|
+
* The check operates on the query summary produced by `getSqlQuerySummary` (`{operation} {table} ...`,
|
|
14
|
+
* the same value used as the span name), so table targets are already isolated from the rest of the
|
|
15
|
+
* query.
|
|
16
|
+
*/
|
|
17
|
+
export declare function targetsCloudflareInternalTable(querySummary: string | undefined, allowlist?: Array<string | RegExp>): boolean;
|
|
18
|
+
//# sourceMappingURL=internalSqlQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internalSqlQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/internalSqlQuery.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,8BAA8B,CAC5C,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GACjC,OAAO,CAgBT"}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
31
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
32
|
*/
|
|
33
|
-
import type { D1Database, DurableObjectNamespace, Queue, R2Bucket } from '@cloudflare/workers-types';
|
|
33
|
+
import type { Ai, D1Database, DurableObjectNamespace, Queue, R2Bucket, RateLimit } from '@cloudflare/workers-types';
|
|
34
34
|
/**
|
|
35
35
|
* Checks if a value is a JSRPC proxy (service binding).
|
|
36
36
|
*
|
|
@@ -56,9 +56,22 @@ export declare function isQueue(item: unknown): item is Queue;
|
|
|
56
56
|
* D1Database has `prepare`, `batch`, and `exec` methods.
|
|
57
57
|
*/
|
|
58
58
|
export declare function isD1Database(item: unknown): item is D1Database;
|
|
59
|
+
/**
|
|
60
|
+
* Duck-type check for Workers AI bindings.
|
|
61
|
+
* The Ai binding has `run`, `gateway`, and `toMarkdown` methods.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isAiBinding(item: unknown): item is Ai;
|
|
59
64
|
/**
|
|
60
65
|
* Duck-type check for R2 Bucket bindings.
|
|
61
66
|
* R2Bucket has `head`, `put`, and `createMultipartUpload` methods.
|
|
62
67
|
*/
|
|
63
68
|
export declare function isR2Bucket(item: unknown): item is R2Bucket;
|
|
69
|
+
/**
|
|
70
|
+
* Duck-type check for RateLimit bindings.
|
|
71
|
+
* RateLimit only exposes a single `limit` method. Because that is a fairly
|
|
72
|
+
* common method name, this check is intentionally run after the more specific
|
|
73
|
+
* binding checks (Queue, R2, D1) in `instrumentEnv`, so those win when a binding
|
|
74
|
+
* also happens to expose `limit`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isRateLimit(item: unknown): item is RateLimit;
|
|
64
77
|
//# sourceMappingURL=isBinding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isBinding.d.ts","sourceRoot":"","sources":["../../../src/utils/isBinding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"isBinding.d.ts","sourceRoot":"","sources":["../../../src/utils/isBinding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEpH;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,OAAO,CAMtD;AAID;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,sBAAsB,CAEtF;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,KAAK,CAEpD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,UAAU,CAQ9D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,EAAE,CAQrD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,QAAQ,CAQ1D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAE5D"}
|
|
@@ -20,6 +20,11 @@ type MethodWrapperOptions = {
|
|
|
20
20
|
* @default false
|
|
21
21
|
*/
|
|
22
22
|
startNewTrace?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The trace origin identifying which instrumentation created the span, e.g. `auto.faas.cloudflare.durable_object`.
|
|
25
|
+
* Used both as the span's `sentry.origin` attribute and as the `mechanism.type` for captured exceptions.
|
|
26
|
+
*/
|
|
27
|
+
origin: string;
|
|
23
28
|
};
|
|
24
29
|
export type UncheckedMethod = (...args: any[]) => any;
|
|
25
30
|
type OriginalMethod = UncheckedMethod;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapMethodWithSentry.d.ts","sourceRoot":"","sources":["../../src/wrapMethodWithSentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAgBtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"wrapMethodWithSentry.d.ts","sourceRoot":"","sources":["../../src/wrapMethodWithSentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAgBtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAQlD,oFAAoF;AACpF,UAAU,8BAA+B,SAAQ,kBAAkB;IACjE,eAAe,CAAC,EAAE,oBAAoB,CAAC;CACxC;AAyBD,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,gBAAgB,GAAG,8BAA8B,CAAC;IAC3D;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AACtD,KAAK,cAAc,GAAG,eAAe,CAAC;AAEtC;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,cAAc,EAC3D,cAAc,EAAE,oBAAoB,EACpC,OAAO,EAAE,CAAC,EACV,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,EAC3C,MAAM,CAAC,EAAE,IAAI,GACZ,CAAC,CA0JH"}
|
|
@@ -71,9 +71,9 @@ interface BaseCloudflareOptions {
|
|
|
71
71
|
* When enabled, trace context (sentry-trace + baggage) is propagated across:
|
|
72
72
|
* - `stub.fetch()` calls to Durable Objects (via HTTP headers)
|
|
73
73
|
* - Service binding `fetch()` calls (via HTTP headers)
|
|
74
|
-
* - RPC method calls to Durable Objects (via trailing argument)
|
|
74
|
+
* - RPC method calls to Durable Objects and WorkerEntrypoints (via trailing argument)
|
|
75
75
|
*
|
|
76
|
-
* When enabled on the **receiver side** (DurableObject), the SDK will also:
|
|
76
|
+
* When enabled on the **receiver side** (DurableObject or WorkerEntrypoint), the SDK will also:
|
|
77
77
|
* - Extract and continue traces from incoming RPC calls
|
|
78
78
|
* - Create spans for each RPC method invocation
|
|
79
79
|
* - Capture errors thrown by RPC methods
|
|
@@ -100,9 +100,38 @@ interface BaseCloudflareOptions {
|
|
|
100
100
|
* }),
|
|
101
101
|
* MyDOBase,
|
|
102
102
|
* );
|
|
103
|
+
*
|
|
104
|
+
* // WorkerEntrypoint side (receiver)
|
|
105
|
+
* export const MyEntrypoint = Sentry.withSentry(
|
|
106
|
+
* env => ({ dsn: env.SENTRY_DSN, enableRpcTracePropagation: true }),
|
|
107
|
+
* MyEntrypointBase,
|
|
108
|
+
* );
|
|
103
109
|
* ```
|
|
104
110
|
*/
|
|
105
111
|
enableRpcTracePropagation?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Table names that should stay instrumented even though they match the reserved `cf_` prefix used
|
|
114
|
+
* by Durable Object frameworks (`agents`, `partyserver`, ...) for their internal SQLite tables.
|
|
115
|
+
*
|
|
116
|
+
* By default, `exec` queries against `cf_`-prefixed tables are treated as framework noise and no
|
|
117
|
+
* `db.query` span is created for them. If one of your own tables happens to use this prefix, add it
|
|
118
|
+
* here to opt it back into instrumentation. Entries are matched against each table name in the
|
|
119
|
+
* query summary — strings must match exactly, while regular expressions give you prefix/pattern
|
|
120
|
+
* matching.
|
|
121
|
+
*
|
|
122
|
+
* @default []
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* export default Sentry.withSentry(
|
|
126
|
+
* (env) => ({
|
|
127
|
+
* dsn: env.SENTRY_DSN,
|
|
128
|
+
* durableObjectSqlSpanAllowlist: ['cf_my_table', /^cf_reports_/],
|
|
129
|
+
* }),
|
|
130
|
+
* handler,
|
|
131
|
+
* );
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
durableObjectSqlSpanAllowlist?: Array<string | RegExp>;
|
|
106
135
|
/**
|
|
107
136
|
* @deprecated Use `enableRpcTracePropagation` instead. This option will be removed in a future major version.
|
|
108
137
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
2
2
|
import { CloudflareOptions } from '../client';
|
|
3
|
-
export type WorkerEntrypointConstructor<Env =
|
|
3
|
+
export type WorkerEntrypointConstructor<Env = unknown, Props = {}> = new (ctx: ExecutionContext, env: any) => InstanceType<typeof WorkerEntrypoint<Env, Props>>;
|
|
4
4
|
/**
|
|
5
5
|
* Instruments a WorkerEntrypoint class to capture errors and performance data.
|
|
6
6
|
*
|
|
@@ -38,5 +38,5 @@ export type WorkerEntrypointConstructor<Env = typeof cloudflareEnv, Props = {}>
|
|
|
38
38
|
* );
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
export declare function instrumentWorkerEntrypoint<T extends
|
|
41
|
+
export declare function instrumentWorkerEntrypoint<Env, Props, T extends InstanceType<typeof WorkerEntrypoint<Env, Props>>, C extends new (ctx: ExecutionContext, env: Env) => T>(optionsCallback: (env: Env) => CloudflareOptions | undefined, WorkerEntrypointClass: C): C;
|
|
42
42
|
//# sourceMappingURL=instrumentWorkerEntrypoint.d.ts.map
|
|
@@ -8,6 +8,8 @@ import { CloudflareOptions } from '../../client';
|
|
|
8
8
|
* - Service bindings / JSRPC proxies
|
|
9
9
|
* - Queue producers (via `send` + `sendBatch` duck-typing)
|
|
10
10
|
* - R2 Buckets (via `head` + `put` + `createMultipartUpload` duck-typing)
|
|
11
|
+
* - Rate limiters (via `limit` duck-typing)
|
|
12
|
+
* - Workers AI (via `run` + `gateway` + `toMarkdown` duck-typing)
|
|
11
13
|
*
|
|
12
14
|
* @param env - The Cloudflare env object to instrument
|
|
13
15
|
* @param options - Optional CloudflareOptions to control RPC trace propagation
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RateLimit } from '@cloudflare/workers-types';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a Cloudflare rate limiter binding to create a span on each `limit()` call.
|
|
4
|
+
*/
|
|
5
|
+
export declare function instrumentRateLimit<T extends RateLimit>(rateLimit: T, bindingName: string): T;
|
|
6
|
+
//# sourceMappingURL=instrumentRateLimit.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare frameworks that build on Durable Objects (`agents`, `partyserver`, ...) manage their
|
|
3
|
+
* own internal SQLite tables, all namespaced with a `cf_` prefix — e.g. `cf_agents_schedules`,
|
|
4
|
+
* `cf_agent_state`, `cf_ai_chat_stream_chunks`. Queries against them (schedule polling, chat-stream
|
|
5
|
+
* persistence, state bookkeeping) are framework implementation details that otherwise flood traces
|
|
6
|
+
* with dozens of zero-signal `db.query` spans per request. The exact set of tables even varies
|
|
7
|
+
* between framework versions, so we match the reserved prefix rather than an enumerated list.
|
|
8
|
+
*
|
|
9
|
+
* The `cf_` prefix is a reserved convention for framework-managed tables, so user tables should not
|
|
10
|
+
* use it. In case a user table does collide with the prefix, the `durableObjectSqlSpanAllowlist`
|
|
11
|
+
* option lets them opt those tables back into instrumentation.
|
|
12
|
+
*
|
|
13
|
+
* The check operates on the query summary produced by `getSqlQuerySummary` (`{operation} {table} ...`,
|
|
14
|
+
* the same value used as the span name), so table targets are already isolated from the rest of the
|
|
15
|
+
* query.
|
|
16
|
+
*/
|
|
17
|
+
export declare function targetsCloudflareInternalTable(querySummary: string | undefined, allowlist?: Array<string | RegExp>): boolean;
|
|
18
|
+
//# sourceMappingURL=internalSqlQuery.d.ts.map
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
31
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
32
|
*/
|
|
33
|
-
import { D1Database, DurableObjectNamespace, Queue, R2Bucket } from '@cloudflare/workers-types';
|
|
33
|
+
import { Ai, D1Database, DurableObjectNamespace, Queue, R2Bucket, RateLimit } from '@cloudflare/workers-types';
|
|
34
34
|
/**
|
|
35
35
|
* Checks if a value is a JSRPC proxy (service binding).
|
|
36
36
|
*
|
|
@@ -56,9 +56,22 @@ export declare function isQueue(item: unknown): item is Queue;
|
|
|
56
56
|
* D1Database has `prepare`, `batch`, and `exec` methods.
|
|
57
57
|
*/
|
|
58
58
|
export declare function isD1Database(item: unknown): item is D1Database;
|
|
59
|
+
/**
|
|
60
|
+
* Duck-type check for Workers AI bindings.
|
|
61
|
+
* The Ai binding has `run`, `gateway`, and `toMarkdown` methods.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isAiBinding(item: unknown): item is Ai;
|
|
59
64
|
/**
|
|
60
65
|
* Duck-type check for R2 Bucket bindings.
|
|
61
66
|
* R2Bucket has `head`, `put`, and `createMultipartUpload` methods.
|
|
62
67
|
*/
|
|
63
68
|
export declare function isR2Bucket(item: unknown): item is R2Bucket;
|
|
69
|
+
/**
|
|
70
|
+
* Duck-type check for RateLimit bindings.
|
|
71
|
+
* RateLimit only exposes a single `limit` method. Because that is a fairly
|
|
72
|
+
* common method name, this check is intentionally run after the more specific
|
|
73
|
+
* binding checks (Queue, R2, D1) in `instrumentEnv`, so those win when a binding
|
|
74
|
+
* also happens to expose `limit`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isRateLimit(item: unknown): item is RateLimit;
|
|
64
77
|
//# sourceMappingURL=isBinding.d.ts.map
|
|
@@ -20,6 +20,11 @@ type MethodWrapperOptions = {
|
|
|
20
20
|
* @default false
|
|
21
21
|
*/
|
|
22
22
|
startNewTrace?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The trace origin identifying which instrumentation created the span, e.g. `auto.faas.cloudflare.durable_object`.
|
|
25
|
+
* Used both as the span's `sentry.origin` attribute and as the `mechanism.type` for captured exceptions.
|
|
26
|
+
*/
|
|
27
|
+
origin: string;
|
|
23
28
|
};
|
|
24
29
|
export type UncheckedMethod = (...args: any[]) => any;
|
|
25
30
|
type OriginalMethod = UncheckedMethod;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/cloudflare",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.67.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",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@opentelemetry/api": "^1.9.1",
|
|
63
|
-
"@sentry/core": "10.
|
|
64
|
-
"@sentry/node": "10.
|
|
65
|
-
"@sentry/server-utils": "10.
|
|
63
|
+
"@sentry/core": "10.67.0",
|
|
64
|
+
"@sentry/node": "10.67.0",
|
|
65
|
+
"@sentry/server-utils": "10.67.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@cloudflare/workers-types": "^4.x || ^5.x"
|