Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first.
<!-- prettier-ignore-end -->

## Unreleased

### Features

- Adds support for `propagateTraceparent` ([#5277](https://github.com/getsentry/sentry-react-native/pull/5227))

## 7.3.0

### Features
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/js/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,20 @@ export interface BaseReactNativeOptions {
* @deprecated This option will be removed in the next major version. Use `beforeSend` instead.
*/
useThreadsForMessageStack?: boolean;

/**
* If set to `true`, the SDK propagates the W3C `traceparent` header to any outgoing requests,
* in addition to the `sentry-trace` and `baggage` headers. Use the {@link CoreOptions.tracePropagationTargets}
* option to control to which outgoing requests the header will be attached.
*
* **Important:** If you set this option to `true`, make sure that you configured your servers'
* CORS settings to allow the `traceparent` header. Otherwise, requests might get blocked.
*
* @see https://www.w3.org/TR/trace-context/
*
* @default false
*/
propagateTraceparent?: boolean;
}

export type SentryReplayQuality = 'low' | 'medium' | 'high';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/js/sdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const DEFAULT_OPTIONS: ReactNativeOptions = {
enableNativeFramesTracking: true,
enableStallTracking: true,
enableUserInteractionTracing: false,
propagateTraceparent: false,
};

/**
Expand Down
22 changes: 22 additions & 0 deletions packages/core/test/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,28 @@ describe('Tests the SDK functionality', () => {
});
});

it('propagateTraceparent is false by default', () => {
init({});

const actualOptions = usedOptions();
expect(actualOptions).toEqual(
expect.objectContaining({
propagateTraceparent: false,
})
)
});

it('propagateTraceparent is getting passed to the client', () => {
init({propagateTraceparent: true});

const actualOptions = usedOptions();
expect(actualOptions).toEqual(
expect.objectContaining({
propagateTraceparent: true,
})
)
})

function expectIntegration(name: string): void {
const actualOptions = usedOptions();
const actualIntegrations = actualOptions?.integrations;
Expand Down
2 changes: 2 additions & 0 deletions packages/core/test/tracing/reactnativetracing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe('ReactNativeTracing', () => {
const instrumentOutgoingRequests = jest.spyOn(SentryBrowser, 'instrumentOutgoingRequests');
setupTestClient({
tracePropagationTargets: ['test1', 'test2'],
propagateTraceparent: true,
enableStallTracking: false,
integrations: [reactNativeTracingIntegration()],
});
Expand All @@ -65,6 +66,7 @@ describe('ReactNativeTracing', () => {
expect.anything(),
expect.objectContaining({
tracePropagationTargets: ['test1', 'test2'],
propagateTraceparent: true,
}),
);
});
Expand Down
Loading