@sentry/cloudflare 9.15.0 → 9.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/build/cjs/durableobject.js +213 -0
  2. package/build/cjs/durableobject.js.map +1 -0
  3. package/build/cjs/handler.js +56 -66
  4. package/build/cjs/handler.js.map +1 -1
  5. package/build/cjs/index.js +5 -0
  6. package/build/cjs/index.js.map +1 -1
  7. package/build/cjs/instrument.js +27 -0
  8. package/build/cjs/instrument.js.map +1 -0
  9. package/build/cjs/logs/exports.js +213 -0
  10. package/build/cjs/logs/exports.js.map +1 -0
  11. package/build/cjs/options.js +23 -0
  12. package/build/cjs/options.js.map +1 -0
  13. package/build/cjs/request.js +12 -0
  14. package/build/cjs/request.js.map +1 -1
  15. package/build/cjs/sdk.js +1 -0
  16. package/build/cjs/sdk.js.map +1 -1
  17. package/build/esm/durableobject.js +211 -0
  18. package/build/esm/durableobject.js.map +1 -0
  19. package/build/esm/handler.js +56 -66
  20. package/build/esm/handler.js.map +1 -1
  21. package/build/esm/index.js +4 -1
  22. package/build/esm/index.js.map +1 -1
  23. package/build/esm/instrument.js +24 -0
  24. package/build/esm/instrument.js.map +1 -0
  25. package/build/esm/logs/exports.js +206 -0
  26. package/build/esm/logs/exports.js.map +1 -0
  27. package/build/esm/options.js +21 -0
  28. package/build/esm/options.js.map +1 -0
  29. package/build/esm/package.json +1 -1
  30. package/build/esm/request.js +13 -1
  31. package/build/esm/request.js.map +1 -1
  32. package/build/esm/sdk.js +1 -0
  33. package/build/esm/sdk.js.map +1 -1
  34. package/build/types/durableobject.d.ts +38 -0
  35. package/build/types/durableobject.d.ts.map +1 -0
  36. package/build/types/handler.d.ts +2 -7
  37. package/build/types/handler.d.ts.map +1 -1
  38. package/build/types/index.d.ts +3 -1
  39. package/build/types/index.d.ts.map +1 -1
  40. package/build/types/instrument.d.ts +9 -0
  41. package/build/types/instrument.d.ts.map +1 -0
  42. package/build/types/logs/exports.d.ts +169 -0
  43. package/build/types/logs/exports.d.ts.map +1 -0
  44. package/build/types/options.d.ts +12 -0
  45. package/build/types/options.d.ts.map +1 -0
  46. package/build/types/request.d.ts.map +1 -1
  47. package/build/types/sdk.d.ts.map +1 -1
  48. package/build/types-ts3.8/durableobject.d.ts +38 -0
  49. package/build/types-ts3.8/handler.d.ts +2 -7
  50. package/build/types-ts3.8/index.d.ts +4 -1
  51. package/build/types-ts3.8/instrument.d.ts +9 -0
  52. package/build/types-ts3.8/logs/exports.d.ts +169 -0
  53. package/build/types-ts3.8/options.d.ts +12 -0
  54. package/package.json +2 -2
