From 281085ef84954fe8b92d81b0238295713dc91d0a Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Wed, 14 Jan 2026 11:12:53 +0100 Subject: [PATCH 1/3] docs(cloudflare): Add info why CF_VERSION_METADATA is used --- .../getting-started-config/javascript.cloudflare.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/getting-started-config/javascript.cloudflare.mdx b/platform-includes/getting-started-config/javascript.cloudflare.mdx index 4face285b2492..1a77bf87678fc 100644 --- a/platform-includes/getting-started-config/javascript.cloudflare.mdx +++ b/platform-includes/getting-started-config/javascript.cloudflare.mdx @@ -14,7 +14,7 @@ compatibility_flags = ["nodejs_als"] # compatibility_flags = ["nodejs_compat"] ``` -Additionally, add the `CF_VERSION_METADATA` binding in the same file: +Additionally, add the `CF_VERSION_METADATA` binding in the same file. This binding provides access to the [Cloudflare version metadata](https://developers.cloudflare.com/workers/runtime-apis/bindings/version-metadata/), which the SDK uses to automatically set the Sentry `release` value based on your deployment version: ```jsonc {tabTitle:JSON} {filename:wrangler.jsonc} { From 2d5eb615920fb5d565b8d4a73e15d03b1b5409f1 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Tue, 27 Jan 2026 16:24:05 +0100 Subject: [PATCH 2/3] fixup! docs(cloudflare): Add info why CF_VERSION_METADATA is used --- .../javascript/guides/cloudflare/index.mdx | 44 ++++++++----------- .../javascript.cloudflare.hono.mdx | 44 ++++++++----------- .../javascript.cloudflare.mdx | 12 ++++- .../javascript.cloudflare.workers.mdx | 38 +++++++--------- 4 files changed, 64 insertions(+), 74 deletions(-) diff --git a/docs/platforms/javascript/guides/cloudflare/index.mdx b/docs/platforms/javascript/guides/cloudflare/index.mdx index 46d8ff82bcf8b..c10be92bbc02d 100644 --- a/docs/platforms/javascript/guides/cloudflare/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/index.mdx @@ -61,31 +61,25 @@ import * as Sentry from "@sentry/cloudflare"; export const onRequest = [ // Make sure Sentry is the first middleware - Sentry.sentryPagesPlugin((context) => { - const { id: versionId } = env.CF_VERSION_METADATA; - - return { - dsn: "___PUBLIC_DSN___", - - release: versionId, - - // Adds request headers and IP for users, for more info visit: - // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#sendDefaultPii - sendDefaultPii: true, - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - enableLogs: true, - // ___PRODUCT_OPTION_END___ logs - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. - // Learn more at - // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#tracesSampleRate - tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance - }; - }), + Sentry.sentryPagesPlugin((context) => ({ + dsn: "___PUBLIC_DSN___", + + // Adds request headers and IP for users, for more info visit: + // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#sendDefaultPii + sendDefaultPii: true, + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + enableLogs: true, + // ___PRODUCT_OPTION_END___ logs + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. + // Learn more at + // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#tracesSampleRate + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + })), // Add more middlewares here ]; ``` diff --git a/platform-includes/getting-started-config/javascript.cloudflare.hono.mdx b/platform-includes/getting-started-config/javascript.cloudflare.hono.mdx index c027e06802e60..f3edfd7b3d4f3 100644 --- a/platform-includes/getting-started-config/javascript.cloudflare.hono.mdx +++ b/platform-includes/getting-started-config/javascript.cloudflare.hono.mdx @@ -10,31 +10,25 @@ const app = new Hono(); // app.get('/your-route', (c) => c.text('Hello!')); export default Sentry.withSentry( - (env: Env) => { - const { id: versionId } = env.CF_VERSION_METADATA; - - return { - dsn: "___PUBLIC_DSN___", - - release: versionId, - - // Adds request headers and IP for users, for more info visit: - // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#sendDefaultPii - sendDefaultPii: true, - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - enableLogs: true, - // ___PRODUCT_OPTION_END___ logs - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. - // Learn more at - // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#tracesSampleRate - tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance - }; - }, + (env: Env) => ({ + dsn: "___PUBLIC_DSN___", + + // Adds request headers and IP for users, for more info visit: + // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#sendDefaultPii + sendDefaultPii: true, + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + enableLogs: true, + // ___PRODUCT_OPTION_END___ logs + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. + // Learn more at + // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#tracesSampleRate + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + }), app ); ``` diff --git a/platform-includes/getting-started-config/javascript.cloudflare.mdx b/platform-includes/getting-started-config/javascript.cloudflare.mdx index 1a77bf87678fc..f2808787d1bbc 100644 --- a/platform-includes/getting-started-config/javascript.cloudflare.mdx +++ b/platform-includes/getting-started-config/javascript.cloudflare.mdx @@ -14,7 +14,14 @@ compatibility_flags = ["nodejs_als"] # compatibility_flags = ["nodejs_compat"] ``` -Additionally, add the `CF_VERSION_METADATA` binding in the same file. This binding provides access to the [Cloudflare version metadata](https://developers.cloudflare.com/workers/runtime-apis/bindings/version-metadata/), which the SDK uses to automatically set the Sentry `release` value based on your deployment version: +### Release Configuration (Optional) + +If you don't set the `release` option manually, the SDK automatically detects it from these sources (in order of priority): + +1. The `SENTRY_RELEASE` environment variable +2. The `CF_VERSION_METADATA.id` binding (if configured) + +To enable automatic release detection via Cloudflare's version metadata, add the `CF_VERSION_METADATA` binding in your wrangler configuration. This provides access to the [Cloudflare version metadata](https://developers.cloudflare.com/workers/runtime-apis/bindings/version-metadata/): ```jsonc {tabTitle:JSON} {filename:wrangler.jsonc} { @@ -26,5 +33,6 @@ Additionally, add the `CF_VERSION_METADATA` binding in the same file. This bindi ``` ```toml {tabTitle:Toml} {filename:wrangler.toml} -version_metadata = { binding = "CF_VERSION_METADATA" } +[version_metadata] +binding = "CF_VERSION_METADATA" ``` diff --git a/platform-includes/getting-started-config/javascript.cloudflare.workers.mdx b/platform-includes/getting-started-config/javascript.cloudflare.workers.mdx index 8f5d20a26f5af..9c794743eda9d 100644 --- a/platform-includes/getting-started-config/javascript.cloudflare.workers.mdx +++ b/platform-includes/getting-started-config/javascript.cloudflare.workers.mdx @@ -4,31 +4,25 @@ Wrap your worker handler with the `withSentry` function, for example, in your `i import * as Sentry from "@sentry/cloudflare"; export default Sentry.withSentry( - (env: Env) => { - const { id: versionId } = env.CF_VERSION_METADATA; + (env: Env) => ({ + dsn: "___PUBLIC_DSN___", - return { - dsn: "___PUBLIC_DSN___", + // Adds request headers and IP for users, for more info visit: + // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#sendDefaultPii + sendDefaultPii: true, + // ___PRODUCT_OPTION_START___ logs - release: versionId, + // Enable logs to be sent to Sentry + enableLogs: true, + // ___PRODUCT_OPTION_END___ logs + // ___PRODUCT_OPTION_START___ performance - // Adds request headers and IP for users, for more info visit: - // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#sendDefaultPii - sendDefaultPii: true, - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - enableLogs: true, - // ___PRODUCT_OPTION_END___ logs - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. - // Learn more at - // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#tracesSampleRate - tracesSampleRate: 1.0, - // ___PRODUCT_OPTION_END___ performance - }; - }, + // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. + // Learn more at + // https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#tracesSampleRate + tracesSampleRate: 1.0, + // ___PRODUCT_OPTION_END___ performance + }), { async fetch(request, env, ctx) { // Your worker logic here From 0a73bf8d1a016c4b2ecbae23699c076ce6864683 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Tue, 27 Jan 2026 17:06:41 +0100 Subject: [PATCH 3/3] fixup! docs(cloudflare): Add info why CF_VERSION_METADATA is used --- .../javascript.cloudflare.mdx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/platform-includes/getting-started-config/javascript.cloudflare.mdx b/platform-includes/getting-started-config/javascript.cloudflare.mdx index f2808787d1bbc..d6a543aa9c4ed 100644 --- a/platform-includes/getting-started-config/javascript.cloudflare.mdx +++ b/platform-includes/getting-started-config/javascript.cloudflare.mdx @@ -23,12 +23,28 @@ If you don't set the `release` option manually, the SDK automatically detects it To enable automatic release detection via Cloudflare's version metadata, add the `CF_VERSION_METADATA` binding in your wrangler configuration. This provides access to the [Cloudflare version metadata](https://developers.cloudflare.com/workers/runtime-apis/bindings/version-metadata/): + + +In earlier versions, you need to manually extract `CF_VERSION_METADATA.id` and pass it as the `release` option: + +```javascript +Sentry.withSentry( + (env) => ({ + dsn: "___PUBLIC_DSN___", + release: env.CF_VERSION_METADATA?.id, + }), + // ... +); +``` + + + ```jsonc {tabTitle:JSON} {filename:wrangler.jsonc} { // ... "version_metadata": { - "binding": "CF_VERSION_METADATA", - }, + "binding": "CF_VERSION_METADATA" + } } ```