Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter beforeSendTransaction from the Native SDK #3140

Merged
merged 8 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- Filter beforeSendTransaction from the Native SDK ([#3140](https://github.com/getsentry/sentry-react-native/pull/3140))

### Features

- Use `android.namespace` for AGP 8 and RN 0.73 ([#3133](https://github.com/getsentry/sentry-react-native/pull/3133))
Expand Down
2 changes: 1 addition & 1 deletion src/js/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const NATIVE: SentryNativeWrapper = {

// filter out all the options that would crash native.
/* eslint-disable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */
const { beforeSend, beforeBreadcrumb, integrations, ...filteredOptions } = options;
const { beforeSend, beforeBreadcrumb, beforeSendTransaction, integrations, ...filteredOptions } = options;
/* eslint-enable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */
const nativeIsReady = await RNSentry.initNativeSdk(filteredOptions);

Expand Down
60 changes: 60 additions & 0 deletions test/wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,66 @@ describe('Tests Native Wrapper', () => {
expect(logger.warn).toHaveBeenLastCalledWith('Note: Native Sentry SDK is disabled.');
});

test('filter beforeSend when initializing Native SDK', async () => {
await NATIVE.initNativeSdk({
dsn: 'test',
enableNative: true,
autoInitializeNativeSdk: true,
beforeSend: jest.fn(),
});

expect(RNSentry.initNativeSdk).toBeCalled();
// @ts-ignore mock value
const initParameter = RNSentry.initNativeSdk.mock.calls[0][0];
expect(initParameter).not.toHaveProperty('beforeSend');
expect(NATIVE.enableNative).toBe(true);
});

test('filter beforeBreadcrumb when initializing Native SDK', async () => {
await NATIVE.initNativeSdk({
dsn: 'test',
enableNative: true,
autoInitializeNativeSdk: true,
beforeBreadcrumb: jest.fn(),
});

expect(RNSentry.initNativeSdk).toBeCalled();
// @ts-ignore mock value
const initParameter = RNSentry.initNativeSdk.mock.calls[0][0];
expect(initParameter).not.toHaveProperty('beforeBreadcrumb');
expect(NATIVE.enableNative).toBe(true);
});

test('filter beforeSendTransaction when initializing Native SDK', async () => {
await NATIVE.initNativeSdk({
dsn: 'test',
enableNative: true,
autoInitializeNativeSdk: true,
beforeSendTransaction: jest.fn(),
});

expect(RNSentry.initNativeSdk).toBeCalled();
// @ts-ignore mock value
const initParameter = RNSentry.initNativeSdk.mock.calls[0][0];
expect(initParameter).not.toHaveProperty('beforeSendTransaction');
expect(NATIVE.enableNative).toBe(true);
});

test('filter integrations when initializing Native SDK', async () => {
await NATIVE.initNativeSdk({
dsn: 'test',
enableNative: true,
autoInitializeNativeSdk: true,
integrations: [],
});

expect(RNSentry.initNativeSdk).toBeCalled();
// @ts-ignore mock value
const initParameter = RNSentry.initNativeSdk.mock.calls[0][0];
expect(initParameter).not.toHaveProperty('integrations');
expect(NATIVE.enableNative).toBe(true);
});

test('does not initialize with autoInitializeNativeSdk: false', async () => {
NATIVE.enableNative = false;
logger.warn = jest.fn();
Expand Down