@@ -0,0 +1,213 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const async = require('./async.js');
5
+ const instrument = require('./instrument.js');
6
+ const options = require('./options.js');
7
+ const request = require('./request.js');
8
+ const sdk = require('./sdk.js');
9
+
10
+ /* eslint-disable @typescript-eslint/unbound-method */
11
+
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ function wrapMethodWithSentry(
14
+ wrapperOptions,
15
+ handler,
16
+ callback,
17
+ ) {
18
+ if (instrument.isInstrumented(handler)) {
19
+ return handler;
20
+ }
21
+
22
+ instrument.markAsInstrumented(handler);
23
+
24
+ return new Proxy(handler, {
25
+ apply(target, thisArg, args) {
26
+ const currentClient = core.getClient();
27
+ // if a client is already set, use withScope, otherwise use withIsolationScope
28
+ const sentryWithScope = currentClient ? core.withScope : core.withIsolationScope;
29
+ return sentryWithScope(async scope => {
30
+ // In certain situations, the passed context can become undefined.
31
+ // For example, for Astro while prerendering pages at build time.
32
+ // see: https://github.com/getsentry/sentry-javascript/issues/13217
33
+ const context = wrapperOptions.context ;
34
+
35
+ const currentClient = scope.getClient();
36
+ if (!currentClient) {
37
+ const client = sdk.init(wrapperOptions.options);
38
+ scope.setClient(client);
39
+ }
40
+
41
+ if (!wrapperOptions.spanName) {
42
+ try {
43
+ if (callback) {
44
+ callback(...args);
45
+ }
46
+ return await Reflect.apply(target, thisArg, args);
47
+ } catch (e) {
48
+ core.captureException(e, {
49
+ mechanism: {
50
+ type: 'cloudflare_durableobject',
51
+ handled: false,
52
+ },
53
+ });
54
+ throw e;
55
+ } finally {
56
+ context?.waitUntil(core.flush(2000));
57
+ }
58
+ }
59
+
60
+ const attributes = wrapperOptions.spanOp
61
+ ? {
62
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,
63
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare_durableobjects',
64
+ }
65
+ : {};
66
+
67
+ // Only create these spans if they have a parent span.
68
+ return core.startSpan({ name: wrapperOptions.spanName, attributes, onlyIfParent: true }, async () => {
69
+ try {
70
+ return await Reflect.apply(target, thisArg, args);
71
+ } catch (e) {
72
+ core.captureException(e, {
73
+ mechanism: {
74
+ type: 'cloudflare_durableobject',
75
+ handled: false,
76
+ },
77
+ });
78
+ throw e;
79
+ } finally {
80
+ context?.waitUntil(core.flush(2000));
81
+ }
82
+ });
83
+ });
84
+ },
85
+ });
86
+ }
87
+
88
+ /**
89
+ * Instruments a Durable Object class to capture errors and performance data.
90
+ *
91
+ * Instruments the following methods:
92
+ * - fetch
93
+ * - alarm
94
+ * - webSocketMessage
95
+ * - webSocketClose
96
+ * - webSocketError
97
+ *
98
+ * as well as any other public RPC methods on the Durable Object instance.
99
+ *
100
+ * @param optionsCallback Function that returns the options for the SDK initialization.
101
+ * @param DurableObjectClass The Durable Object class to instrument.
102
+ * @returns The instrumented Durable Object class.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * class MyDurableObjectBase extends DurableObject {
107
+ * constructor(ctx: DurableObjectState, env: Env) {
108
+ * super(ctx, env);
109
+ * }
110
+ * }
111
+ *
112
+ * export const MyDurableObject = instrumentDurableObjectWithSentry(
113
+ * env => ({
114
+ * dsn: env.SENTRY_DSN,
115
+ * tracesSampleRate: 1.0,
116
+ * }),
117
+ * MyDurableObjectBase,
118
+ * );
119
+ * ```
120
+ */
121
+ function instrumentDurableObjectWithSentry(
122
+ optionsCallback,
123
+ DurableObjectClass,
124
+ ) {
125
+ return new Proxy(DurableObjectClass, {
126
+ construct(target, [context, env]) {
127
+ async.setAsyncLocalStorageAsyncContextStrategy();
128
+
129
+ const options$1 = options.getFinalOptions(optionsCallback(env), env);
130
+
131
+ const obj = new target(context, env);
132
+
133
+ // These are the methods that are available on a Durable Object
134
+ // ref: https://developers.cloudflare.com/durable-objects/api/base/
135
+ // obj.alarm
136
+ // obj.fetch
137
+ // obj.webSocketError
138
+ // obj.webSocketClose
139
+ // obj.webSocketMessage
140
+
141
+ // Any other public methods on the Durable Object instance are RPC calls.
142
+
143
+ if (obj.fetch && typeof obj.fetch === 'function' && !instrument.isInstrumented(obj.fetch)) {
144
+ obj.fetch = new Proxy(obj.fetch, {
145
+ apply(target, thisArg, args) {
146
+ return request.wrapRequestHandler({ options: options$1, request: args[0], context }, () =>
147
+ Reflect.apply(target, thisArg, args),
148
+ );
149
+ },
150
+ });
151
+
152
+ instrument.markAsInstrumented(obj.fetch);
153
+ }
154
+
155
+ if (obj.alarm && typeof obj.alarm === 'function') {
156
+ obj.alarm = wrapMethodWithSentry({ options: options$1, context, spanName: 'alarm' }, obj.alarm);
157
+ }
158
+
159
+ if (obj.webSocketMessage && typeof obj.webSocketMessage === 'function') {
160
+ obj.webSocketMessage = wrapMethodWithSentry(
161
+ { options: options$1, context, spanName: 'webSocketMessage' },
162
+ obj.webSocketMessage,
163
+ );
164
+ }
165
+
166
+ if (obj.webSocketClose && typeof obj.webSocketClose === 'function') {
167
+ obj.webSocketClose = wrapMethodWithSentry({ options: options$1, context, spanName: 'webSocketClose' }, obj.webSocketClose);
168
+ }
169
+
170
+ if (obj.webSocketError && typeof obj.webSocketError === 'function') {
171
+ obj.webSocketError = wrapMethodWithSentry(
172
+ { options: options$1, context, spanName: 'webSocketError' },
173
+ obj.webSocketError,
174
+ (_, error) =>
175
+ core.captureException(error, {
176
+ mechanism: {
177
+ type: 'cloudflare_durableobject_websocket',
178
+ handled: false,
179
+ },
180
+ }),
181
+ );
182
+ }
183
+
184
+ for (const method of Object.getOwnPropertyNames(obj)) {
185
+ if (
186
+ method === 'fetch' ||
187
+ method === 'alarm' ||
188
+ method === 'webSocketError' ||
189
+ method === 'webSocketClose' ||
190
+ method === 'webSocketMessage'
191
+ ) {
192
+ continue;
193
+ }
194
+
195
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
196
+ const value = (obj )[method] ;
197
+ if (typeof value === 'function') {
198
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
199
+ (obj )[method] = wrapMethodWithSentry(
200
+ { options: options$1, context, spanName: method, spanOp: 'rpc' },
201
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
202
+ value ,
203
+ );
204
+ }
205
+ }
206
+
207
+ return obj;
208
+ },
209
+ });
210
+ }
211
+
212
+ exports.instrumentDurableObjectWithSentry = instrumentDurableObjectWithSentry;
213
+ //# sourceMappingURL=durableobject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durableobject.js","sources":["../../src/durableobject.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/unbound-method */\nimport {\n captureException,\n flush,\n getClient,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type { DurableObject } from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { isInstrumented, markAsInstrumented } from './instrument';\nimport { getFinalOptions } from './options';\nimport { wrapRequestHandler } from './request';\nimport { init } from './sdk';\n\ntype MethodWrapperOptions = {\n spanName?: string;\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | DurableObjectState;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction wrapMethodWithSentry<T extends (...args: any[]) => any>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n): T {\n if (isInstrumented(handler)) {\n return handler;\n }\n\n markAsInstrumented(handler);\n\n return new Proxy(handler, {\n apply(target, thisArg, args: Parameters<T>) {\n const currentClient = getClient();\n // if a client is already set, use withScope, otherwise use withIsolationScope\n const sentryWithScope = currentClient ? withScope : withIsolationScope;\n return sentryWithScope(async scope => {\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 = wrapperOptions.context as ExecutionContext | undefined;\n\n const currentClient = scope.getClient();\n if (!currentClient) {\n const client = init(wrapperOptions.options);\n scope.setClient(client);\n }\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n return await Reflect.apply(target, thisArg, args);\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'cloudflare_durableobject',\n handled: false,\n },\n });\n throw e;\n } finally {\n context?.waitUntil(flush(2000));\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare_durableobjects',\n }\n : {};\n\n // Only create these spans if they have a parent span.\n return startSpan({ name: wrapperOptions.spanName, attributes, onlyIfParent: true }, async () => {\n try {\n return await Reflect.apply(target, thisArg, args);\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'cloudflare_durableobject',\n handled: false,\n },\n });\n throw e;\n } finally {\n context?.waitUntil(flush(2000));\n }\n });\n });\n },\n });\n}\n\n/**\n * Instruments a Durable Object class to capture errors and performance data.\n *\n * Instruments the following methods:\n * - fetch\n * - alarm\n * - webSocketMessage\n * - webSocketClose\n * - webSocketError\n *\n * as well as any other public RPC methods on the Durable Object instance.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param DurableObjectClass The Durable Object class to instrument.\n * @returns The instrumented Durable Object class.\n *\n * @example\n * ```ts\n * class MyDurableObjectBase extends DurableObject {\n * constructor(ctx: DurableObjectState, env: Env) {\n * super(ctx, env);\n * }\n * }\n *\n * export const MyDurableObject = instrumentDurableObjectWithSentry(\n * env => ({\n * dsn: env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * }),\n * MyDurableObjectBase,\n * );\n * ```\n */\nexport function instrumentDurableObjectWithSentry<E, T extends DurableObject<E>>(\n optionsCallback: (env: E) => CloudflareOptions,\n DurableObjectClass: new (state: DurableObjectState, env: E) => T,\n): new (state: DurableObjectState, env: E) => T {\n return new Proxy(DurableObjectClass, {\n construct(target, [context, env]) {\n setAsyncLocalStorageAsyncContextStrategy();\n\n const options = getFinalOptions(optionsCallback(env), env);\n\n const obj = new target(context, env);\n\n // These are the methods that are available on a Durable Object\n // ref: https://developers.cloudflare.com/durable-objects/api/base/\n // obj.alarm\n // obj.fetch\n // obj.webSocketError\n // obj.webSocketClose\n // obj.webSocketMessage\n\n // Any other public methods on the Durable Object instance are RPC calls.\n\n if (obj.fetch && typeof obj.fetch === 'function' && !isInstrumented(obj.fetch)) {\n obj.fetch = new Proxy(obj.fetch, {\n apply(target, thisArg, args) {\n return wrapRequestHandler({ options, request: args[0], context }, () =>\n Reflect.apply(target, thisArg, args),\n );\n },\n });\n\n markAsInstrumented(obj.fetch);\n }\n\n if (obj.alarm && typeof obj.alarm === 'function') {\n obj.alarm = wrapMethodWithSentry({ options, context, spanName: 'alarm' }, obj.alarm);\n }\n\n if (obj.webSocketMessage && typeof obj.webSocketMessage === 'function') {\n obj.webSocketMessage = wrapMethodWithSentry(\n { options, context, spanName: 'webSocketMessage' },\n obj.webSocketMessage,\n );\n }\n\n if (obj.webSocketClose && typeof obj.webSocketClose === 'function') {\n obj.webSocketClose = wrapMethodWithSentry({ options, context, spanName: 'webSocketClose' }, obj.webSocketClose);\n }\n\n if (obj.webSocketError && typeof obj.webSocketError === 'function') {\n obj.webSocketError = wrapMethodWithSentry(\n { options, context, spanName: 'webSocketError' },\n obj.webSocketError,\n (_, error) =>\n captureException(error, {\n mechanism: {\n type: 'cloudflare_durableobject_websocket',\n handled: false,\n },\n }),\n );\n }\n\n for (const method of Object.getOwnPropertyNames(obj)) {\n if (\n method === 'fetch' ||\n method === 'alarm' ||\n method === 'webSocketError' ||\n method === 'webSocketClose' ||\n method === 'webSocketMessage'\n ) {\n continue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const value = (obj as any)[method] as unknown;\n if (typeof value === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n (obj as any)[method] = wrapMethodWithSentry(\n { options, context, spanName: method, spanOp: 'rpc' },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value as (...args: any[]) => any,\n );\n }\n }\n\n return obj;\n },\n });\n}\n"],"names":["isInstrumented","markAsInstrumented","getClient","withScope","withIsolationScope","init","captureException","flush","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","startSpan","setAsyncLocalStorageAsyncContextStrategy","options","getFinalOptions","wrapRequestHandler"],"mappings":";;;;;;;;;AAAA;;AA0BA;AACA,SAAS,oBAAoB;AAC7B,EAAE,cAAc;AAChB,EAAE,OAAO;AACT,EAAE,QAAQ;AACV,EAAK;AACL,EAAE,IAAIA,yBAAc,CAAC,OAAO,CAAC,EAAE;AAC/B,IAAI,OAAO,OAAO;AAClB;;AAEA,EAAEC,6BAAkB,CAAC,OAAO,CAAC;;AAE7B,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;AAC5B,IAAI,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAiB;AAChD,MAAM,MAAM,aAAA,GAAgBC,cAAS,EAAE;AACvC;AACA,MAAM,MAAM,eAAg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,WAAEA,SAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,kBAAkB;AAC1D,UAAU,GAAG,CAAC,cAAc;AAC5B,UAAU,CAAC,CAAC,EAAE,KAAK;AACnB,YAAYN,qBAAgB,CAAC,KAAK,EAAE;AACpC,cAAc,SAAS,EAAE;AACzB,gBAAgB,IAAI,EAAE,oCAAoC;AAC1D,gBAAgB,OAAO,EAAE,KAAK;AAC9B,eAAe;AACf,aAAa,CAAC;AACd,SAAS;AACT;;AAEA,MAAM,KAAK,MAAM,MAAO,IAAG,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE;AAC5D,QAAQ;AACR,UAAU,MAAA,KAAW,OAAQ;AAC7B,UAAU,MAAA,KAAW,OAAQ;AAC7B,UAAU,MAAA,KAAW,gBAAiB;AACtC,UAAU,MAAA,KAAW,gBAAiB;AACtC,UAAU,WAAW;AACrB,UAAU;AACV,UAAU;AACV;;AAEA;AACA,QAAQ,MAAM,QAAQ,CAAC,MAAY,MAAM,CAAE;AAC3C,QAAQ,IAAI,OAAO,KAAM,KAAI,UAAU,EAAE;AACzC;AACA,UAAU,CAAC,GAAI,GAAQ,MAAM,CAAA,GAAI,oBAAoB;AACrD,YAAY,WAAEM,SAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAA,EAAO;AACjE;AACA,YAAY,KAAM;AAClB,WAAW;AACX;AACA;;AAEA,MAAM,OAAO,GAAG;AAChB,KAAK;AACL,GAAG,CAAC;AACJ;;;;"}
@@ -2,14 +2,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const core = require('@sentry/core');
4
4
  const async = require('./async.js');
