@sentry/cloudflare 9.15.0 → 9.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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
@@ -1,13 +1,11 @@
1
1
  import { withIsolationScope, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, captureException, flush } from '@sentry/core';
2
2
  import { setAsyncLocalStorageAsyncContextStrategy } from './async.js';
3
+ import { isInstrumented, markAsInstrumented } from './instrument.js';
4
+ import { getFinalOptions } from './options.js';
3
5
  import { wrapRequestHandler } from './request.js';
4
6
  import { addCloudResourceContext } from './scope-utils.js';
5
7
  import { init } from './sdk.js';
6
8
 
7
- /**
8
- * Extract environment generic from exported handler.
9
- */
10
-
11
9
  /**
12
10
  * Wrapper for Cloudflare handlers.
13
11
  *
@@ -19,83 +17,75 @@ import { init } from './sdk.js';
19
17
  * @param handler {ExportedHandler} The handler to wrap.
20
18
  * @returns The wrapped handler.
21
19
  */
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
20
  function withSentry(
24
21
  optionsCallback,
25
22
  handler,
26
23
  ) {
27
24
  setAsyncLocalStorageAsyncContextStrategy();
28
25
 
29
- if ('fetch' in handler && typeof handler.fetch === 'function' && !isInstrumented(handler.fetch)) {
30
- handler.fetch = new Proxy(handler.fetch, {
31
- apply(target, thisArg, args) {
32
- const [request, env, context] = args;
33
- const options = optionsCallback(env);
34
- return wrapRequestHandler({ options, request, context }, () => target.apply(thisArg, args));
35
- },
36
- });
26
+ try {
27
+ if ('fetch' in handler && typeof handler.fetch === 'function' && !isInstrumented(handler.fetch)) {
28
+ handler.fetch = new Proxy(handler.fetch, {
29
+ apply(target, thisArg, args) {
30
+ const [request, env, context] = args;
37
31
 
38
- markAsInstrumented(handler.fetch);
39
- }
32
+ const options = getFinalOptions(optionsCallback(env), env);
40
33
 
41
- if ('scheduled' in handler && typeof handler.scheduled === 'function' && !isInstrumented(handler.scheduled)) {
42
- handler.scheduled = new Proxy(handler.scheduled, {
43
- apply(target, thisArg, args) {
44
- const [event, env, context] = args;
45
- return withIsolationScope(isolationScope => {
46
- const options = optionsCallback(env);
47
- const client = init(options);
48
- isolationScope.setClient(client);
34
+ return wrapRequestHandler({ options, request, context }, () => target.apply(thisArg, args));
35
+ },
36
+ });
49
37
 
50
- addCloudResourceContext(isolationScope);
38
+ markAsInstrumented(handler.fetch);
39
+ }
51
40
 
52
- return startSpan(
53
- {
54
- op: 'faas.cron',
55
- name: `Scheduled Cron ${event.cron}`,
56
- attributes: {
57
- 'faas.cron': event.cron,
58
- 'faas.time': new Date(event.scheduledTime).toISOString(),
59
- 'faas.trigger': 'timer',
60
- [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare',
61
- [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
62
- },
63
- },
64
- async () => {
65
- try {
66
- return await (target.apply(thisArg, args) );
67
- } catch (e) {
68
- captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });
69
- throw e;
70
- } finally {
71
- context.waitUntil(flush(2000));
72
- }
73
- },
74
- );
75
- });
76
- },
77
- });
41
+ if ('scheduled' in handler && typeof handler.scheduled === 'function' && !isInstrumented(handler.scheduled)) {
42
+ handler.scheduled = new Proxy(handler.scheduled, {
43
+ apply(target, thisArg, args) {
44
+ const [event, env, context] = args;
45
+ return withIsolationScope(isolationScope => {
46
+ const options = getFinalOptions(optionsCallback(env), env);
78
47
 
79
- markAsInstrumented(handler.scheduled);
80
- }
48
+ const client = init(options);
49
+ isolationScope.setClient(client);
81
50
 
82
- return handler;
83
- }
51
+ addCloudResourceContext(isolationScope);
84
52
 
85
- function markAsInstrumented(handler) {
86
- try {
87
- (handler ).__SENTRY_INSTRUMENTED__ = true;
88
- } catch {
89
- // ignore errors here
90
- }
91
- }
53
+ return startSpan(
54
+ {
55
+ op: 'faas.cron',
56
+ name: `Scheduled Cron ${event.cron}`,
57
+ attributes: {
58
+ 'faas.cron': event.cron,
59
+ 'faas.time': new Date(event.scheduledTime).toISOString(),
60
+ 'faas.trigger': 'timer',
61
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare',
62
+ [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
63
+ },
64
+ },
65
+ async () => {
66
+ try {
67
+ return await (target.apply(thisArg, args) );
68
+ } catch (e) {
69
+ captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });
70
+ throw e;
71
+ } finally {
72
+ context.waitUntil(flush(2000));
73
+ }
74
+ },
75
+ );
76
+ });
77
+ },
78
+ });
92
79
 
93
- function isInstrumented(handler) {
94
- try {
95
- return (handler ).__SENTRY_INSTRUMENTED__;
96
- } catch {
97
- return false;
80
+ markAsInstrumented(handler.scheduled);
81
+ }
82
+ // This is here because Miniflare sometimes cannot get instrumented
83
+ //
84
+ } catch (e) {
85
+ // Do not console anything here, we don't want to spam the console with errors
98
86
  }
87
+
88
+ return handler;
99
89
  }
