@sentry/cloudflare 10.67.0 → 10.68.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 (78) hide show
  1. package/build/cjs/defineCloudflareOptions.js +11 -0
  2. package/build/cjs/defineCloudflareOptions.js.map +1 -0
  3. package/build/cjs/index.js +3 -0
  4. package/build/cjs/index.js.map +1 -1
  5. package/build/cjs/integrations/tracing/vercelai.js.map +1 -1
  6. package/build/cjs/nodejs_compat/index.js +5 -2
  7. package/build/cjs/nodejs_compat/index.js.map +1 -1
  8. package/build/cjs/nodejs_compat/integrations/tracing/vercelai.js.map +1 -1
  9. package/build/cjs/sdk.js +12 -1
  10. package/build/cjs/sdk.js.map +1 -1
  11. package/build/cjs/vite/autoInstrument.js +81 -0
  12. package/build/cjs/vite/autoInstrument.js.map +1 -0
  13. package/build/cjs/vite/index.js +14 -0
  14. package/build/cjs/vite/index.js.map +1 -0
  15. package/build/cjs/vite/instrumentFile.js +31 -0
  16. package/build/cjs/vite/instrumentFile.js.map +1 -0
  17. package/build/cjs/vite/transform.js +144 -0
  18. package/build/cjs/vite/transform.js.map +1 -0
  19. package/build/cjs/vite/workerEntrypoint.js +66 -0
  20. package/build/cjs/vite/workerEntrypoint.js.map +1 -0
  21. package/build/cjs/vite/wranglerConfig.js +54 -0
  22. package/build/cjs/vite/wranglerConfig.js.map +1 -0
  23. package/build/esm/defineCloudflareOptions.js +9 -0
  24. package/build/esm/defineCloudflareOptions.js.map +1 -0
  25. package/build/esm/index.js +2 -1
  26. package/build/esm/index.js.map +1 -1
  27. package/build/esm/integrations/tracing/vercelai.js.map +1 -1
  28. package/build/esm/nodejs_compat/index.js +3 -2
  29. package/build/esm/nodejs_compat/index.js.map +1 -1
  30. package/build/esm/nodejs_compat/integrations/tracing/vercelai.js.map +1 -1
  31. package/build/esm/package.json +1 -1
  32. package/build/esm/sdk.js +13 -2
  33. package/build/esm/sdk.js.map +1 -1
  34. package/build/esm/vite/autoInstrument.js +79 -0
  35. package/build/esm/vite/autoInstrument.js.map +1 -0
  36. package/build/esm/vite/index.js +12 -0
  37. package/build/esm/vite/index.js.map +1 -0
  38. package/build/esm/vite/instrumentFile.js +27 -0
  39. package/build/esm/vite/instrumentFile.js.map +1 -0
  40. package/build/esm/vite/transform.js +142 -0
  41. package/build/esm/vite/transform.js.map +1 -0
  42. package/build/esm/vite/workerEntrypoint.js +64 -0
  43. package/build/esm/vite/workerEntrypoint.js.map +1 -0
  44. package/build/esm/vite/wranglerConfig.js +52 -0
  45. package/build/esm/vite/wranglerConfig.js.map +1 -0
  46. package/build/types/defineCloudflareOptions.d.ts +38 -0
  47. package/build/types/defineCloudflareOptions.d.ts.map +1 -0
  48. package/build/types/index.d.ts +2 -1
  49. package/build/types/index.d.ts.map +1 -1
  50. package/build/types/integrations/tracing/vercelai.d.ts.map +1 -1
  51. package/build/types/nodejs_compat/index.d.ts +1 -1
  52. package/build/types/nodejs_compat/index.d.ts.map +1 -1
  53. package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts +1 -8
  54. package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts.map +1 -1
  55. package/build/types/sdk.d.ts.map +1 -1
  56. package/build/types/vite/autoInstrument.d.ts +21 -0
  57. package/build/types/vite/autoInstrument.d.ts.map +1 -0
  58. package/build/types/vite/index.d.ts +88 -0
  59. package/build/types/vite/index.d.ts.map +1 -0
  60. package/build/types/vite/instrumentFile.d.ts +22 -0
  61. package/build/types/vite/instrumentFile.d.ts.map +1 -0
  62. package/build/types/vite/transform.d.ts +60 -0
  63. package/build/types/vite/transform.d.ts.map +1 -0
  64. package/build/types/vite/workerEntrypoint.d.ts +12 -0
  65. package/build/types/vite/workerEntrypoint.d.ts.map +1 -0
  66. package/build/types/vite/wranglerConfig.d.ts +43 -0
  67. package/build/types/vite/wranglerConfig.d.ts.map +1 -0
  68. package/build/types-ts3.8/defineCloudflareOptions.d.ts +38 -0
  69. package/build/types-ts3.8/index.d.ts +2 -1
  70. package/build/types-ts3.8/nodejs_compat/index.d.ts +1 -1
  71. package/build/types-ts3.8/nodejs_compat/integrations/tracing/vercelai.d.ts +7 -14
  72. package/build/types-ts3.8/vite/autoInstrument.d.ts +21 -0
  73. package/build/types-ts3.8/vite/index.d.ts +88 -0
  74. package/build/types-ts3.8/vite/instrumentFile.d.ts +22 -0
  75. package/build/types-ts3.8/vite/transform.d.ts +60 -0
  76. package/build/types-ts3.8/vite/workerEntrypoint.d.ts +12 -0
  77. package/build/types-ts3.8/vite/wranglerConfig.d.ts +43 -0
  78. package/package.json +19 -5