5
+ const instrument = require('./instrument.js');
6
+ const options = require('./options.js');
5
7
  const request = require('./request.js');
6
8
  const scopeUtils = require('./scope-utils.js');
7
9
  const sdk = require('./sdk.js');
8
10
 
9
- /**
10
- * Extract environment generic from exported handler.
11
- */
12
-
13
11
  /**
14
12
  * Wrapper for Cloudflare handlers.
15
13
  *
@@ -21,83 +19,75 @@ const sdk = require('./sdk.js');
21
19
  * @param handler {ExportedHandler} The handler to wrap.
22
20
  * @returns The wrapped handler.
23
21
  */
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
22
  function withSentry(
26
23
  optionsCallback,
27
24
  handler,
28
25
  ) {
29
26
  async.setAsyncLocalStorageAsyncContextStrategy();
30
27
 
31
- if ('fetch' in handler && typeof handler.fetch === 'function' && !isInstrumented(handler.fetch)) {
32
- handler.fetch = new Proxy(handler.fetch, {
33
- apply(target, thisArg, args) {
34
- const [request$1, env, context] = args;
35
- const options = optionsCallback(env);
36
- return request.wrapRequestHandler({ options, request: request$1, context }, () => target.apply(thisArg, args));
37
- },
38
- });
28
+ try {
29
+ if ('fetch' in handler && typeof handler.fetch === 'function' && !instrument.isInstrumented(handler.fetch)) {
30
+ handler.fetch = new Proxy(handler.fetch, {
31
+ apply(target, thisArg, args) {
32
+ const [request$1, env, context] = args;
39
33
 
40
- markAsInstrumented(handler.fetch);
41
- }
34
+ const options$1 = options.getFinalOptions(optionsCallback(env), env);
42
35
 
43
- if ('scheduled' in handler && typeof handler.scheduled === 'function' && !isInstrumented(handler.scheduled)) {
44
- handler.scheduled = new Proxy(handler.scheduled, {
45
- apply(target, thisArg, args) {
46
- const [event, env, context] = args;
47
- return core.withIsolationScope(isolationScope => {
48
- const options = optionsCallback(env);
49
- const client = sdk.init(options);
50
- isolationScope.setClient(client);
36
+ return request.wrapRequestHandler({ options: options$1, request: request$1, context }, () => target.apply(thisArg, args));
37
+ },
38
+ });
51
39
 
52
- scopeUtils.addCloudResourceContext(isolationScope);
40
+ instrument.markAsInstrumented(handler.fetch);
41
+ }
53
42
 
54
- return core.startSpan(
55
- {
56
- op: 'faas.cron',
57
- name: `Scheduled Cron ${event.cron}`,
58
- attributes: {
59
- 'faas.cron': event.cron,
60
- 'faas.time': new Date(event.scheduledTime).toISOString(),
61
- 'faas.trigger': 'timer',
62
- [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare',
63
- [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
64
- },
65
- },
66
- async () => {
67
- try {
68
- return await (target.apply(thisArg, args) );
69
- } catch (e) {
70
- core.captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });
71
- throw e;
72
- } finally {
73
- context.waitUntil(core.flush(2000));
74
- }
75
- },
76
- );
77
- });
78
- },
79
- });
43
+ if ('scheduled' in handler && typeof handler.scheduled === 'function' && !instrument.isInstrumented(handler.scheduled)) {
44
+ handler.scheduled = new Proxy(handler.scheduled, {
45
+ apply(target, thisArg, args) {
46
+ const [event, env, context] = args;
47
+ return core.withIsolationScope(isolationScope => {
48
+ const options$1 = options.getFinalOptions(optionsCallback(env), env);
80
49
 
81
- markAsInstrumented(handler.scheduled);
82
- }
50
+ const client = sdk.init(options$1);
51
+ isolationScope.setClient(client);
83
52
 
84
- return handler;
85
- }
53
+ scopeUtils.addCloudResourceContext(isolationScope);
86
54
 
87
- function markAsInstrumented(handler) {
88
- try {
89
- (handler ).__SENTRY_INSTRUMENTED__ = true;
90
- } catch {
91
- // ignore errors here
92
- }
93
- }
55
+ return core.startSpan(
56
+ {
57
+ op: 'faas.cron',
58
+ name: `Scheduled Cron ${event.cron}`,
59
+ attributes: {
60
+ 'faas.cron': event.cron,
61
+ 'faas.time': new Date(event.scheduledTime).toISOString(),
62
+ 'faas.trigger': 'timer',
63
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare',
64
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
65
+ },
66
+ },
67
+ async () => {
68
+ try {
69
+ return await (target.apply(thisArg, args) );
70
+ } catch (e) {
71
+ core.captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });
72
+ throw e;
73
+ } finally {
74
+ context.waitUntil(core.flush(2000));
75
+ }
76
+ },
77
+ );
78
+ });
79
+ },
80
+ });
94
81
 