100
90
 
101
91
  export { 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":[],"mappings":";;;;;;AAmBA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,UAAU;AAC1B,EAAE,eAAe;AACjB,EAAE,OAAO;AACT,EAAK;AACL,EAAE,wCAAwC,EAAE;;AAE5C,EAAE,IAAI,OAAQ,IAAG,WAAW,OAAO,OAAO,CAAC,KAAA,KAAU,UAAW,IAAG,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACnG,IAAI,OAAO,CAAC,KAAA,GAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE;AAC7C,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAA0D;AAC3F,QAAQ,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAE,GAAE,IAAI;AAC5C,QAAQ,MAAM,OAAQ,GAAE,eAAe,CAAC,GAAG,CAAC;AAC5C,QAAQ,OAAO,kBAAkB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAA,EAAS,EAAE,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC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,OAAA,CAAA,EAAA;AACA,gBAAA,gBAAA,CAAA,CAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA,IAAA,EAAA,YAAA,EAAA,EAAA,CAAA;AACA,gBAAA,MAAA,CAAA;AACA,eAAA,SAAA;AACA,gBAAA,OAAA,CAAA,SAAA,CAAA,KAAA,CAAA,IAAA,CAAA,CAAA;AACA;AACA,aAAA;AACA,WAAA;AACA,SAAA,CAAA;AACA,OAAA;AACA,KAAA,CAAA;;AAEA,IAAA,kBAAA,CAAA,OAAA,CAAA,SAAA,CAAA;AACA;;AAEA,EAAA,OAAA,OAAA;AACA;;AAMA,SAAA,kBAAA,CAAA,OAAA,EAAA;AACA,EAAA,IAAA;AACA,IAAA,CAAA,OAAA,GAAA,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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A,OAAA,CAAA,EAAA;AACA;AACA;;AAEA,EAAA,OAAA,OAAA;AACA;;;;"}
@@ -1,5 +1,8 @@
1
- export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, close, consoleIntegration, continueTrace, createTransport, dedupeIntegration, eventFiltersIntegration, extraErrorDataIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, inboundFiltersIntegration, instrumentSupabaseClient, isInitialized, lastEventId, linkedErrorsIntegration, moduleMetadataIntegration, requestDataIntegration, rewriteFramesIntegration, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanToBaggageHeader, spanToJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSpan, startSpanManual, supabaseIntegration, suppressTracing, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/core';
1
+ export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, close, consoleIntegration, consoleLoggingIntegration, continueTrace, createTransport, dedupeIntegration, eventFiltersIntegration, extraErrorDataIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, inboundFiltersIntegration, instrumentSupabaseClient, isInitialized, lastEventId, linkedErrorsIntegration, moduleMetadataIntegration, requestDataIntegration, rewriteFramesIntegration, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanToBaggageHeader, spanToJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSpan, startSpanManual, supabaseIntegration, suppressTracing, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/core';
2
+ import * as exports from './logs/exports.js';
3
+ export { exports as logger };
2
4
  export { withSentry } from './handler.js';
5
+ export { instrumentDurableObjectWithSentry } from './durableobject.js';
3
6
  export { sentryPagesPlugin } from './pages-plugin.js';
4
7
  export { wrapRequestHandler } from './request.js';
5
8
  export { CloudflareClient } from './client.js';
@@ -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,24 @@
1
+ /**
2
+ * Mark an object as instrumented.
3
+ */
4
+ function markAsInstrumented(obj) {
5
+ try {
6
+ (obj ).__SENTRY_INSTRUMENTED__ = true;
7
+ } catch {
8
+ // ignore errors here
9
+ }
10
+ }
11
+
12
+ /**
13
+ * Check if an object is instrumented.
14
+ */
15
+ function isInstrumented(obj) {
16
+ try {
17
+ return (obj ).__SENTRY_INSTRUMENTED__;
18
+ } catch {
19
+ return false;
20
+ }
21
+ }
22
+
23
+ export { isInstrumented, markAsInstrumented };
24
+ //# 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;;;;"}
@@ -0,0 +1,206 @@
1
+ import { _INTERNAL_captureLog } from '@sentry/core';
2
+ export { fmt } from '@sentry/core';
3
+
4
+ /**
5
+ * Capture a log with the given level.
6
+ *
7
+ * @param level - The level of the log.
8
+ * @param message - The message to log.
9
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.
10
+ * @param severityNumber - The severity number of the log.
11
+ */
12
+ function captureLog(
13
+ level,
14
+ message,
15
+ attributes,
16
+ severityNumber,
17
+ ) {
18
+ _INTERNAL_captureLog({ level, message, attributes, severityNumber });
19
+ }
20
+
21
+ /**
22
+ * @summary Capture a log with the `trace` level. Requires `_experiments.enableLogs` to be enabled.
23
+ *
24
+ * @param message - The message to log.
25
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { userId: 100, route: '/dashboard' }.
26
+ *
27
+ * @example
28
+ *
29
+ * ```
30
+ * Sentry.logger.trace('User clicked submit button', {
31
+ * buttonId: 'submit-form',
32
+ * formId: 'user-profile',
33
+ * timestamp: Date.now()
34
+ * });
35
+ * ```
36
+ *
37
+ * @example With template strings
38
+ *
39
+ * ```
40
+ * Sentry.logger.trace(Sentry.logger.fmt`User ${user} navigated to ${page}`, {
41
+ * userId: '123',
42
+ * sessionId: 'abc-xyz'
43
+ * });
44
+ * ```
45
+ */
46
+ function trace(message, attributes) {
47
+ captureLog('trace', message, attributes);
48
+ }
49
+
50
+ /**
51
+ * @summary Capture a log with the `debug` level. Requires `_experiments.enableLogs` to be enabled.
52
+ *
53
+ * @param message - The message to log.
54
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { component: 'Header', state: 'loading' }.
55
+ *
56
+ * @example
57
+ *
58
+ * ```
59
+ * Sentry.logger.debug('Component mounted', {
60
+ * component: 'UserProfile',
61
+ * props: { userId: 123 },
62
+ * renderTime: 150
63
+ * });
64
+ * ```
65
+ *
66
+ * @example With template strings
67
+ *
68
+ * ```
69
+ * Sentry.logger.debug(Sentry.logger.fmt`API request to ${endpoint} failed`, {
70
+ * statusCode: 404,
71
+ * requestId: 'req-123',
72
+ * duration: 250
73
+ * });
74
+ * ```
75
+ */
76
+ function debug(message, attributes) {
77
+ captureLog('debug', message, attributes);
78
+ }
79
+
80
+ /**
81
+ * @summary Capture a log with the `info` level. Requires `_experiments.enableLogs` to be enabled.
82
+ *
83
+ * @param message - The message to log.
84
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { feature: 'checkout', status: 'completed' }.
85
+ *
86
+ * @example
87
+ *
88
+ * ```
89
+ * Sentry.logger.info('User completed checkout', {
90
+ * orderId: 'order-123',
91
+ * amount: 99.99,
92
+ * paymentMethod: 'credit_card'
93
+ * });
94
+ * ```
95
+ *
96
+ * @example With template strings
97
+ *
98
+ * ```
99
+ * Sentry.logger.info(Sentry.logger.fmt`User ${user} updated profile picture`, {
100
+ * userId: 'user-123',
101
+ * imageSize: '2.5MB',
102
+ * timestamp: Date.now()
103
+ * });
104
+ * ```
105
+ */
106
+ function info(message, attributes) {
107
+ captureLog('info', message, attributes);
108
+ }
109
+
110
+ /**
111
+ * @summary Capture a log with the `warn` level. Requires `_experiments.enableLogs` to be enabled.
112
+ *
113
+ * @param message - The message to log.
114
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { browser: 'Chrome', version: '91.0' }.
115
+ *
116
+ * @example
117
+ *
118
+ * ```
119
+ * Sentry.logger.warn('Browser compatibility issue detected', {
120
+ * browser: 'Safari',
121
+ * version: '14.0',
122
+ * feature: 'WebRTC',
123
+ * fallback: 'enabled'
124
+ * });
125
+ * ```
126
+ *
127
+ * @example With template strings
128
+ *
129
+ * ```
130
+ * Sentry.logger.warn(Sentry.logger.fmt`API endpoint ${endpoint} is deprecated`, {
131
+ * recommendedEndpoint: '/api/v2/users',
132
+ * sunsetDate: '2024-12-31',
133
+ * clientVersion: '1.2.3'
134
+ * });
135
+ * ```
136
+ */
137
+ function warn(message, attributes) {
138
+ captureLog('warn', message, attributes);
139
+ }
140
+
141
+ /**
142
+ * @summary Capture a log with the `error` level. Requires `_experiments.enableLogs` to be enabled.
143
+ *
144
+ * @param message - The message to log.
145
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { error: 'NetworkError', url: '/api/data' }.
146
+ *
147
+ * @example
148
+ *
149
+ * ```
150
+ * Sentry.logger.error('Failed to load user data', {
151
+ * error: 'NetworkError',
152
+ * url: '/api/users/123',
153
+ * statusCode: 500,
154
+ * retryCount: 3
155
+ * });
156
+ * ```
157
+ *
158
+ * @example With template strings
159
+ *
160
+ * ```
161
+ * Sentry.logger.error(Sentry.logger.fmt`Payment processing failed for order ${orderId}`, {
162
+ * error: 'InsufficientFunds',
163
+ * amount: 100.00,
164
+ * currency: 'USD',
165
+ * userId: 'user-456'
166
+ * });
167
+ * ```
168
+ */
169
+ function error(message, attributes) {
170
+ captureLog('error', message, attributes);
171
+ }
172
+
173
+ /**
174
+ * @summary Capture a log with the `fatal` level. Requires `_experiments.enableLogs` to be enabled.
175
+ *
176
+ * @param message - The message to log.
177
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { appState: 'corrupted', sessionId: 'abc-123' }.
178
+ *
179
+ * @example
180
+ *
181
+ * ```
182
+ * Sentry.logger.fatal('Application state corrupted', {
183
+ * lastKnownState: 'authenticated',
184
+ * sessionId: 'session-123',
185
+ * timestamp: Date.now(),
186
+ * recoveryAttempted: true
187
+ * });
188
+ * ```
189
+ *
190
+ * @example With template strings
191
+ *
192
+ * ```
193
+ * Sentry.logger.fatal(Sentry.logger.fmt`Critical system failure in ${service}`, {
194
+ * service: 'payment-processor',
195
+ * errorCode: 'CRITICAL_FAILURE',
196
+ * affectedUsers: 150,
197
+ * timestamp: Date.now()
198
+ * });
199
+ * ```
200
+ */
201
+ function fatal(message, attributes) {
202
+ captureLog('fatal', message, attributes);
203
+ }
204
+
205
+ export { debug, error, fatal, info, trace, warn };
206
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.js","sources":["../../../src/logs/exports.ts"],"sourcesContent":["import type { Log, LogSeverityLevel, ParameterizedString } from '@sentry/core';\nimport { _INTERNAL_captureLog } from '@sentry/core';\n\n/**\n * Capture a log with the given level.\n *\n * @param level - The level of the log.\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.\n * @param severityNumber - The severity number of the log.\n */\nfunction captureLog(\n level: LogSeverityLevel,\n message: ParameterizedString,\n attributes?: Log['attributes'],\n severityNumber?: Log['severityNumber'],\n): void {\n _INTERNAL_captureLog({ level, message, attributes, severityNumber });\n}\n\n/**\n * @summary Capture a log with the `trace` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { userId: 100, route: '/dashboard' }.\n *\n * @example\n *\n * ```\n * Sentry.logger.trace('User clicked submit button', {\n * buttonId: 'submit-form',\n * formId: 'user-profile',\n * timestamp: Date.now()\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.trace(Sentry.logger.fmt`User ${user} navigated to ${page}`, {\n * userId: '123',\n * sessionId: 'abc-xyz'\n * });\n * ```\n */\nexport function trace(message: ParameterizedString, attributes?: Log['attributes']): void {\n captureLog('trace', message, attributes);\n}\n\n/**\n * @summary Capture a log with the `debug` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { component: 'Header', state: 'loading' }.\n *\n * @example\n *\n * ```\n * Sentry.logger.debug('Component mounted', {\n * component: 'UserProfile',\n * props: { userId: 123 },\n * renderTime: 150\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.debug(Sentry.logger.fmt`API request to ${endpoint} failed`, {\n * statusCode: 404,\n * requestId: 'req-123',\n * duration: 250\n * });\n * ```\n */\nexport function debug(message: ParameterizedString, attributes?: Log['attributes']): void {\n captureLog('debug', message, attributes);\n}\n\n/**\n * @summary Capture a log with the `info` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { feature: 'checkout', status: 'completed' }.\n *\n * @example\n *\n * ```\n * Sentry.logger.info('User completed checkout', {\n * orderId: 'order-123',\n * amount: 99.99,\n * paymentMethod: 'credit_card'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.info(Sentry.logger.fmt`User ${user} updated profile picture`, {\n * userId: 'user-123',\n * imageSize: '2.5MB',\n * timestamp: Date.now()\n * });\n * ```\n */\nexport function info(message: ParameterizedString, attributes?: Log['attributes']): void {\n captureLog('info', message, attributes);\n}\n\n/**\n * @summary Capture a log with the `warn` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { browser: 'Chrome', version: '91.0' }.\n *\n * @example\n *\n * ```\n * Sentry.logger.warn('Browser compatibility issue detected', {\n * browser: 'Safari',\n * version: '14.0',\n * feature: 'WebRTC',\n * fallback: 'enabled'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.warn(Sentry.logger.fmt`API endpoint ${endpoint} is deprecated`, {\n * recommendedEndpoint: '/api/v2/users',\n * sunsetDate: '2024-12-31',\n * clientVersion: '1.2.3'\n * });\n * ```\n */\nexport function warn(message: ParameterizedString, attributes?: Log['attributes']): void {\n captureLog('warn', message, attributes);\n}\n\n/**\n * @summary Capture a log with the `error` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { error: 'NetworkError', url: '/api/data' }.\n *\n * @example\n *\n * ```\n * Sentry.logger.error('Failed to load user data', {\n * error: 'NetworkError',\n * url: '/api/users/123',\n * statusCode: 500,\n * retryCount: 3\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.error(Sentry.logger.fmt`Payment processing failed for order ${orderId}`, {\n * error: 'InsufficientFunds',\n * amount: 100.00,\n * currency: 'USD',\n * userId: 'user-456'\n * });\n * ```\n */\nexport function error(message: ParameterizedString, attributes?: Log['attributes']): void {\n captureLog('error', message, attributes);\n}\n\n/**\n * @summary Capture a log with the `fatal` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { appState: 'corrupted', sessionId: 'abc-123' }.\n *\n * @example\n *\n * ```\n * Sentry.logger.fatal('Application state corrupted', {\n * lastKnownState: 'authenticated',\n * sessionId: 'session-123',\n * timestamp: Date.now(),\n * recoveryAttempted: true\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.fatal(Sentry.logger.fmt`Critical system failure in ${service}`, {\n * service: 'payment-processor',\n * errorCode: 'CRITICAL_FAILURE',\n * affectedUsers: 150,\n * timestamp: Date.now()\n * });\n * ```\n */\nexport function fatal(message: ParameterizedString, attributes?: Log['attributes']): void {\n captureLog('fatal', message, attributes);\n}\n\nexport { fmt } from '@sentry/core';\n"],"names":[],"mappings":";;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,UAAU;AACnB,EAAE,KAAK;AACP,EAAE,OAAO;AACT,EAAE,UAAU;AACZ,EAAE,cAAc;AAChB,EAAQ;AACR,EAAE,oBAAoB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,cAAe,EAAC,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,OAAO,EAAuB,UAAU,EAA4B;AAC1F,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,OAAO,EAAuB,UAAU,EAA4B;AAC1F,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAuB,UAAU,EAA4B;AACzF,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAuB,UAAU,EAA4B;AACzF,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,OAAO,EAAuB,UAAU,EAA4B;AAC1F,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,OAAO,EAAuB,UAAU,EAA4B;AAC1F,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC;AAC1C;;;;"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Merges the options passed in from the user with the options we read from
3
+ * the Cloudflare `env` environment variable object.
4
+ *
5
+ * @param userOptions - The options passed in from the user.
6
+ * @param env - The environment variables.
7
+ *
8
+ * @returns The final options.
9
+ */
10
+ function getFinalOptions(userOptions, env) {
11
+ if (typeof env !== 'object' || env === null) {
12
+ return userOptions;
13
+ }
14
+
15
+ const release = 'SENTRY_RELEASE' in env && typeof env.SENTRY_RELEASE === 'string' ? env.SENTRY_RELEASE : undefined;
16
+
17
+ return { release, ...userOptions };
18
+ }
19
+
20
+ export { getFinalOptions };
21
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sources":["../../src/options.ts"],"sourcesContent":["import type { CloudflareOptions } from './client';\n\n/**\n * Merges the options passed in from the user with the options we read from\n * the Cloudflare `env` environment variable object.\n *\n * @param userOptions - The options passed in from the user.\n * @param env - The environment variables.\n *\n * @returns The final options.\n */\nexport function getFinalOptions(userOptions: CloudflareOptions, env: unknown): CloudflareOptions {\n if (typeof env !== 'object' || env === null) {\n return userOptions;\n }\n\n const release = 'SENTRY_RELEASE' in env && typeof env.SENTRY_RELEASE === 'string' ? env.SENTRY_RELEASE : undefined;\n\n return { release, ...userOptions };\n}\n"],"names":[],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,WAAW,EAAqB,GAAG,EAA8B;AACjG,EAAE,IAAI,OAAO,GAAI,KAAI,YAAY,GAAA,KAAQ,IAAI,EAAE;AAC/C,IAAI,OAAO,WAAW;AACtB;;AAEA,EAAE,MAAM,OAAQ,GAAE,oBAAoB,GAAA,IAAO,OAAO,GAAG,CAAC,cAAA,KAAmB,QAAS,GAAE,GAAG,CAAC,cAAA,GAAiB,SAAS;;AAEpH,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,aAAa;AACpC;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"9.15.0","sideEffects":false}
1
+ {"type":"module","version":"9.16.0","sideEffects":false}
@@ -1,4 +1,4 @@
1
- import { withIsolationScope, SEMANTIC_ATTRIBUTE_URL_FULL, SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD, stripUrlQueryAndFragment, continueTrace, startSpan, setHttpStatus, captureException, flush, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
1
+ import { withIsolationScope, SEMANTIC_ATTRIBUTE_URL_FULL, SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD, stripUrlQueryAndFragment, captureException, flush, continueTrace, startSpan, setHttpStatus, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
2
2
  import { addCloudResourceContext, addRequest, addCultureContext } from './scope-utils.js';
3
3
  import { init } from './sdk.js';
4
4
 
@@ -54,6 +54,18 @@ function wrapRequestHandler(
54
54
 
55
55
  const routeName = `${request.method} ${pathname ? stripUrlQueryAndFragment(pathname) : '/'}`;
56
56
 
57
+ // Do not capture spans for OPTIONS and HEAD requests
58
+ if (request.method === 'OPTIONS' || request.method === 'HEAD') {
59
+ try {
60
+ return await handler();
61
+ } catch (e) {
62
+ captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });
63
+ throw e;
64
+ } finally {
65
+ context?.waitUntil(flush(2000));
66
+ }
67
+ }
68
+
57
69
  return continueTrace(
58
70
  { sentryTrace: request.headers.get('sentry-trace') || '', baggage: request.headers.get('baggage') },
59
71
  () => {
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sources":["../../src/request.ts"],"sourcesContent":["import type { ExecutionContext, IncomingRequestCfProperties } from '@cloudflare/workers-types';\nimport type { SpanAttributes } from '@sentry/core';\nimport {\n captureException,\n continueTrace,\n flush,\n SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n setHttpStatus,\n startSpan,\n stripUrlQueryAndFragment,\n withIsolationScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport { addCloudResourceContext, addCultureContext, addRequest } from './scope-utils';\nimport { init } from './sdk';\n\ninterface RequestHandlerWrapperOptions {\n options: CloudflareOptions;\n request: Request<unknown, IncomingRequestCfProperties<unknown>>;\n context: ExecutionContext;\n}\n\n/**\n * Wraps a cloudflare request handler in Sentry instrumentation\n */\nexport function wrapRequestHandler(\n wrapperOptions: RequestHandlerWrapperOptions,\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return withIsolationScope(async isolationScope => {\n const { options, request } = wrapperOptions;\n\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 client = init(options);\n isolationScope.setClient(client);\n\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.cloudflare',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server',\n [SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD]: request.method,\n [SEMANTIC_ATTRIBUTE_URL_FULL]: request.url,\n };\n\n const contentLength = request.headers.get('content-length');\n if (contentLength) {\n attributes['http.request.body.size'] = parseInt(contentLength, 10);\n }\n\n let pathname = '';\n try {\n const url = new URL(request.url);\n pathname = url.pathname;\n attributes['server.address'] = url.hostname;\n attributes['url.scheme'] = url.protocol.replace(':', '');\n } catch {\n // skip\n }\n\n addCloudResourceContext(isolationScope);\n if (request) {\n addRequest(isolationScope, request);\n if (request.cf) {\n addCultureContext(isolationScope, request.cf);\n attributes['network.protocol.name'] = request.cf.httpProtocol;\n }\n }\n\n const routeName = `${request.method} ${pathname ? stripUrlQueryAndFragment(pathname) : '/'}`;\n\n return continueTrace(\n { sentryTrace: request.headers.get('sentry-trace') || '', baggage: request.headers.get('baggage') },\n () => {\n // Note: This span will not have a duration unless I/O happens in the handler. This is\n // because of how the cloudflare workers runtime works.\n // See: https://developers.cloudflare.com/workers/runtime-apis/performance/\n return startSpan(\n {\n name: routeName,\n attributes,\n },\n async span => {\n try {\n const res = await handler();\n setHttpStatus(span, res.status);\n return res;\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"],"names":[],"mappings":";;;;AA0BA;AACA;AACA;AACO,SAAS,kBAAkB;AAClC,EAAE,cAAc;AAChB,EAAE,OAAO;AACT,EAAqB;AACrB,EAAE,OAAO,kBAAkB,CAAC,MAAM,kBAAkB;AACpD,IAAI,MAAM,EAAE,OAAO,EAAE,OAAQ,EAAA,GAAI,cAAc;;AAE/C;AACA;AACA;AACA,IAAI,MAAM,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AAO,CAAC,EAAE,CAAC,YAAY;AACrE;AACA;;AAEA,IAAI,MAAM,SAAA,GAAY,CAAC,EAAA,OAAA,CAAA,MAAA,CAAA,CAAA,EAAA,QAAA,GAAA,wBAAA,CAAA,QAAA,CAAA,GAAA,GAAA,CAAA,CAAA;;AAEA,IAAA,OAAA,aAAA;AACA,MAAA,EAAA,WAAA,EAAA,OAAA,CAAA,OAAA,CAAA,GAAA,CAAA,cAAA,CAAA,IAAA,EAAA,EAAA,OAAA,EAAA,OAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA,CAAA,EAAA;AACA,MAAA,MAAA;AACA;AACA;AACA;AACA,QAAA,OAAA,SAAA;AACA,UAAA;AACA,YAAA,IAAA,EAAA,SAAA;AACA,YAAA,UAAA;AACA,WAAA;AACA,UAAA,MAAA,IAAA,IAAA;AACA,YAAA,IAAA;AACA,cAAA,MAAA,GAAA,GAAA,MAAA,OAAA,EAAA;AACA,cAAA,aAAA,CAAA,IAAA,EAAA,GAAA,CAAA,MAAA,CAAA;AACA,cAAA,OAAA,GAAA;AACA,aAAA,CAAA,OAAA,CAAA,EAAA;AACA,cAAA,gBAAA,CAAA,CAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA,IAAA,EAAA,YAAA,EAAA,EAAA,CAAA;AACA,cAAA,MAAA,CAAA;AACA,aAAA,SAAA;AACA,cAAA,OAAA,EAAA,SAAA,CAAA,KAAA,CAAA,IAAA,CAAA,CAAA;AACA;AACA,WAAA;AACA,SAAA;AACA,OAAA;AACA,KAAA;AACA,GAAA,CAAA;AACA;;;;"}
1
+ {"version":3,"file":"request.js","sources":["../../src/request.ts"],"sourcesContent":["import type { ExecutionContext, IncomingRequestCfProperties } from '@cloudflare/workers-types';\nimport type { SpanAttributes } from '@sentry/core';\nimport {\n captureException,\n continueTrace,\n flush,\n SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n setHttpStatus,\n startSpan,\n stripUrlQueryAndFragment,\n withIsolationScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport { addCloudResourceContext, addCultureContext, addRequest } from './scope-utils';\nimport { init } from './sdk';\n\ninterface RequestHandlerWrapperOptions {\n options: CloudflareOptions;\n request: Request<unknown, IncomingRequestCfProperties<unknown>>;\n context: ExecutionContext;\n}\n\n/**\n * Wraps a cloudflare request handler in Sentry instrumentation\n */\nexport function wrapRequestHandler(\n wrapperOptions: RequestHandlerWrapperOptions,\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return withIsolationScope(async isolationScope => {\n const { options, request } = wrapperOptions;\n\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 client = init(options);\n isolationScope.setClient(client);\n\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.cloudflare',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server',\n [SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD]: request.method,\n [SEMANTIC_ATTRIBUTE_URL_FULL]: request.url,\n };\n\n const contentLength = request.headers.get('content-length');\n if (contentLength) {\n attributes['http.request.body.size'] = parseInt(contentLength, 10);\n }\n\n let pathname = '';\n try {\n const url = new URL(request.url);\n pathname = url.pathname;\n attributes['server.address'] = url.hostname;\n attributes['url.scheme'] = url.protocol.replace(':', '');\n } catch {\n // skip\n }\n\n addCloudResourceContext(isolationScope);\n if (request) {\n addRequest(isolationScope, request);\n if (request.cf) {\n addCultureContext(isolationScope, request.cf);\n attributes['network.protocol.name'] = request.cf.httpProtocol;\n }\n }\n\n const routeName = `${request.method} ${pathname ? stripUrlQueryAndFragment(pathname) : '/'}`;\n\n // Do not capture spans for OPTIONS and HEAD requests\n if (request.method === 'OPTIONS' || request.method === 'HEAD') {\n try {\n return await handler();\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 return continueTrace(\n { sentryTrace: request.headers.get('sentry-trace') || '', baggage: request.headers.get('baggage') },\n () => {\n // Note: This span will not have a duration unless I/O happens in the handler. This is\n // because of how the cloudflare workers runtime works.\n // See: https://developers.cloudflare.com/workers/runtime-apis/performance/\n return startSpan(\n {\n name: routeName,\n attributes,\n },\n async span => {\n try {\n const res = await handler();\n setHttpStatus(span, res.status);\n return res;\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"],"names":[],"mappings":";;;;AA0BA;AACA;AACA;AACO,SAAS,kBAAkB;AAClC,EAAE,cAAc;AAChB,EAAE,OAAO;AACT,EAAqB;AACrB,EAAE,OAAO,kBAAkB,CAAC,MAAM,kBAAkB;AACpD,IAAI,MAAM,EAAE,OAAO,EAAE,OAAQ,EAAA,GAAI,cAAc;;AAE/C;AACA;AACA;AACA,IAAI,MAAM,OAAA,GAAU,cAAc,CAAC,OAAQ;;AAE3C,IAAI,MAAM,MAAO,GAAE,IAAI,CAAC,OAAO,CAAC;AAChC,IAAI,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC;;AAEpC,IAAI,MAAM,UAAU,GAAmB;AACvC,MAAM,CAAC,gCAAgC,GAAG,sBAAsB;AAChE,MAAM,CAAC,gCAAgC,GAAG,KAAK;AAC/C,MAAM,CAAC,4BAA4B,GAAG,aAAa;AACnD,MAAM,CAAC,sCAAsC,GAAG,OAAO,CAAC,MAAM;AAC9D,MAAM,CAAC,2BAA2B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A,QAAA,gBAAA,CAAA,CAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA,IAAA,EAAA,YAAA,EAAA,EAAA,CAAA;AACA,QAAA,MAAA,CAAA;AACA,OAAA,SAAA;AACA,QAAA,OAAA,EAAA,SAAA,CAAA,KAAA,CAAA,IAAA,CAAA,CAAA;AACA;AACA;;AAEA,IAAA,OAAA,aAAA;AACA,MAAA,EAAA,WAAA,EAAA,OAAA,CAAA,OAAA,CAAA,GAAA,CAAA,cAAA,CAAA,IAAA,EAAA,EAAA,OAAA,EAAA,OAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA,CAAA,EAAA;AACA,MAAA,MAAA;AACA;AACA;AACA;AACA,QAAA,OAAA,SAAA;AACA,UAAA;AACA,YAAA,IAAA,EAAA,SAAA;AACA,YAAA,UAAA;AACA,WAAA;AACA,UAAA,MAAA,IAAA,IAAA;AACA,YAAA,IAAA;AACA,cAAA,MAAA,GAAA,GAAA,MAAA,OAAA,EAAA;AACA,cAAA,aAAA,CAAA,IAAA,EAAA,GAAA,CAAA,MAAA,CAAA;AACA,cAAA,OAAA,GAAA;AACA,aAAA,CAAA,OAAA,CAAA,EAAA;AACA,cAAA,gBAAA,CAAA,CAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA,IAAA,EAAA,YAAA,EAAA,EAAA,CAAA;AACA,cAAA,MAAA,CAAA;AACA,aAAA,SAAA;AACA,cAAA,OAAA,EAAA,SAAA,CAAA,KAAA,CAAA,IAAA,CAAA,CAAA;AACA;AACA,WAAA;AACA,SAAA;AACA,OAAA;AACA,KAAA;AACA,GAAA,CAAA;AACA;;;;"}
package/build/esm/sdk.js CHANGED
@@ -15,6 +15,7 @@ function getDefaultIntegrations(options) {
15
15
  functionToStringIntegration(),
16
16
  linkedErrorsIntegration(),
17
17
  fetchIntegration(),
18
+ // TODO(v10): the `include` object should be defined directly in the integration based on `sendDefaultPii`
18
19
  requestDataIntegration(sendDefaultPii ? undefined : { include: { cookies: false } }),
19
20
  consoleIntegration(),
20
21
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {\n consoleIntegration,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\nimport { fetchIntegration } from './integrations/fetch';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/** Get the default integrations for the Cloudflare SDK. */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n const sendDefaultPii = options.sendDefaultPii ?? false;\n return [\n dedupeIntegration(),\n // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n requestDataIntegration(sendDefaultPii ? undefined : { include: { cookies: false } }),\n consoleIntegration(),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeCloudflareTransport,\n };\n\n return initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n}\n"],"names":[],"mappings":";;;;;;AAkBA;AACO,SAAS,sBAAsB,CAAC,OAAO,EAAoC;AAClF,EAAE,MAAM,cAAe,GAAE,OAAO,CAAC,cAAA,IAAkB,KAAK;AACxD,EAAE,OAAO;AACT,IAAI,iBAAiB,EAAE;AACvB;AACA;AACA,IAAI,yBAAyB,EAAE;AAC/B,IAAI,2BAA2B,EAAE;AACjC,IAAI,uBAAuB,EAAE;AAC7B,IAAI,gBAAgB,EAAE;AACtB,IAAI,sBAAsB,CAAC,cAAe,GAAE,YAAY,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,KAAM,EAAA,EAAG,CAAC;AACxF,IAAI,kBAAkB,EAAE;AACxB,GAAG;AACH;;AAEA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAmD;AAC/E,EAAE,IAAI,OAAO,CAAC,mBAAoB,KAAI,SAAS,EAAE;AACjD,IAAI,OAAO,CAAC,mBAAA,GAAsB,sBAAsB,CAAC,OAAO,CAAC;AACjE;;AAEA,EAAE,MAAM,aAAa,GAA4B;AACjD,IAAI,GAAG,OAAO;AACd,IAAI,WAAW,EAAE,iCAAiC,CAAC,OAAO,CAAC,WAAA,IAAe,kBAAkB,CAAC;AAC7F,IAAI,YAAY,EAAE,sBAAsB,CAAC,OAAO,CAAC;AACjD,IAAI,SAAS,EAAE,OAAO,CAAC,SAAA,IAAa,uBAAuB;AAC3D,GAAG;;AAEH,EAAE,OAAO,WAAW,CAAC,gBAAgB,EAAE,aAAa,CAAE;AACtD;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {\n consoleIntegration,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\nimport { fetchIntegration } from './integrations/fetch';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/** Get the default integrations for the Cloudflare SDK. */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n const sendDefaultPii = options.sendDefaultPii ?? false;\n return [\n dedupeIntegration(),\n // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n // TODO(v10): the `include` object should be defined directly in the integration based on `sendDefaultPii`\n requestDataIntegration(sendDefaultPii ? undefined : { include: { cookies: false } }),\n consoleIntegration(),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeCloudflareTransport,\n };\n\n return initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n}\n"],"names":[],"mappings":";;;;;;AAkBA;AACO,SAAS,sBAAsB,CAAC,OAAO,EAAoC;AAClF,EAAE,MAAM,cAAe,GAAE,OAAO,CAAC,cAAA,IAAkB,KAAK;AACxD,EAAE,OAAO;AACT,IAAI,iBAAiB,EAAE;AACvB;AACA;AACA,IAAI,yBAAyB,EAAE;AAC/B,IAAI,2BAA2B,EAAE;AACjC,IAAI,uBAAuB,EAAE;AAC7B,IAAI,gBAAgB,EAAE;AACtB;AACA,IAAI,sBAAsB,CAAC,cAAe,GAAE,YAAY,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,KAAM,EAAA,EAAG,CAAC;AACxF,IAAI,kBAAkB,EAAE;AACxB,GAAG;AACH;;AAEA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAmD;AAC/E,EAAE,IAAI,OAAO,CAAC,mBAAoB,KAAI,SAAS,EAAE;AACjD,IAAI,OAAO,CAAC,mBAAA,GAAsB,sBAAsB,CAAC,OAAO,CAAC;AACjE;;AAEA,EAAE,MAAM,aAAa,GAA4B;AACjD,IAAI,GAAG,OAAO;AACd,IAAI,WAAW,EAAE,iCAAiC,CAAC,OAAO,CAAC,WAAA,IAAe,kBAAkB,CAAC;AAC7F,IAAI,YAAY,EAAE,sBAAsB,CAAC,OAAO,CAAC;AACjD,IAAI,SAAS,EAAE,OAAO,CAAC,SAAA,IAAa,uBAAuB;AAC3D,GAAG;;AAEH,EAAE,OAAO,WAAW,CAAC,gBAAgB,EAAE,aAAa,CAAE;AACtD;;;;"}
@@ -0,0 +1,38 @@
1
+ /// <reference types="@cloudflare/workers-types" />
2
+ import type { DurableObject } from 'cloudflare:workers';
3
+ import type { CloudflareOptions } from './client';
4
+ /**
5
+ * Instruments a Durable Object class to capture errors and performance data.
6
+ *
7
+ * Instruments the following methods:
8
+ * - fetch
9
+ * - alarm
10
+ * - webSocketMessage
11
+ * - webSocketClose
12
+ * - webSocketError
13
+ *
14
+ * as well as any other public RPC methods on the Durable Object instance.
15
+ *
16
+ * @param optionsCallback Function that returns the options for the SDK initialization.
17
+ * @param DurableObjectClass The Durable Object class to instrument.
18
+ * @returns The instrumented Durable Object class.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * class MyDurableObjectBase extends DurableObject {
23
+ * constructor(ctx: DurableObjectState, env: Env) {
24
+ * super(ctx, env);
25
+ * }
26
+ * }
27
+ *
28
+ * export const MyDurableObject = instrumentDurableObjectWithSentry(
29
+ * env => ({
30
+ * dsn: env.SENTRY_DSN,
31
+ * tracesSampleRate: 1.0,
32
+ * }),
33
+ * MyDurableObjectBase,
34
+ * );
35
+ * ```
36
+ */
37
+ export declare function instrumentDurableObjectWithSentry<E, T extends DurableObject<E>>(optionsCallback: (env: E) => CloudflareOptions, DurableObjectClass: new (state: DurableObjectState, env: E) => T): new (state: DurableObjectState, env: E) => T;
38
+ //# sourceMappingURL=durableobject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durableobject.d.ts","sourceRoot":"","sources":["../../src/durableobject.ts"],"names":[],"mappings":";AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAyFlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,iCAAiC,CAAC,CAAC,EAAE,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,EAC7E,eAAe,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,iBAAiB,EAC9C,kBAAkB,EAAE,KAAK,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GAC/D,KAAK,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAsF9C"}