@@ -1,16 +1,10 @@
1
- /**
2
- * This is a copy of the Vercel AI integration from the Cloudflare SDK (src/integrations/tracing/vercelai.ts).
3
- *
4
- * The only difference is that it includes tracing channel support
5
- * because the default Vercel AI integration needs `nodejs_als`, while this one uses `nodejs_compat`.
6
- */
7
- interface VercelAiOptions {
8
- /**
9
- * Enable or disable truncation of recorded input messages.
10
- * Defaults to `true`.
11
- */
12
- enableTruncation?: boolean;
13
- }
1
+ /*
2
+ * This is a copy of the Vercel AI integration from the Cloudflare SDK (src/integrations/tracing/vercelai.ts).
3
+ *
4
+ * The only difference is that it includes tracing channel support
5
+ * because the default Vercel AI integration needs `nodejs_als`, while this one uses `nodejs_compat`.
6
+ */
7
+ import { VercelAiOptions } from '@sentry/server-utils';
14
8
  /**
15
9
  * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
16
10
  * This integration is not enabled by default, you need to manually add it.
@@ -40,5 +34,4 @@ interface VercelAiOptions {
40
34
  export declare const vercelAIIntegration: (options?: VercelAiOptions | undefined) => import("@sentry/core").Integration & {
41
35
  name: string;
42
36
  };
43
- export {};
44
37
  //# sourceMappingURL=vercelai.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { ProgramBody } from './transform';
2
+ export declare function sentryCloudflareAutoInstrumentPlugin(): {
3
+ name: string;
4
+ configResolved(config: {
5
+ root: string;
6
+ logger?: {
7
+ warn(msg: string): void;
8
+ };
9
+ }): void;
10
+ transform(this: {
11
+ parse(code: string): ProgramBody;
12
+ warn?(msg: string): void;
13
+ environment?: {
14
+ name?: string;
15
+ };
16
+ }, code: string, id: string): {
17
+ code: string;
18
+ map: unknown;
19
+ } | undefined;
20
+ };
21
+ //# sourceMappingURL=autoInstrument.d.ts.map
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Options for {@link sentryCloudflareVitePlugin}.
3
+ */
4
+ export interface SentryCloudflareVitePluginOptions {
5
+ /**
6
+ * Experimental options that may change or be removed without notice.
7
+ */
8
+ _experimental?: {
9
+ /**
10
+ * Enables build-time automatic instrumentation of supported dependencies
11
+ * (e.g. database clients like `mysql`) so the Sentry Cloudflare SDK can
12
+ * trace them without monkey-patching, which wouldn't work in workerd anyway.
13
+ *
14
+ * When enabled, the plugin injects `diagnostics_channel.tracingChannel`
15
+ * calls into the bundled packages and, next to each, a snippet that
16
+ * registers the matching Sentry channel-subscriber factory on the global
17
+ * marker, which the SDK picks up in `Sentry.withSentry()`. Both `vite build`
18
+ * and `vite dev` are instrumented.
19
+ *
20
+ * @default false
21
+ * @experimental May change or be removed in any release.
22
+ */
23
+ useDiagnosticsChannelInjection?: boolean;
24
+ /**
25
+ * Automatically wraps your Worker at build time so you don't have to edit
26
+ * your entry: the plugin reads your wrangler config, wraps the default
27
+ * export with `Sentry.withSentry()` (sourcing options from a co-located
28
+ * `instrument.*` file, falling back to env), and wraps any configured
29
+ * Durable Object class with `instrumentDurableObjectWithSentry`. Both
30
+ * `vite build` and `vite dev` are instrumented.
31
+ *
32
+ * @default false
33
+ * @experimental May change or be removed in any release.
34
+ */
35
+ autoInstrumentation?: boolean;
36
+ };
37
+ }
38
+ /**
39
+ * Sentry Vite plugin for Cloudflare Workers.
40
+ *
41
+ * Add this plugin to your Vite configuration to enable additional Sentry
42
+ * instrumentation for Cloudflare Workers built with Vite. Configure the Sentry
43
+ * SDK in your Worker as usual with `Sentry.withSentry()`.
44
+ *
45
+ * Currently, the only functionality is the experimental
46
+ * `_experimental.useDiagnosticsChannelInjection` option, which traces supported
47
+ * dependencies (such as database clients) without changing your application
48
+ * code. Without it, the plugin is a no-op.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * // vite.config.ts
53
+ * import { cloudflare } from '@cloudflare/vite-plugin';
54
+ * import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
55
+ * import { defineConfig } from 'vite';
56
+ *
57
+ * export default defineConfig({
58
+ * plugins: [
59
+ * cloudflare(),
60
+ * sentryCloudflareVitePlugin({
61
+ * _experimental: {
62
+ * useDiagnosticsChannelInjection: true,
63
+ * },
64
+ * }),
65
+ * ],
66
+ * });
67
+ * ```
68
+ */
69
+ export declare function sentryCloudflareVitePlugin(options?: SentryCloudflareVitePluginOptions): ({
70
+ name: string;
71
+ configResolved(config: {
72
+ root: string;
73
+ logger?: {
74
+ warn(msg: string): void;
75
+ };
76
+ }): void;
77
+ transform(this: {
78
+ parse(code: string): import("./transform").ProgramBody;
79
+ warn?(msg: string): void;
80
+ environment?: {
81
+ name?: string;
82
+ };
83
+ }, code: string, id: string): {
84
+ code: string;
85
+ map: unknown;
86
+ } | undefined;
87
+ } | import("vite").Plugin<any>)[];
88
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,22 @@
1
+ export declare const ENV_FALLBACK_OPTIONS_FN = "() => undefined";
2
+ /**
3
+ * Locate the conventional `instrument.server.*` module sitting next to the
4
+ * worker entry file. Returns its absolute path, or `undefined` when absent.
5
+ */
6
+ export declare function resolveInstrumentFile(entryFilePath: string): string | undefined;
7
+ /**
8
+ * Build the `optionsFn` reference and `import` statement for the instrument
9
+ * module whose **default export** is the options callback
10
+ * `(env) => CloudflareOptions`.
11
+ *
12
+ * The import is emitted relative to `entryFilePath` because it is injected into
13
+ * the entry file's source. The file extension is kept: extensionless specifiers
14
+ * only resolve for extensions in Vite's default `resolve.extensions` (which
15
+ * excludes `.cjs`), and keeping it makes our probe order authoritative when
16
+ * several `instrument.server.*` files coexist.
17
+ */
18
+ export declare function buildOptionsImport(entryFilePath: string, instrumentFilePath: string): {
19
+ optionsFn: string;
20
+ importStmt: string;
21
+ };
22
+ //# sourceMappingURL=instrumentFile.d.ts.map
@@ -0,0 +1,60 @@
1
+ import MagicString from 'magic-string';
2
+ export interface BaseNode {
3
+ type: string;
4
+ start: number;
5
+ end: number;
6
+ }
7
+ export interface ProgramBody {
8
+ body: BaseNode[];
9
+ }
10
+ /**
11
+ * The kind of Sentry wrapper to apply to an exported class.
12
+ *
13
+ * `durableObject` and `workflow` are keyed by name from the wrangler config
14
+ * (`durable_objects.bindings`, `workflows`), since those class names are
15
+ * authoritative there. `workerEntrypoint` is different: a worker's own
16
+ * entrypoints aren't enumerated in its config, so they're detected structurally
17
+ * (a class extending `WorkerEntrypoint` from `cloudflare:workers`), with the
18
+ * config providing only a fallback for self-bound entrypoints whose base class
19
+ * lives in another module.
20
+ */
21
+ export type ClassWrapperKind = 'durableObject' | 'workflow' | 'workerEntrypoint';
22
+ export interface TransformContext {
23
+ /**
24
+ * Exported class name → the kind of Sentry wrapper to apply. Populated from
25
+ * the wrangler config, so the transform can wrap by name without resolving
26
+ * each class's base type.
27
+ */
28
+ classWrappers: Map<string, ClassWrapperKind>;
29
+ optionsFn: string;
30
+ /** Import statement prepended when `optionsFn` references a separate module. */
31
+ optionsImport?: string;
32
+ }
33
+ export interface TransformResult {
34
+ code: string;
35
+ map: ReturnType<MagicString['generateMap']>;
36
+ /**
37
+ * The configured class names that were actually wrapped. Lets the plugin warn
38
+ * about configured classes it could not find, instead of silently leaving
39
+ * them uninstrumented.
40
+ */
41
+ wrappedClasses: Set<string>;
42
+ }
43
+ /**
44
+ * Rewrite the worker entry source to wrap its default export with `withSentry`
45
+ * and any configured class export with its matching Sentry wrapper (see
46
+ * {@link TransformContext.classWrappers}, e.g. Durable Object classes with
47
+ * `instrumentDurableObjectWithSentry`).
48
+ *
49
+ * Handles both `export class MyDO {}` and the specifier form
50
+ * (`class MyDO {}` … `export { MyDO }` / `export { Foo as MyDO }`).
51
+ * Re-exports from other modules (`export { MyDO } from './do'`) cannot be
52
+ * wrapped here and are left alone — the plugin warns about them via
53
+ * {@link TransformResult.wrappedClasses}.
54
+ *
55
+ * Exported (rather than inlined into the plugin) so it can be unit-tested with a
56
+ * plain AST and no Vite context. Returns `undefined` when nothing was wrapped and
57
+ * there are no already-manually-wrapped classes to report.
58
+ */
59
+ export declare function applyAutoInstrumentTransforms(code: string, ast: ProgramBody, ctx: TransformContext): TransformResult | undefined;
60
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { ProgramBody } from './transform';
2
+ /**
3
+ * Find top-level classes that (transitively, within this module) extend
4
+ * `WorkerEntrypoint` imported from `cloudflare:workers`. esbuild has already
5
+ * stripped TypeScript by transform time, so a superclass is a plain identifier
6
+ * (`extends WorkerEntrypoint`) or member access (`extends cf.WorkerEntrypoint`).
7
+ *
8
+ * Only same-file base chains are resolvable here; a base class imported from
9
+ * another module is invisible and relies on the config self-binding fallback.
10
+ */
11
+ export declare function detectWorkerEntrypointClasses(ast: ProgramBody): Set<string>;
12
+ //# sourceMappingURL=workerEntrypoint.d.ts.map
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The slice of the wrangler configuration the auto-instrument plugin cares
3
+ * about. `main` is an absolute path (wrangler resolves it against the config
4
+ * file's directory).
5
+ */
6
+ export interface WranglerConfig {
7
+ main?: string;
8
+ durableObjects: Array<{
9
+ name: string;
10
+ className: string;
11
+ }>;
12
+ workflows: Array<{
13
+ name: string;
14
+ className: string;
15
+ }>;
16
+ /**
17
+ * Named `WorkerEntrypoint` exports this worker binds to itself via a service
18
+ * binding (`services[]` whose `service` is this worker's own `name`). Only
19
+ * self-bindings appear here: a service binding's `entrypoint` otherwise names
20
+ * an export on a *different* worker, which this build can't wrap.
21
+ */
22
+ workerEntrypoints: string[];
23
+ }
24
+ /**
25
+ * Locate and resolve the wrangler configuration via wrangler's own
26
+ * `unstable_readConfig` — the API `@cloudflare/vite-plugin` uses.
27
+ *
28
+ * We only locate the file (probing `wrangler.json`, `.jsonc`, `.toml` inside
29
+ * `root` with wrangler's own precedence, since it discovers from `cwd` rather
30
+ * than an arbitrary root); wrangler then parses it, flattens the active
31
+ * environment (honoring `CLOUDFLARE_ENV`), and resolves `main` to an absolute
32
+ * path. Durable Object and Workflow bindings are the active environment's,
33
+ * matching what the deployed Worker actually binds.
34
+ *
35
+ * Returns `undefined` when no config file is found or it can't be read/parsed
36
+ * (the caller warns and disables auto-instrumentation rather than failing the
37
+ * whole build).
38
+ */
39
+ export declare function resolveWranglerConfig(root: string, explicitPath?: string): {
40
+ config: WranglerConfig;
41
+ configDir: string;
42
+ } | undefined;
43
+ //# sourceMappingURL=wranglerConfig.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/cloudflare",
3
- "version": "10.67.0",
3
+ "version": "10.68.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",
@@ -46,6 +46,16 @@
46
46
  "types": "./build/types/nodejs_compat/index.d.ts",
47
47
  "default": "./build/cjs/nodejs_compat/index.js"
48
48
  }
