@sentry/cloudflare 10.68.0 → 10.69.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 +5 -0
- package/build/cjs/client.js.map +1 -1
- package/build/cjs/durableobject.js +131 -96
- package/build/cjs/durableobject.js.map +1 -1
- package/build/cjs/index.js +3 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/instrumentations/agents/index.js +14 -0
- package/build/cjs/instrumentations/agents/index.js.map +1 -0
- package/build/cjs/instrumentations/agents/instrumentAgentCallableRpc.js +52 -0
- package/build/cjs/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/cjs/instrumentations/agents/instrumentChatAgentConversation.js +31 -0
- package/build/cjs/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/cjs/instrumentations/agents/types.js +32 -0
- package/build/cjs/instrumentations/agents/types.js.map +1 -0
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +6 -0
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/cjs/instrumentations/instrumentSqlStorage.js +1 -1
- package/build/cjs/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/cjs/integrations/spotlight.js +64 -0
- package/build/cjs/integrations/spotlight.js.map +1 -0
- package/build/cjs/nodejs_compat/index.js +5 -2
- package/build/cjs/nodejs_compat/index.js.map +1 -1
- package/build/cjs/options.js +14 -1
- package/build/cjs/options.js.map +1 -1
- package/build/cjs/sdk.js +8 -0
- package/build/cjs/sdk.js.map +1 -1
- package/build/cjs/utils/internalSqlQuery.js +13 -7
- package/build/cjs/utils/internalSqlQuery.js.map +1 -1
- package/build/cjs/utils/internalStorageKey.js +44 -0
- package/build/cjs/utils/internalStorageKey.js.map +1 -0
- package/build/cjs/vite/agentClass.js +114 -0
- package/build/cjs/vite/agentClass.js.map +1 -0
- package/build/cjs/vite/autoInstrument.js +17 -4
- package/build/cjs/vite/autoInstrument.js.map +1 -1
- package/build/cjs/vite/index.js +1 -1
- package/build/cjs/vite/index.js.map +1 -1
- package/build/cjs/vite/moduleShape.js +231 -0
- package/build/cjs/vite/moduleShape.js.map +1 -0
- package/build/cjs/vite/transform.js +6 -1
- package/build/cjs/vite/transform.js.map +1 -1
- package/build/cjs/vite/wranglerConfig.js +1 -1
- package/build/cjs/vite/wranglerConfig.js.map +1 -1
- package/build/esm/client.js +6 -1
- package/build/esm/client.js.map +1 -1
- package/build/esm/durableobject.js +129 -97
- package/build/esm/durableobject.js.map +1 -1
- package/build/esm/index.js +2 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/instrumentations/agents/index.js +12 -0
- package/build/esm/instrumentations/agents/index.js.map +1 -0
- package/build/esm/instrumentations/agents/instrumentAgentCallableRpc.js +50 -0
- package/build/esm/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/esm/instrumentations/agents/instrumentChatAgentConversation.js +29 -0
- package/build/esm/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/esm/instrumentations/agents/types.js +26 -0
- package/build/esm/instrumentations/agents/types.js.map +1 -0
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js +7 -1
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/esm/instrumentations/instrumentSqlStorage.js +1 -1
- package/build/esm/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/esm/integrations/spotlight.js +61 -0
- package/build/esm/integrations/spotlight.js.map +1 -0
- package/build/esm/nodejs_compat/index.js +2 -1
- package/build/esm/nodejs_compat/index.js.map +1 -1
- package/build/esm/options.js +14 -1
- package/build/esm/options.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/sdk.js +8 -0
- package/build/esm/sdk.js.map +1 -1
- package/build/esm/utils/internalSqlQuery.js +13 -7
- package/build/esm/utils/internalSqlQuery.js.map +1 -1
- package/build/esm/utils/internalStorageKey.js +41 -0
- package/build/esm/utils/internalStorageKey.js.map +1 -0
- package/build/esm/utils/traceLinks.js +1 -1
- package/build/esm/vite/agentClass.js +111 -0
- package/build/esm/vite/agentClass.js.map +1 -0
- package/build/esm/vite/autoInstrument.js +17 -4
- package/build/esm/vite/autoInstrument.js.map +1 -1
- package/build/esm/vite/index.js +1 -1
- package/build/esm/vite/index.js.map +1 -1
- package/build/esm/vite/moduleShape.js +227 -0
- package/build/esm/vite/moduleShape.js.map +1 -0
- package/build/esm/vite/transform.js +6 -1
- package/build/esm/vite/transform.js.map +1 -1
- package/build/esm/vite/wranglerConfig.js +1 -1
- package/build/esm/vite/wranglerConfig.js.map +1 -1
- package/build/types/client.d.ts +37 -0
- package/build/types/client.d.ts.map +1 -1
- package/build/types/durableobject.d.ts +81 -0
- package/build/types/durableobject.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrumentations/agents/index.d.ts +24 -0
- package/build/types/instrumentations/agents/index.d.ts.map +1 -0
- package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts +11 -0
- package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts.map +1 -0
- package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts +22 -0
- package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts.map +1 -0
- package/build/types/instrumentations/agents/types.d.ts +49 -0
- package/build/types/instrumentations/agents/types.d.ts.map +1 -0
- package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
- package/build/types/integrations/spotlight.d.ts +22 -0
- package/build/types/integrations/spotlight.d.ts.map +1 -0
- package/build/types/options.d.ts.map +1 -1
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types/utils/internalSqlQuery.d.ts +4 -2
- package/build/types/utils/internalSqlQuery.d.ts.map +1 -1
- package/build/types/utils/internalStorageKey.d.ts +22 -0
- package/build/types/utils/internalStorageKey.d.ts.map +1 -0
- package/build/types/vite/agentClass.d.ts +41 -0
- package/build/types/vite/agentClass.d.ts.map +1 -0
- package/build/types/vite/autoInstrument.d.ts +7 -6
- package/build/types/vite/autoInstrument.d.ts.map +1 -1
- package/build/types/vite/index.d.ts +14 -4
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/vite/moduleShape.d.ts +52 -0
- package/build/types/vite/moduleShape.d.ts.map +1 -0
- package/build/types/vite/transform.d.ts +6 -1
- package/build/types/vite/transform.d.ts.map +1 -1
- package/build/types-ts3.8/client.d.ts +37 -0
- package/build/types-ts3.8/durableobject.d.ts +81 -0
- package/build/types-ts3.8/index.d.ts +2 -1
- package/build/types-ts3.8/instrumentations/agents/index.d.ts +24 -0
- package/build/types-ts3.8/instrumentations/agents/instrumentAgentCallableRpc.d.ts +11 -0
- package/build/types-ts3.8/instrumentations/agents/instrumentChatAgentConversation.d.ts +22 -0
- package/build/types-ts3.8/instrumentations/agents/types.d.ts +49 -0
- package/build/types-ts3.8/integrations/spotlight.d.ts +22 -0
- package/build/types-ts3.8/utils/internalSqlQuery.d.ts +4 -2
- package/build/types-ts3.8/utils/internalStorageKey.d.ts +22 -0
- package/build/types-ts3.8/vite/agentClass.d.ts +41 -0
- package/build/types-ts3.8/vite/autoInstrument.d.ts +7 -6
- package/build/types-ts3.8/vite/index.d.ts +14 -4
- package/build/types-ts3.8/vite/moduleShape.d.ts +52 -0
- package/build/types-ts3.8/vite/transform.d.ts +6 -1
- package/package.json +3 -3
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
import { DurableObject } from 'cloudflare:workers';
|
|
2
2
|
import { CloudflareOptions } from './client';
|
|
3
|
+
/**
|
|
4
|
+
* The instrumented context passed between the shared construction helpers.
|
|
5
|
+
*
|
|
6
|
+
* This is intentionally `any` rather than `ReturnType<typeof instrumentContext<DurableObjectState>>`.
|
|
7
|
+
* A concrete `DurableObjectState` here forces `tsc` to structurally relate its `storage: SqlStorage`
|
|
8
|
+
* graph against the `ExecutionContext | InstrumentedDurableObjectState` parameter of
|
|
9
|
+
* `wrapMethodWithSentry`, while the RPC-branded `DurableObject` from `cloudflare:workers` is also in
|
|
10
|
+
* scope. That union comparison explodes (1296×1296) and hangs the type build. The original inline
|
|
11
|
+
* implementation avoided this only incidentally, because `ctx` reached it as `any` through the Proxy
|
|
12
|
+
* `construct` trap. Keeping the shared context `any` preserves that behavior.
|
|
13
|
+
*/
|
|
14
|
+
type InstrumentedDurableObjectContext = any;
|
|
15
|
+
/**
|
|
16
|
+
* Constructs a Durable Object instance and instruments its built-in handler methods
|
|
17
|
+
* (`fetch`, `alarm`, `webSocketMessage`, `webSocketClose`, `webSocketError`).
|
|
18
|
+
*
|
|
19
|
+
* This is the shared construction path used by both {@link instrumentDurableObjectWithSentry}
|
|
20
|
+
* and {@link instrumentAgentWithSentry}. It intentionally does NOT apply the RPC prototype-method
|
|
21
|
+
* proxy — callers apply that last via {@link finalizeWithRpcInstrumentation}, after any additional
|
|
22
|
+
* per-instance instrumentation has been layered onto the returned object.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare function constructInstrumentedDurableObject<E, T extends DurableObject<E>>(target: new (state: DurableObjectState, env: E) => T, ctx: DurableObjectState, env: E, newTarget: NewableFunction, optionsCallback: (env: E) => CloudflareOptions): {
|
|
27
|
+
obj: T;
|
|
28
|
+
options: CloudflareOptions;
|
|
29
|
+
context: InstrumentedDurableObjectContext;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Wraps a constructed (and already handler-instrumented) Durable Object instance with the RPC
|
|
33
|
+
* prototype-method proxy, when RPC trace propagation is enabled. Returns the object unchanged when
|
|
34
|
+
* RPC instrumentation is disabled.
|
|
35
|
+
*
|
|
36
|
+
* This must be applied last, so that any per-instance instrumentation (own properties such as
|
|
37
|
+
* `fetch`, `alarm`, or Agent-specific handlers) is excluded from RPC method tracing.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare function finalizeWithRpcInstrumentation<T extends object>(obj: T, options: CloudflareOptions, context: InstrumentedDurableObjectContext): T;
|
|
3
42
|
/**
|
|
4
43
|
* Instruments a Durable Object class to capture errors and performance data.
|
|
5
44
|
*
|
|
@@ -34,4 +73,46 @@ import { CloudflareOptions } from './client';
|
|
|
34
73
|
* ```
|
|
35
74
|
*/
|
|
36
75
|
export declare function instrumentDurableObjectWithSentry<E, T extends DurableObject<E>, C extends new (state: DurableObjectState, env: E) => T>(optionsCallback: (env: E) => CloudflareOptions, DurableObjectClass: C): C;
|
|
76
|
+
/**
|
|
77
|
+
* Instruments a Cloudflare [`agents`](https://www.npmjs.com/package/agents) Agent class with Sentry.
|
|
78
|
+
*
|
|
79
|
+
* An `Agent` is a Durable Object under the hood, so this applies the same instrumentation as
|
|
80
|
+
* {@link instrumentDurableObjectWithSentry} (request transactions, `alarm`, WebSocket handlers, RPC
|
|
81
|
+
* trace propagation, SQL spans) and additionally captures Agent-specific telemetry via
|
|
82
|
+
* `instrumentCloudflareAgent`:
|
|
83
|
+
*
|
|
84
|
+
* - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.
|
|
85
|
+
* - **Breadcrumbs** — for every Agent observability event (`rpc`, `state:update`, `connect`,
|
|
86
|
+
* `disconnect`, `schedule:*`, `queue:*`, `workflow:*`, `email:*`, `mcp:*`, ...).
|
|
87
|
+
*
|
|
88
|
+
* Cloudflare Workers cannot auto-instrument, so the Agent class must be wrapped manually.
|
|
89
|
+
*
|
|
90
|
+
* @param optionsCallback Function that returns the options for the SDK initialization.
|
|
91
|
+
* @param AgentClass The Agent class to instrument.
|
|
92
|
+
* @returns The instrumented Agent class.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* import { Agent, callable, routeAgentRequest } from 'agents';
|
|
97
|
+
* import * as Sentry from '@sentry/cloudflare';
|
|
98
|
+
*
|
|
99
|
+
* class MyAgentBase extends Agent<Env> {
|
|
100
|
+
* @callable()
|
|
101
|
+
* async greet(name: string): Promise<string> {
|
|
102
|
+
* return `Hello, ${name}!`;
|
|
103
|
+
* }
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* export const MyAgent = Sentry.instrumentAgentWithSentry(
|
|
107
|
+
* env => ({
|
|
108
|
+
* dsn: env.SENTRY_DSN,
|
|
109
|
+
* tracesSampleRate: 1.0,
|
|
110
|
+
* enableRpcTracePropagation: true,
|
|
111
|
+
* }),
|
|
112
|
+
* MyAgentBase,
|
|
113
|
+
* );
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare function instrumentAgentWithSentry<E, T extends DurableObject<E>, C extends new (state: DurableObjectState, env: E) => T>(optionsCallback: (env: E) => CloudflareOptions, AgentClass: C): C;
|
|
117
|
+
export {};
|
|
37
118
|
//# sourceMappingURL=durableobject.d.ts.map
|
|
@@ -3,13 +3,14 @@ export { CloudflareOptions } from './client';
|
|
|
3
3
|
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureFeedback, close, createTransport, lastEventId, flush, getClient, isInitialized, isEnabled, getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, Scope, SDK_VERSION, setContext, setExtra, setExtras, setTag, setTags, setAttribute, setAttributes, setUser, setConversationId, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, captureCheckIn, withMonitor, setMeasurement, getActiveSpan, getRootSpan, getTraceData, getTraceMetaTags, startSpan, startInactiveSpan, startSpanManual, startNewTrace, bindScopeToEmitter, suppressTracing, withActiveSpan, getSpanDescendants, continueTrace, functionToStringIntegration, inboundFiltersIntegration, instrumentOpenAiClient, instrumentGoogleGenAIClient, instrumentAnthropicAiClient, eventFiltersIntegration, linkedErrorsIntegration, requestDataIntegration, extraErrorDataIntegration, dedupeIntegration, rewriteFramesIntegration, captureConsoleIntegration, moduleMetadataIntegration, supabaseIntegration, instrumentSupabaseClient, instrumentPostgresJsSql, zodErrorsIntegration, consoleIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, trpcMiddleware, spanToJSON, spanToTraceHeader, spanToBaggageHeader, updateSpanName, wrapMcpServerWithSentry, consoleLoggingIntegration, createConsolaReporter, createLangChainCallbackHandler, instrumentLangChainEmbeddings, featureFlagsIntegration, growthbookIntegration, logger, metrics, withStreamedSpan, spanStreamingIntegration, instrumentStateGraph, instrumentLangGraph, instrumentCreateReactAgent, } from '@sentry/core';
|
|
4
4
|
export { withSentry } from './withSentry';
|
|
5
5
|
export { defineCloudflareOptions } from './defineCloudflareOptions';
|
|
6
|
-
export { instrumentDurableObjectWithSentry } from './durableobject';
|
|
6
|
+
export { instrumentAgentWithSentry, instrumentDurableObjectWithSentry } from './durableobject';
|
|
7
7
|
export { sentryPagesPlugin } from './pages-plugin';
|
|
8
8
|
export { wrapRequestHandler } from './request';
|
|
9
9
|
export { CloudflareClient } from './client';
|
|
10
10
|
export { getDefaultIntegrations } from './sdk';
|
|
11
11
|
export { httpServerIntegration } from './integrations/httpServer';
|
|
12
12
|
export { fetchIntegration } from './integrations/fetch';
|
|
13
|
+
export { spotlightIntegration } from './integrations/spotlight';
|
|
13
14
|
export { vercelAIIntegration } from './integrations/tracing/vercelai';
|
|
14
15
|
export { honoIntegration } from './integrations/hono';
|
|
15
16
|
export { instrumentD1WithSentry } from './instrumentations/worker/instrumentD1';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instruments an instance of a Cloudflare [`agents`](https://www.npmjs.com/package/agents) `Agent`
|
|
3
|
+
* with Sentry, adding telemetry that is specific to the Agent's runtime behavior:
|
|
4
|
+
*
|
|
5
|
+
* - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.
|
|
6
|
+
* - **Conversation correlation** — sets the conversation id on the scope for each unit of agent
|
|
7
|
+
* work — chat turn or callable RPC call — so `gen_ai` spans created within it are correlated, for
|
|
8
|
+
* chat and plain agents alike. Defaults to the instance `name` and is rotated when the chat is
|
|
9
|
+
* cleared (the `message:clear` observability event).
|
|
10
|
+
*
|
|
11
|
+
* It only hooks the `agents` package internals and uses Sentry's tracing primitives. On Cloudflare
|
|
12
|
+
* Workers, prefer `instrumentAgentWithSentry`, which additionally instruments the Durable Object
|
|
13
|
+
* handlers and initializes the SDK; that function calls this one internally.
|
|
14
|
+
*
|
|
15
|
+
* The hooks replace own-properties on the instance and defer to the original implementation, so
|
|
16
|
+
* they compose with any other instrumentation applied to the same instance.
|
|
17
|
+
*
|
|
18
|
+
* @param agent The `agents` `Agent` instance to instrument.
|
|
19
|
+
* @returns The same instance, instrumented.
|
|
20
|
+
*
|
|
21
|
+
* @internal Use `instrumentAgentWithSentry` instead — this is called internally by it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function instrumentCloudflareAgent<T extends object>(agent: T): T;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AgentInternals } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps the Agent's `onMessage` handler to create a span for each `@callable()` RPC invocation.
|
|
4
|
+
* RPC requests arrive as WebSocket messages, so this span nests under the active transaction for
|
|
5
|
+
* the WebSocket message (on Cloudflare, the instrumented Durable Object `webSocketMessage` hook).
|
|
6
|
+
*
|
|
7
|
+
* Also sets the conversation id on the scope for the duration of the call: callable methods are the
|
|
8
|
+
* unit of work for plain (non-chat) agents, which run LLM calls just like chat turns do.
|
|
9
|
+
*/
|
|
10
|
+
export declare function instrumentAgentCallableRpc(obj: AgentInternals): void;
|
|
11
|
+
//# sourceMappingURL=instrumentAgentCallableRpc.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AgentInternals } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* For chat agents (`AIChatAgent` from `@cloudflare/ai-chat`), correlates each chat turn's AI spans
|
|
4
|
+
* with a conversation id on the active scope.
|
|
5
|
+
*
|
|
6
|
+
* In the Agents model one agent instance is one long-lived conversation, so the instance `name` is
|
|
7
|
+
* the base conversation id. When the user clears the chat, they expect a fresh conversation — but
|
|
8
|
+
* recreating the Durable Object for that would also drop the MCP/OAuth state stored per instance
|
|
9
|
+
* (GitHub/Sentry sign-in). To get a fresh conversation id *without* losing that state, we rotate an
|
|
10
|
+
* in-memory id on the instance when the SDK reports a cleared chat, and stamp that (falling back to
|
|
11
|
+
* the instance `name` before the first clear).
|
|
12
|
+
*
|
|
13
|
+
* The id itself is not attached to spans here — the SDK's `conversationIdIntegration` reads it off
|
|
14
|
+
* the scope at `spanStart` and stamps `gen_ai.conversation.id` onto the AI spans created inside the
|
|
15
|
+
* turn (e.g. by the Workers AI instrumentation), which correlates a turn's model and tool calls.
|
|
16
|
+
*
|
|
17
|
+
* Plain (non-chat) `Agent`s do not define `onChatMessage`, so they are skipped here — their unit
|
|
18
|
+
* of work is the callable RPC method, where `instrumentAgentCallableRpc` sets the conversation id
|
|
19
|
+
* instead.
|
|
20
|
+
*/
|
|
21
|
+
export declare function instrumentChatAgentConversation(obj: AgentInternals): void;
|
|
22
|
+
//# sourceMappingURL=instrumentChatAgentConversation.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const AGENT_SPAN_ORIGIN = "auto.faas.cloudflare.agents";
|
|
2
|
+
export declare const AGENT_CLASS_ATTRIBUTE = "cloudflare.agent.class";
|
|
3
|
+
export declare const AGENT_NAME_ATTRIBUTE = "cloudflare.agent.name";
|
|
4
|
+
/**
|
|
5
|
+
* The subset of the `agents` `Agent` instance internals that we instrument. These are runtime
|
|
6
|
+
* implementation details of the `agents` package (v0.13.x) rather than part of its public type
|
|
7
|
+
* surface, so every access is guarded and wrapping degrades gracefully if a name changes upstream.
|
|
8
|
+
*/
|
|
9
|
+
export interface AgentInternals {
|
|
10
|
+
/** Central choke-point through which all `agents:*` observability events are published. */
|
|
11
|
+
_emit?: (type: string, payload?: Record<string, unknown>) => void;
|
|
12
|
+
/** WebSocket message handler; dispatches `@callable()` RPC requests. */
|
|
13
|
+
onMessage?: (...args: unknown[]) => unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Chat-turn handler. Only `AIChatAgent` (from `@cloudflare/ai-chat`) defines this; a plain `Agent`
|
|
16
|
+
* does not, so its presence discriminates a chat agent.
|
|
17
|
+
*/
|
|
18
|
+
onChatMessage?: (...args: unknown[]) => unknown;
|
|
19
|
+
/** The user's Agent class (used by the SDK for the observability event `agent` field). */
|
|
20
|
+
_ParentClass?: {
|
|
21
|
+
name?: string;
|
|
22
|
+
};
|
|
23
|
+
/** The Agent instance name, which in the Agents model identifies the conversation/thread. */
|
|
24
|
+
name?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Internal: the active conversation id, rotated when the chat is cleared (the `message:clear`
|
|
27
|
+
* observability event) so a reset chat groups as a fresh conversation while the instance (and its
|
|
28
|
+
* MCP/OAuth state) stays put. Set by `instrumentChatAgentConversation`; falls back to `name`
|
|
29
|
+
* before the first clear.
|
|
30
|
+
*/
|
|
31
|
+
__sentryConversationId?: string;
|
|
32
|
+
}
|
|
33
|
+
/** Reads best-effort agent identity attributes from the instance, tolerating missing internals. */
|
|
34
|
+
export declare function getAgentAttributes(instance: AgentInternals): Record<string, string>;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the agent instance's conversation id on the current scope for the duration of the
|
|
37
|
+
* surrounding unit of work (chat turn, callable RPC call). In the Agents model one instance is one
|
|
38
|
+
* conversation, so the instance `name` is the natural conversation id — for chat and plain agents
|
|
39
|
+
* alike, since plain agents run LLM calls too (e.g. inside `@callable()` methods). Once the chat
|
|
40
|
+
* has been cleared, the rotated `__sentryConversationId` takes precedence so LLM calls from any
|
|
41
|
+
* unit of work group under the fresh conversation.
|
|
42
|
+
*
|
|
43
|
+
* `conversationIdIntegration` reads the id off the scope at `spanStart` and stamps
|
|
44
|
+
* `gen_ai.conversation.id` onto AI spans created within the unit of work, correlating its model
|
|
45
|
+
* and tool calls. Callers run inside a per-event forked scope (`wrapMethodWithSentry`), so the id
|
|
46
|
+
* does not leak into unrelated events.
|
|
47
|
+
*/
|
|
48
|
+
export declare function setAgentConversationId(instance: AgentInternals): void;
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type SpotlightConnectionOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Set this if the Spotlight Sidecar is not running on localhost:8969.
|
|
4
|
+
* By default, the URL is set to http://localhost:8969/stream
|
|
5
|
+
*/
|
|
6
|
+
sidecarUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const INTEGRATION_NAME: "Spotlight";
|
|
9
|
+
/**
|
|
10
|
+
* Use this integration to send errors and transactions to Spotlight.
|
|
11
|
+
*
|
|
12
|
+
* Learn more about spotlight at https://spotlightjs.com
|
|
13
|
+
*
|
|
14
|
+
* Important: This integration is intended for local development only.
|
|
15
|
+
* Each forwarded envelope counts as a Worker subrequest (50 free / 1000 paid
|
|
16
|
+
* per invocation), so it should not be enabled in production.
|
|
17
|
+
*/
|
|
18
|
+
export declare const spotlightIntegration: (options?: Partial<SpotlightConnectionOptions> | undefined) => import("@sentry/core").Integration & {
|
|
19
|
+
name: "Spotlight";
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=spotlight.d.ts.map
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
*
|
|
13
13
|
* The check operates on the query summary produced by `getSqlQuerySummary` (`{operation} {table} ...`,
|
|
14
14
|
* the same value used as the span name), so table targets are already isolated from the rest of the
|
|
15
|
-
* query.
|
|
15
|
+
* query. The one exception is `CREATE INDEX`: its summary carries the index name, not the indexed
|
|
16
|
+
* table (upstream OTel convention), so the `cf_` target only appears in the ON clause of the full
|
|
17
|
+
* statement, which `queryText` is needed for.
|
|
16
18
|
*/
|
|
17
|
-
export declare function targetsCloudflareInternalTable(querySummary: string | undefined, allowlist?: Array<string | RegExp
|
|
19
|
+
export declare function targetsCloudflareInternalTable(querySummary: string | undefined, allowlist?: Array<string | RegExp>, queryText?: string): boolean;
|
|
18
20
|
//# sourceMappingURL=internalSqlQuery.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare frameworks that build on Durable Objects (`agents`, `partyserver`, ...) also manage
|
|
3
|
+
* their own internal KV entries alongside their internal SQLite tables, namespaced with a reserved
|
|
4
|
+
* prefix — e.g. `cf_agents_state`, `cf_agents_mcp_servers`, `__ps_name`. Reads/writes of these
|
|
5
|
+
* (message persistence, MCP connection bookkeeping, name hydration) are framework implementation
|
|
6
|
+
* details that otherwise flood traces with dozens of zero-signal `durable_object_storage_*` spans
|
|
7
|
+
* per request, so we match the reserved prefixes rather than an enumerated list. This mirrors the
|
|
8
|
+
* `cf_` convention used for internal SQL tables (see `targetsCloudflareInternalTable`).
|
|
9
|
+
*
|
|
10
|
+
* The prefixes are a reserved convention for framework-managed entries, so user keys should not use
|
|
11
|
+
* them. In case a user key does collide, the `durableObjectStorageSpanAllowlist` option lets them
|
|
12
|
+
* opt those keys back into instrumentation.
|
|
13
|
+
*/
|
|
14
|
+
export declare function targetsCloudflareInternalKey(key: string | undefined, allowlist?: Array<string | RegExp>): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Extracts the KV keys a Durable Object storage call targets, so the caller can decide whether the
|
|
17
|
+
* operation only touches framework-internal entries. Returns `undefined` when the keys can't be
|
|
18
|
+
* determined from the arguments (e.g. `list()` without a prefix), in which case the call is treated
|
|
19
|
+
* as user work and stays instrumented.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getStorageKeys(methodName: string, args: unknown[]): string[] | undefined;
|
|
22
|
+
//# sourceMappingURL=internalStorageKey.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ProgramBody } from './transform';
|
|
2
|
+
/**
|
|
3
|
+
* The subset of the Vite/Rollup plugin context needed to walk the module graph.
|
|
4
|
+
*
|
|
5
|
+
* `resolve` is optional: without it detection still works, but only for base-class chains declared
|
|
6
|
+
* inside the entry module itself. `readFile` is injectable for tests and defaults to reading disk.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately **no `load`**: awaiting the plugin context's `load()` from inside a `transform` hook
|
|
9
|
+
* deadlocks the build — the module cannot finish loading while its own transform is still pending
|
|
10
|
+
* (Rollup documents this hazard, and Vite's Rolldown pipeline is stricter still). Sibling modules
|
|
11
|
+
* are therefore read straight off disk; see {@link getModuleShape}.
|
|
12
|
+
*/
|
|
13
|
+
export interface ModuleResolver {
|
|
14
|
+
parse(code: string): ProgramBody;
|
|
15
|
+
resolve?(source: string, importer: string): Promise<{
|
|
16
|
+
id: string;
|
|
17
|
+
} | null | undefined>;
|
|
18
|
+
readFile?(id: string): string | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Find which of `candidates` (top-level class names in the entry module) are Cloudflare
|
|
22
|
+
* [`agents`](https://www.npmjs.com/package/agents) Agents.
|
|
23
|
+
*
|
|
24
|
+
* An Agent is a Durable Object under the hood, so wrangler configures it as one and the transform
|
|
25
|
+
* would otherwise reach for `instrumentDurableObjectWithSentry`. Detecting the Agent base chain lets
|
|
26
|
+
* it pick `instrumentAgentWithSentry` instead, which adds the Agent-specific telemetry on top.
|
|
27
|
+
*
|
|
28
|
+
* Unlike `WorkerEntrypoint` detection, the chain is followed *across* modules: base classes commonly
|
|
29
|
+
* live in their own file (`import { MyBase } from './base'`), and there is no runtime fallback that
|
|
30
|
+
* would catch a missed one. Resolution stops at package boundaries — a base class imported from
|
|
31
|
+
* `node_modules` is only recognized when it is one of {@link AGENT_BASE_CLASSES}.
|
|
32
|
+
*/
|
|
33
|
+
export declare function detectAgentClasses(ast: ProgramBody, entryId: string, candidates: Iterable<string>, resolver: ModuleResolver): Promise<Set<string>>;
|
|
34
|
+
/**
|
|
35
|
+
* The local class names in the entry that a configured class name could refer to — either declared
|
|
36
|
+
* under that name directly, or aliased to it by an `export { Local as Configured }` specifier.
|
|
37
|
+
*
|
|
38
|
+
* Keeps detection (which reads and scans other modules) off classes that no binding points at.
|
|
39
|
+
*/
|
|
40
|
+
export declare function collectAgentCandidates(ast: ProgramBody, configuredNames: Iterable<string>): Set<string>;
|
|
41
|
+
//# sourceMappingURL=agentClass.d.ts.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function sentryCloudflareAutoInstrumentPlugin(
|
|
1
|
+
import { ModuleResolver } from './agentClass';
|
|
2
|
+
export declare function sentryCloudflareAutoInstrumentPlugin(options?: {
|
|
3
|
+
wranglerConfigPath?: string;
|
|
4
|
+
}): {
|
|
3
5
|
name: string;
|
|
4
6
|
configResolved(config: {
|
|
5
7
|
root: string;
|
|
@@ -7,15 +9,14 @@ export declare function sentryCloudflareAutoInstrumentPlugin(): {
|
|
|
7
9
|
warn(msg: string): void;
|
|
8
10
|
};
|
|
9
11
|
}): void;
|
|
10
|
-
transform(this: {
|
|
11
|
-
parse(code: string): ProgramBody;
|
|
12
|
+
transform(this: ModuleResolver & {
|
|
12
13
|
warn?(msg: string): void;
|
|
13
14
|
environment?: {
|
|
14
15
|
name?: string;
|
|
15
16
|
};
|
|
16
|
-
}, code: string, id: string): {
|
|
17
|
+
}, code: string, id: string): Promise<{
|
|
17
18
|
code: string;
|
|
18
19
|
map: unknown;
|
|
19
|
-
} | undefined
|
|
20
|
+
} | undefined>;
|
|
20
21
|
};
|
|
21
22
|
//# sourceMappingURL=autoInstrument.d.ts.map
|
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* Options for {@link sentryCloudflareVitePlugin}.
|
|
3
3
|
*/
|
|
4
4
|
export interface SentryCloudflareVitePluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Path to the wrangler config, relative to the Vite root (or absolute).
|
|
7
|
+
* Set this when your config doesn't use a default name — e.g. when you
|
|
8
|
+
* pass `configPath: './wrangler.agent.jsonc'` to `@cloudflare/vite-plugin`,
|
|
9
|
+
* which the Sentry plugin cannot see. When set, only this file is read
|
|
10
|
+
* (no default-name probing), and a warning is emitted if it is missing or
|
|
11
|
+
* unparseable.
|
|
12
|
+
*
|
|
13
|
+
* @default undefined (probes `wrangler.json`, `wrangler.jsonc`, `wrangler.toml` at the Vite root)
|
|
14
|
+
*/
|
|
15
|
+
wranglerConfigPath?: string;
|
|
5
16
|
/**
|
|
6
17
|
* Experimental options that may change or be removed without notice.
|
|
7
18
|
*/
|
|
@@ -74,15 +85,14 @@ export declare function sentryCloudflareVitePlugin(options?: SentryCloudflareVit
|
|
|
74
85
|
warn(msg: string): void;
|
|
75
86
|
};
|
|
76
87
|
}): void;
|
|
77
|
-
transform(this: {
|
|
78
|
-
parse(code: string): import("./transform").ProgramBody;
|
|
88
|
+
transform(this: import("./agentClass").ModuleResolver & {
|
|
79
89
|
warn?(msg: string): void;
|
|
80
90
|
environment?: {
|
|
81
91
|
name?: string;
|
|
82
92
|
};
|
|
83
|
-
}, code: string, id: string): {
|
|
93
|
+
}, code: string, id: string): Promise<{
|
|
84
94
|
code: string;
|
|
85
95
|
map: unknown;
|
|
86
|
-
} | undefined
|
|
96
|
+
} | undefined>;
|
|
87
97
|
} | import("vite").Plugin<any>)[];
|
|
88
98
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ProgramBody } from './transform';
|
|
2
|
+
/** Binding name used for a module's default export. */
|
|
3
|
+
export declare const DEFAULT_EXPORT = "default";
|
|
4
|
+
/** A resolved superclass reference: a bare identifier or a `ns.Member` expression. */
|
|
5
|
+
export type SuperRef = {
|
|
6
|
+
kind: 'identifier';
|
|
7
|
+
name: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'member';
|
|
10
|
+
object: string;
|
|
11
|
+
property: string;
|
|
12
|
+
};
|
|
13
|
+
/** The declarations of a single module that binding resolution needs. */
|
|
14
|
+
export interface ModuleShape {
|
|
15
|
+
/** Top-level class names → their superclass reference (absent when the class has no `extends`). */
|
|
16
|
+
classes: Map<string, SuperRef | undefined>;
|
|
17
|
+
/** Local binding name → the import it came from (`imported` is `default` for a default import). */
|
|
18
|
+
imports: Map<string, {
|
|
19
|
+
source: string;
|
|
20
|
+
imported: string;
|
|
21
|
+
}>;
|
|
22
|
+
/** Local binding name → module specifier, for `import * as ns from '...'`. */
|
|
23
|
+
namespaces: Map<string, string>;
|
|
24
|
+
/** Exported name → the re-export it came from, for `export { x as y } from '...'`. */
|
|
25
|
+
reexports: Map<string, {
|
|
26
|
+
source: string;
|
|
27
|
+
imported: string;
|
|
28
|
+
}>;
|
|
29
|
+
/** Exported name → local binding name, for `export { x as y }` without a source. */
|
|
30
|
+
localExports: Map<string, string>;
|
|
31
|
+
/** Module specifiers of bare `export * from '...'` declarations. */
|
|
32
|
+
starExports: string[];
|
|
33
|
+
/** `export default <Identifier>` — the local name it refers to. */
|
|
34
|
+
defaultExportName?: string;
|
|
35
|
+
/** True when the module's default export is a class declaration/expression. */
|
|
36
|
+
defaultExportIsClass?: boolean;
|
|
37
|
+
/** Superclass of an anonymous `export default class extends X`. */
|
|
38
|
+
defaultExportSuper?: SuperRef;
|
|
39
|
+
}
|
|
40
|
+
/** Collect the shape of a module from its parsed AST — used for the already-parsed entry module. */
|
|
41
|
+
export declare function shapeFromAst(ast: ProgramBody): ModuleShape;
|
|
42
|
+
/**
|
|
43
|
+
* Extract the module shape from **unprocessed source**.
|
|
44
|
+
*
|
|
45
|
+
* Sibling modules are read straight from disk (the plugin context's `load()` would deadlock inside a
|
|
46
|
+
* transform hook), so they may still be TypeScript — which no JS parser will accept. Only
|
|
47
|
+
* import/export statements and `class X extends Y` headers matter here, and those are
|
|
48
|
+
* declaration-level syntax a scan can pick out reliably; class bodies, type annotations and generics
|
|
49
|
+
* are irrelevant and simply skipped.
|
|
50
|
+
*/
|
|
51
|
+
export declare function shapeFromSource(rawCode: string): ModuleShape;
|
|
52
|
+
//# sourceMappingURL=moduleShape.d.ts.map
|
|
@@ -18,7 +18,7 @@ export interface ProgramBody {
|
|
|
18
18
|
* config providing only a fallback for self-bound entrypoints whose base class
|
|
19
19
|
* lives in another module.
|
|
20
20
|
*/
|
|
21
|
-
export type ClassWrapperKind = 'durableObject' | 'workflow' | 'workerEntrypoint';
|
|
21
|
+
export type ClassWrapperKind = 'durableObject' | 'agent' | 'workflow' | 'workerEntrypoint';
|
|
22
22
|
export interface TransformContext {
|
|
23
23
|
/**
|
|
24
24
|
* Exported class name → the kind of Sentry wrapper to apply. Populated from
|
|
@@ -26,6 +26,11 @@ export interface TransformContext {
|
|
|
26
26
|
* each class's base type.
|
|
27
27
|
*/
|
|
28
28
|
classWrappers: Map<string, ClassWrapperKind>;
|
|
29
|
+
/**
|
|
30
|
+
* Local class names detected as `agents` Agents. An Agent is configured as a Durable Object in
|
|
31
|
+
* wrangler, so this upgrades those entries from `durableObject` to `agent`.
|
|
32
|
+
*/
|
|
33
|
+
agentClasses?: ReadonlySet<string>;
|
|
29
34
|
optionsFn: string;
|
|
30
35
|
/** Import statement prepended when `optionsFn` references a separate module. */
|
|
31
36
|
optionsImport?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/cloudflare",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.69.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",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@opentelemetry/api": "^1.9.1",
|
|
73
|
-
"@sentry/core": "10.
|
|
74
|
-
"@sentry/server-utils": "10.
|
|
73
|
+
"@sentry/core": "10.69.0",
|
|
74
|
+
"@sentry/server-utils": "10.69.0",
|
|
75
75
|
"magic-string": "~0.30.21"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|