Skip to content

Commit

Permalink
fix(client): use _setupIntegrations to extend both init and publi…
Browse files Browse the repository at this point in the history
…c `setupIntegrations` (#3882)
  • Loading branch information
krystofwoldrich authored Jun 13, 2024
1 parent f2f3399 commit 9fc8151
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### Fixes

- Add more expressive debug logs to Native Frames Integration ([#3880](https://github.com/getsentry/sentry-react-native/pull/3880))
- Add missing tracing integrations when using `client.init()` ([#3882](https://github.com/getsentry/sentry-react-native/pull/3882))

### Dependencies

Expand Down
4 changes: 2 additions & 2 deletions src/js/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
/**
* Sets up the integrations
*/
public setupIntegrations(): void {
super.setupIntegrations();
protected _setupIntegrations(): void {
super._setupIntegrations();
const tracing = this.getIntegration(ReactNativeTracing);
const routingName = tracing?.options.routingInstrumentation?.name;
if (routingName) {
Expand Down
32 changes: 32 additions & 0 deletions test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,22 @@ describe('Tests ReactNativeClient', () => {
expect(client.getIntegrationById('ReactNativeUserInteractionTracing')).toBeTruthy();
});

test('register user interactions tracing - init()', () => {
const client = new ReactNativeClient(
mockedOptions({
dsn: EXAMPLE_DSN,
integrations: [
new ReactNativeTracing({
enableUserInteractionTracing: true,
}),
],
}),
);
client.init();

expect(client.getIntegrationById('ReactNativeUserInteractionTracing')).toBeTruthy();
});

test('do not register user interactions tracing', () => {
const client = new ReactNativeClient(
mockedOptions({
Expand All @@ -682,6 +698,22 @@ describe('Tests ReactNativeClient', () => {

expect(client.getIntegrationById('ReactNativeUserInteractionTracing')).toBeUndefined();
});

test('do not register user interactions tracing - init()', () => {
const client = new ReactNativeClient(
mockedOptions({
dsn: EXAMPLE_DSN,
integrations: [
new ReactNativeTracing({
enableUserInteractionTracing: false,
}),
],
}),
);
client.init();

expect(client.getIntegrationById('ReactNativeUserInteractionTracing')).toBeUndefined();
});
});
});

Expand Down

0 comments on commit 9fc8151

Please sign in to comment.