49
+ },
50
+ "./vite": {
51
+ "import": {
52
+ "types": "./build/types/vite/index.d.ts",
53
+ "default": "./build/esm/vite/index.js"
54
+ },
55
+ "require": {
56
+ "types": "./build/types/vite/index.d.ts",
57
+ "default": "./build/cjs/vite/index.js"
58
+ }
49
59
  }
50
60
  },
51
61
  "typesVersions": {
@@ -60,16 +70,20 @@
60
70
  },
61
71
  "dependencies": {
62
72
  "@opentelemetry/api": "^1.9.1",
63
- "@sentry/core": "10.67.0",
64
- "@sentry/node": "10.67.0",
65
- "@sentry/server-utils": "10.67.0"
73
+ "@sentry/core": "10.68.0",
74
+ "@sentry/server-utils": "10.68.0",
75
+ "magic-string": "~0.30.21"
66
76
  },
67
77
  "peerDependencies": {
68
- "@cloudflare/workers-types": "^4.x || ^5.x"
78
+ "@cloudflare/workers-types": "^4.x || ^5.x",
79
+ "wrangler": "^4.x"
69
80
  },
70
81
  "peerDependenciesMeta": {
71
82
  "@cloudflare/workers-types": {
72
83
  "optional": true
84
+ },
85
+ "wrangler": {
86
+ "optional": true
73
87
  }
74
88
  },
75
89
  "devDependencies": {