95
- function isInstrumented(handler) {
96
- try {
97
- return (handler ).__SENTRY_INSTRUMENTED__;
98
- } catch {
99
- return false;
82
+ instrument.markAsInstrumented(handler.scheduled);
83
+ }
84
+ // This is here because Miniflare sometimes cannot get instrumented
85
+ //
86
+ } catch (e) {
87
+ // Do not console anything here, we don't want to spam the console with errors
100
88
  }
89
+
90
+ return handler;
101
91
  }
102
92
 
103
93
  exports.withSentry = withSentry;
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sources":["../../src/handler.ts"],"sourcesContent":["import type {\n ExportedHandler,\n ExportedHandlerFetchHandler,\n ExportedHandlerScheduledHandler,\n} from '@cloudflare/workers-types';\nimport {\n captureException,\n flush,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n} from '@sentry/core';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { wrapRequestHandler } from './request';\nimport { addCloudResourceContext } from './scope-utils';\nimport { init } from './sdk';\n\n/**\n * Extract environment generic from exported handler.\n */\ntype ExtractEnv<P> = P extends ExportedHandler<infer Env> ? Env : never;\n\n/**\n * Wrapper for Cloudflare handlers.\n *\n * Initializes the SDK and wraps the handler with Sentry instrumentation.\n *\n * Automatically instruments the `fetch` method of the handler.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param handler {ExportedHandler} The handler to wrap.\n * @returns The wrapped handler.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentry<E extends ExportedHandler<any>>(\n optionsCallback: (env: ExtractEnv<E>) => CloudflareOptions,\n handler: E,\n): E {\n setAsyncLocalStorageAsyncContextStrategy();\n\n if ('fetch' in handler && typeof handler.fetch === 'function' && !isInstrumented(handler.fetch)) {\n handler.fetch = new Proxy(handler.fetch, {\n apply(target, thisArg, args: Parameters<ExportedHandlerFetchHandler<ExtractEnv<E>>>) {\n const [request, env, context] = args;\n const options = optionsCallback(env);\n return wrapRequestHandler({ options, request, context }, () => target.apply(thisArg, args));\n },\n });\n\n markAsInstrumented(handler.fetch);\n }\n\n if ('scheduled' in handler && typeof handler.scheduled === 'function' && !isInstrumented(handler.scheduled)) {\n handler.scheduled = new Proxy(handler.scheduled, {\n apply(target, thisArg, args: Parameters<ExportedHandlerScheduledHandler<ExtractEnv<E>>>) {\n const [event, env, context] = args;\n return withIsolationScope(isolationScope => {\n const options = optionsCallback(env);\n const client = init(options);\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n return startSpan(\n {\n op: 'faas.cron',\n name: `Scheduled Cron ${event.cron}`,\n attributes: {\n 'faas.cron': event.cron,\n 'faas.time': new Date(event.scheduledTime).toISOString(),\n 'faas.trigger': 'timer',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async () => {\n try {\n return await (target.apply(thisArg, args) as ReturnType<typeof target>);\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });\n throw e;\n } finally {\n context.waitUntil(flush(2000));\n }\n },\n );\n });\n },\n });\n\n markAsInstrumented(handler.scheduled);\n }\n\n return handler;\n}\n\ntype SentryInstrumented<T> = T & {\n __SENTRY_INSTRUMENTED__?: boolean;\n};\n\nfunction markAsInstrumented<T>(handler: T): void {\n try {\n (handler as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__ = true;\n } catch {\n // ignore errors here\n }\n}\n\nfunction isInstrumented<T>(handler: T): boolean | undefined {\n try {\n return (handler as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__;\n } catch {\n return false;\n }\n}\n"],"names":["setAsyncLocalStorageAsyncContextStrategy","request","wrapRequestHandler","withIsolationScope","init","addCloudResourceContext","startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","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,uBAAA,GAAA,IAAA;AACA,GAAA,CAAA,MAAA;AACA;AACA;AACA;;AAEA,SAAA,cAAA,CAAA,OAAA,EAAA;AACA,EAAA,IAAA;AACA,IAAA,OAAA,CAAA,OAAA,GAAA,uBAAA;AACA,GAAA,CAAA,MAAA;AACA,IAAA,OAAA,KAAA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"handler.js","sources":["../../src/handler.ts"],"sourcesContent":["import {\n captureException,\n flush,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n} from '@sentry/core';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { isInstrumented, markAsInstrumented } from './instrument';\nimport { getFinalOptions } from './options';\nimport { wrapRequestHandler } from './request';\nimport { addCloudResourceContext } from './scope-utils';\nimport { init } from './sdk';\n\n/**\n * Wrapper for Cloudflare handlers.\n *\n * Initializes the SDK and wraps the handler with Sentry instrumentation.\n *\n * Automatically instruments the `fetch` method of the handler.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param handler {ExportedHandler} The handler to wrap.\n * @returns The wrapped handler.\n */\nexport function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown>(\n optionsCallback: (env: Env) => CloudflareOptions,\n handler: ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata>,\n): ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata> {\n setAsyncLocalStorageAsyncContextStrategy();\n\n try {\n if ('fetch' in handler && typeof handler.fetch === 'function' && !isInstrumented(handler.fetch)) {\n handler.fetch = new Proxy(handler.fetch, {\n apply(target, thisArg, args: Parameters<ExportedHandlerFetchHandler<Env, CfHostMetadata>>) {\n const [request, env, context] = args;\n\n const options = getFinalOptions(optionsCallback(env), env);\n\n return wrapRequestHandler({ options, request, context }, () => target.apply(thisArg, args));\n },\n });\n\n markAsInstrumented(handler.fetch);\n }\n\n if ('scheduled' in handler && typeof handler.scheduled === 'function' && !isInstrumented(handler.scheduled)) {\n handler.scheduled = new Proxy(handler.scheduled, {\n apply(target, thisArg, args: Parameters<ExportedHandlerScheduledHandler<Env>>) {\n const [event, env, context] = args;\n return withIsolationScope(isolationScope => {\n const options = getFinalOptions(optionsCallback(env), env);\n\n const client = init(options);\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n return startSpan(\n {\n op: 'faas.cron',\n name: `Scheduled Cron ${event.cron}`,\n attributes: {\n 'faas.cron': event.cron,\n 'faas.time': new Date(event.scheduledTime).toISOString(),\n 'faas.trigger': 'timer',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async () => {\n try {\n return await (target.apply(thisArg, args) as ReturnType<typeof target>);\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });\n throw e;\n } finally {\n context.waitUntil(flush(2000));\n }\n },\n );\n });\n },\n });\n\n markAsInstrumented(handler.scheduled);\n }\n // This is here because Miniflare sometimes cannot get instrumented\n //\n } catch (e) {\n // Do not console anything here, we don't want to spam the console with errors\n }\n\n return handler;\n}\n"],"names":["setAsyncLocalStorageAsyncContextStrategy","isInstrumented","request","options","getFinalOptions","wrapRequestHandler","markAsInstrumented","withIsolationScope","init","addCloudResourceContext","startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","captureException","flush"],"mappings":";;;;;;;;;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,UAAU;AAC1B,EAAE,eAAe;AACjB,EAAE,OAAO;AACT,EAA6D;AAC7D,EAAEA,8CAAwC,EAAE;;AAE5C,EAAE,IAAI;AACN,IAAI,IAAI,OAAQ,IAAG,WAAW,OAAO,OAAO,CAAC,KAAA,KAAU,U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nD,YAAY,OAAOC,cAAS;AAC5B,cAAc;AACd,gBAAgB,EAAE,EAAE,WAAW;AAC/B,gBAAgB,IAAI,EAAE,CAAC,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;AACA,gBAAA,UAAA,EAAA;AACA,kBAAA,WAAA,EAAA,KAAA,CAAA,IAAA;AACA,kBAAA,WAAA,EAAA,IAAA,IAAA,CAAA,KAAA,CAAA,aAAA,CAAA,CAAA,WAAA,EAAA;AACA,kBAAA,cAAA,EAAA,OAAA;AACA,kBAAA,CAAAC,qCAAA,GAAA,sBAAA;AACA,kBAAA,CAAAC,qCAAA,GAAA,MAAA;AACA,iBAAA;AACA,eAAA;AACA,cAAA,YAAA;AACA,gBAAA,IAAA;AACA,kBAAA,OAAA,OAAA,MAAA,CAAA,KAAA,CAAA,OAAA,EAAA,IAAA,CAAA,EAAA;AACA,iBAAA,CAAA,OAAA,CAAA,EAAA;AACA,kBAAAC,qBAAA,CAAA,CAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA,IAAA,EAAA,YAAA,EAAA,EAAA,CAAA;AACA,kBAAA,MAAA,CAAA;AACA,iBAAA,SAAA;AACA,kBAAA,OAAA,CAAA,SAAA,CAAAC,UAAA,CAAA,IAAA,CAAA,CAAA;AACA;AACA,eAAA;AACA,aAAA;AACA,WAAA,CAAA;AACA,SAAA;AACA,OAAA,CAAA;;AAEA,MAAAR,6BAAA,CAAA,OAAA,CAAA,SAAA,CAAA;AACA;AACA;AACA;AACA,GAAA,CAAA,OAAA,CAAA,EAAA;AACA;AACA;;AAEA,EAAA,OAAA,OAAA;AACA;;;;"}
@@ -1,7 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const core = require('@sentry/core');
4
+ const exports$1 = require('./logs/exports.js');
4
5
  const handler = require('./handler.js');
6
+ const durableobject = require('./durableobject.js');
5
7
  const pagesPlugin = require('./pages-plugin.js');
6
8
  const request = require('./request.js');
7
9
  const client = require('./client.js');
@@ -29,6 +31,7 @@ exports.captureFeedback = core.captureFeedback;
29
31
  exports.captureMessage = core.captureMessage;
30
32
  exports.close = core.close;
31
33
  exports.consoleIntegration = core.consoleIntegration;
34
+ exports.consoleLoggingIntegration = core.consoleLoggingIntegration;
32
35
  exports.continueTrace = core.continueTrace;
33
36
  exports.createTransport = core.createTransport;
34
37
  exports.dedupeIntegration = core.dedupeIntegration;
@@ -80,7 +83,9 @@ exports.withMonitor = core.withMonitor;
80
83
  exports.withScope = core.withScope;
81
84
  exports.wrapMcpServerWithSentry = core.wrapMcpServerWithSentry;
82
85
  exports.zodErrorsIntegration = core.zodErrorsIntegration;
86
+ exports.logger = exports$1;
83
87
  exports.withSentry = handler.withSentry;
88
+ exports.instrumentDurableObjectWithSentry = durableobject.instrumentDurableObjectWithSentry;
84
89
  exports.sentryPagesPlugin = pagesPlugin.sentryPagesPlugin;
85
90
  exports.wrapRequestHandler = request.wrapRequestHandler;
86
91
  exports.CloudflareClient = client.CloudflareClient;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,27 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ /**
4
+ * Mark an object as instrumented.
5
+ */
6
+ function markAsInstrumented(obj) {
7
+ try {
8
+ (obj ).__SENTRY_INSTRUMENTED__ = true;
9
+ } catch {
10
+ // ignore errors here
11
+ }
12
+ }
13
+
14
+ /**
15
+ * Check if an object is instrumented.
16
+ */
17
+ function isInstrumented(obj) {
18
+ try {
19
+ return (obj ).__SENTRY_INSTRUMENTED__;
20
+ } catch {
21
+ return false;
22
+ }
23
+ }
24
+
25
+ exports.isInstrumented = isInstrumented;
26
+ exports.markAsInstrumented = markAsInstrumented;
27
+ //# sourceMappingURL=instrument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrument.js","sources":["../../src/instrument.ts"],"sourcesContent":["type SentryInstrumented<T> = T & {\n __SENTRY_INSTRUMENTED__?: boolean;\n};\n\n/**\n * Mark an object as instrumented.\n */\nexport function markAsInstrumented<T>(obj: T): void {\n try {\n (obj as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__ = true;\n } catch {\n // ignore errors here\n }\n}\n\n/**\n * Check if an object is instrumented.\n */\nexport function isInstrumented<T>(obj: T): boolean | undefined {\n try {\n return (obj as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__;\n } catch {\n return false;\n }\n}\n"],"names":[],"mappings":";;AAIA;AACA;AACA;AACO,SAAS,kBAAkB,CAAI,GAAG,EAAW;AACpD,EAAE,IAAI;AACN,IAAI,CAAC,GAAI,GAA0B,uBAAA,GAA0B,IAAI;AACjE,IAAI,MAAM;AACV;AACA;AACA;;AAEA;AACA;AACA;AACO,SAAS,cAAc,CAAI,GAAG,EAA0B;AAC/D,EAAE,IAAI;AACN,IAAI,OAAO,CAAC,GAAI,GAA0B,uBAAuB;AACjE,IAAI,MAAM;AACV,IAAI,OAAO,KAAK;AAChB;AACA;;;;;"}