From 9c371ab4dca5b0610e8eb2f532ad75883c266475 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Tue, 17 Mar 2026 15:13:36 +0100 Subject: [PATCH 1/2] docs: Add strict trace continuation docs for Capacitor and React Native - Remove `categorySupported` restriction from `strictTraceContinuation` and `orgId` options so they show for all JS platforms (not just server/serverless) - Create Capacitor distributed tracing include with strict trace continuation section - Add strict trace continuation section to React Native distributed tracing include --- .../common/configuration/options.mdx | 4 +- .../how-to-use/javascript.capacitor.mdx | 54 +++++++++++++++++++ .../how-to-use/react-native.mdx | 30 +++++++++++ 3 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 platform-includes/distributed-tracing/how-to-use/javascript.capacitor.mdx diff --git a/docs/platforms/javascript/common/configuration/options.mdx b/docs/platforms/javascript/common/configuration/options.mdx index 9761465d6983a..1c9e97e4ea325 100644 --- a/docs/platforms/javascript/common/configuration/options.mdx +++ b/docs/platforms/javascript/common/configuration/options.mdx @@ -18,7 +18,7 @@ sidebar_order: 1 - + The organization ID for your Sentry project. @@ -436,7 +436,7 @@ If you want to disable trace propagation, you can set this option to `[]`. - + If set to `true`, the SDK will only continue a trace if the organization ID of the incoming trace found in the `baggage` header matches the organization ID of the current Sentry client. diff --git a/platform-includes/distributed-tracing/how-to-use/javascript.capacitor.mdx b/platform-includes/distributed-tracing/how-to-use/javascript.capacitor.mdx new file mode 100644 index 0000000000000..c67ea38598c22 --- /dev/null +++ b/platform-includes/distributed-tracing/how-to-use/javascript.capacitor.mdx @@ -0,0 +1,54 @@ +If you're using the current version of our Capacitor SDK, distributed tracing will work out of the box. + +To get around possible [Browser CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) issues, define your `tracePropagationTargets`. + +```javascript +Sentry.init({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + tracePropagationTargets: ["https://myproject.org", /^\/api\//], +}); +``` + +### Strict Trace Continuation + +When your application receives requests, they might include `sentry-trace` and `baggage` headers from an upstream service that is also using Sentry. +By default, the SDK will continue the trace from these incoming headers. However, this behavior can be undesirable if the requests are from a third-party service, +as it can lead to unwanted traces, increased billing, and skewed performance data. + +To prevent this, you can enable `strictTraceContinuation`. When this option is set to `true`, the SDK checks the incoming request for Sentry trace information and only continues the trace if it belongs to the same Sentry organization. +Otherwise, it starts a new trace. + +```javascript {4} +Sentry.init({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + // Ensure that only traces from your own organization are continued + strictTraceContinuation: true, +}); +``` + +The SDK automatically parses the organization ID from your DSN. If you use a DSN format that doesn't include the organization ID (number followed by the letter `"o"`), or if you need to override it, you can provide it manually using the `orgId` option: + +```javascript {5} +Sentry.init({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + strictTraceContinuation: true, + // Manually provide your organization ID (overrides organization ID parsed from DSN) + orgId: 12345, +}); +``` + +### Disabling Distributed Tracing + +If you want to disable distributed tracing and ensure no Sentry trace headers are sent, you can configure your SDK like this: + +```javascript +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // Overwrite the defaults to ensure no trace headers are sent + tracePropagationTargets: [], +}); +``` diff --git a/platform-includes/distributed-tracing/how-to-use/react-native.mdx b/platform-includes/distributed-tracing/how-to-use/react-native.mdx index cbad4b0a41058..2284ba7d0a1f3 100644 --- a/platform-includes/distributed-tracing/how-to-use/react-native.mdx +++ b/platform-includes/distributed-tracing/how-to-use/react-native.mdx @@ -8,3 +8,33 @@ Sentry.init({ ``` If you're using version `5.9.x` or below, you'll need to have our tracing feature enabled in order for distributed tracing to work. + +### Strict Trace Continuation + +When your application receives requests, they might include `sentry-trace` and `baggage` headers from an upstream service that is also using Sentry. +By default, the SDK will continue the trace from these incoming headers. However, this behavior can be undesirable if the requests are from a third-party service, +as it can lead to unwanted traces, increased billing, and skewed performance data. + +To prevent this, you can enable `strictTraceContinuation`. When this option is set to `true`, the SDK checks the incoming request for Sentry trace information and only continues the trace if it belongs to the same Sentry organization. +Otherwise, it starts a new trace. + +```javascript {4} +Sentry.init({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + // Ensure that only traces from your own organization are continued + strictTraceContinuation: true, +}); +``` + +The SDK automatically parses the organization ID from your DSN. If you use a DSN format that doesn't include the organization ID (number followed by the letter `"o"`), or if you need to override it, you can provide it manually using the `orgId` option: + +```javascript {5} +Sentry.init({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + strictTraceContinuation: true, + // Manually provide your organization ID (overrides organization ID parsed from DSN) + orgId: 12345, +}); +``` From dafdee87918b9d376aed243036e33cdf74885f20 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Tue, 17 Mar 2026 15:15:53 +0100 Subject: [PATCH 2/2] docs: Scope PR to Capacitor only, remove React Native changes --- .../how-to-use/react-native.mdx | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/platform-includes/distributed-tracing/how-to-use/react-native.mdx b/platform-includes/distributed-tracing/how-to-use/react-native.mdx index 2284ba7d0a1f3..cbad4b0a41058 100644 --- a/platform-includes/distributed-tracing/how-to-use/react-native.mdx +++ b/platform-includes/distributed-tracing/how-to-use/react-native.mdx @@ -8,33 +8,3 @@ Sentry.init({ ``` If you're using version `5.9.x` or below, you'll need to have our tracing feature enabled in order for distributed tracing to work. - -### Strict Trace Continuation - -When your application receives requests, they might include `sentry-trace` and `baggage` headers from an upstream service that is also using Sentry. -By default, the SDK will continue the trace from these incoming headers. However, this behavior can be undesirable if the requests are from a third-party service, -as it can lead to unwanted traces, increased billing, and skewed performance data. - -To prevent this, you can enable `strictTraceContinuation`. When this option is set to `true`, the SDK checks the incoming request for Sentry trace information and only continues the trace if it belongs to the same Sentry organization. -Otherwise, it starts a new trace. - -```javascript {4} -Sentry.init({ - dsn: "___PUBLIC_DSN___", - tracesSampleRate: 1.0, - // Ensure that only traces from your own organization are continued - strictTraceContinuation: true, -}); -``` - -The SDK automatically parses the organization ID from your DSN. If you use a DSN format that doesn't include the organization ID (number followed by the letter `"o"`), or if you need to override it, you can provide it manually using the `orgId` option: - -```javascript {5} -Sentry.init({ - dsn: "___PUBLIC_DSN___", - tracesSampleRate: 1.0, - strictTraceContinuation: true, - // Manually provide your organization ID (overrides organization ID parsed from DSN) - orgId: 12345, -}); -```