Skip to content

Commit d088905

Browse files
authored
Add support for propagateTraceparent (#5227)
1 parent 07808fb commit d088905

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
99
## Unreleased
1010

11+
### Features
12+
13+
- Adds support for `propagateTraceparent` ([#5277](https://github.com/getsentry/sentry-react-native/pull/5227))
14+
1115
### Dependencies
1216

1317
- Bump JavaScript SDK from v10.18.0 to v10.19.0 ([#5254](https://github.com/getsentry/sentry-react-native/pull/5254))

packages/core/src/js/options.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,20 @@ export interface BaseReactNativeOptions {
291291
* @deprecated This option will be removed in the next major version. Use `beforeSend` instead.
292292
*/
293293
useThreadsForMessageStack?: boolean;
294+
295+
/**
296+
* If set to `true`, the SDK propagates the W3C `traceparent` header to any outgoing requests,
297+
* in addition to the `sentry-trace` and `baggage` headers. Use the {@link CoreOptions.tracePropagationTargets}
298+
* option to control to which outgoing requests the header will be attached.
299+
*
300+
* **Important:** If you set this option to `true`, make sure that you configured your servers'
301+
* CORS settings to allow the `traceparent` header. Otherwise, requests might get blocked.
302+
*
303+
* @see https://www.w3.org/TR/trace-context/
304+
*
305+
* @default false
306+
*/
307+
propagateTraceparent?: boolean;
294308
}
295309

296310
export type SentryReplayQuality = 'low' | 'medium' | 'high';

packages/core/src/js/sdk.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const DEFAULT_OPTIONS: ReactNativeOptions = {
4545
enableNativeFramesTracking: true,
4646
enableStallTracking: true,
4747
enableUserInteractionTracing: false,
48+
propagateTraceparent: false,
4849
};
4950

5051
/**

packages/core/test/sdk.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,28 @@ describe('Tests the SDK functionality', () => {
11561156
}),
11571157
);
11581158
});
1159+
1160+
it('propagateTraceparent is false by default', () => {
1161+
init({});
1162+
1163+
const actualOptions = usedOptions();
1164+
expect(actualOptions).toEqual(
1165+
expect.objectContaining({
1166+
propagateTraceparent: false,
1167+
}),
1168+
);
1169+
});
1170+
1171+
it('propagateTraceparent is getting passed to the client', () => {
1172+
init({ propagateTraceparent: true });
1173+
1174+
const actualOptions = usedOptions();
1175+
expect(actualOptions).toEqual(
1176+
expect.objectContaining({
1177+
propagateTraceparent: true,
1178+
}),
1179+
);
1180+
});
11591181
});
11601182

11611183
function expectIntegration(name: string): void {

0 commit comments

Comments
 (0)