Skip to content
Merged
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
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi

### Dependencies

- Bump JavaScript SDK from v8.54.0 to v9.12.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568), [#4752](https://github.com/getsentry/sentry-react-native/pull/4752))
- [changelog](https://github.com/getsentry/sentry-javascript/blob/9.12.0/CHANGELOG.md)
- [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.12.0)
- Bump Bundler Plugins from v3.2.2 to v3.2.4 ([#4693](https://github.com/getsentry/sentry-react-native/pull/4693), [#4707](https://github.com/getsentry/sentry-react-native/pull/4707))
- [changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/CHANGELOG.md#324)
- [diff](https://github.com/getsentry/sentry-javascript-bundler-plugins/compare/3.2.2...3.2.4)
Expand All @@ -25,7 +28,7 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi

### Major Changes

- `ip addresses` is only collected when `sendDefaultPii`: `true`
- Set `{{auto}}` if `user.ip_address` is `undefined` and `sendDefaultPii: true` ([#4466](https://github.com/getsentry/sentry-react-native/pull/4466))
- Exceptions from `captureConsoleIntegration` are now marked as handled: true by default
- `shutdownTimeout` moved from `core` to `@sentry/react-native`
- `hasTracingEnabled` was renamed to `hasSpansEnabled`
Expand Down Expand Up @@ -223,9 +226,6 @@ Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](http

### Dependencies

- Bump JavaScript SDK from v8.54.0 to v9.1.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568))
- [changelog](https://github.com/getsentry/sentry-javascript/blob/9.1.0/CHANGELOG.md)
- [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.1.0)
- Bump Android SDK from v7.20.1 to v8.3.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#830)
- [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.3.0)
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"devDependencies": {
"@babel/preset-env": "^7.25.3",
"@babel/preset-typescript": "^7.18.6",
"@sentry/core": "9.1.0",
"@sentry/core": "9.12.0",
"@sentry/react-native": "6.11.0-beta.0",
"@types/node": "^20.9.3",
"@types/react": "^18.2.64",
Expand Down
14 changes: 7 additions & 7 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@
},
"dependencies": {
"@sentry/babel-plugin-component-annotate": "3.1.2",
"@sentry/browser": "9.1.0",
"@sentry/browser": "9.12.0",
"@sentry/cli": "2.43.0",
"@sentry/core": "9.1.0",
"@sentry/react": "9.1.0",
"@sentry/types": "9.1.0"
"@sentry/core": "9.12.0",
"@sentry/react": "9.12.0",
"@sentry/types": "9.12.0"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@expo/metro-config": "0.19.5",
"@mswjs/interceptors": "^0.25.15",
"@react-native/babel-preset": "0.77.1",
"@sentry-internal/eslint-config-sdk": "9.1.0",
"@sentry-internal/eslint-plugin-sdk": "9.1.0",
"@sentry-internal/typescript": "9.1.0",
"@sentry-internal/eslint-config-sdk": "9.12.0",
"@sentry-internal/eslint-plugin-sdk": "9.12.0",
"@sentry-internal/typescript": "9.12.0",
"@sentry/wizard": "4.6.0",
"@testing-library/react-native": "^12.7.2",
"@types/jest": "^29.5.13",
Expand Down
14 changes: 13 additions & 1 deletion packages/core/src/js/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ import type {
TransportMakeRequestResponse,
UserFeedback,
} from '@sentry/core';
import { BaseClient, dateTimestampInSeconds, logger, SentryError } from '@sentry/core';
import {
BaseClient,
dateTimestampInSeconds,
logger,
SentryError,
addAutoIpAddressToSession,
addAutoIpAddressToUser,
} from '@sentry/core';
import { Alert } from 'react-native';

import { getDevServer } from './integrations/debugsymbolicatorutils';
Expand Down Expand Up @@ -48,6 +55,11 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
super(options);

this._outcomesBuffer = [];

if (options.sendDefaultPii === true) {
this.on('postprocessEvent', addAutoIpAddressToUser);
this.on('beforeSendSession', addAutoIpAddressToSession);
}
}

/**
Expand Down
90 changes: 90 additions & 0 deletions packages/core/test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,96 @@ describe('Tests ReactNativeClient', () => {
client.recordDroppedEvent('before_send', 'error');
}
});

describe('ipAddress', () => {
let mockTransportSend: jest.Mock;
let client: ReactNativeClient;

beforeEach(() => {
mockTransportSend = jest.fn(() => Promise.resolve());
client = new ReactNativeClient({
...DEFAULT_OPTIONS,
dsn: EXAMPLE_DSN,
transport: () => ({
send: mockTransportSend,
flush: jest.fn(),
}),
sendDefaultPii: true,
});
});

test('preserves ip_address null', () => {
client.captureEvent({
user: {
ip_address: null,
},
});

expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user).toEqual(
expect.objectContaining({ ip_address: null }),
);
});

test('preserves ip_address value if set', () => {
client.captureEvent({
user: {
ip_address: '203.45.167.89',
},
});

expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user).toEqual(
expect.objectContaining({ ip_address: '203.45.167.89' }),
);
});

test('adds ip_address {{auto}} to user if set to undefined', () => {
client.captureEvent({
user: {
ip_address: undefined,
},
});

expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user).toEqual(
expect.objectContaining({ ip_address: '{{auto}}' }),
);
});

test('adds ip_address {{auto}} to user if not set', () => {
client.captureEvent({
user: {},
});

expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user).toEqual(
expect.objectContaining({ ip_address: '{{auto}}' }),
);
});

test('adds ip_address {{auto}} to undefined user', () => {
client.captureEvent({});

expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user).toEqual(
expect.objectContaining({ ip_address: '{{auto}}' }),
);
});

test('does not add ip_address {{auto}} to undefined user if sendDefaultPii is false', () => {
client = new ReactNativeClient({
...DEFAULT_OPTIONS,
dsn: EXAMPLE_DSN,
transport: () => ({
send: mockTransportSend,
flush: jest.fn(),
}),
sendDefaultPii: false,
});

client.captureEvent({});

expect(
mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user?.ip_address,
).toBeUndefined();
});
});
});

function mockedOptions(options: Partial<ReactNativeClientOptions>): ReactNativeClientOptions {
Expand Down
4 changes: 2 additions & 2 deletions samples/react-native-macos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"@react-navigation/bottom-tabs": "^6.5.12",
"@react-navigation/native": "^6.1.9",
"@react-navigation/stack": "^6.3.20",
"@sentry/core": "9.1.0",
"@sentry/react": "9.1.0",
"@sentry/core": "9.12.0",
"@sentry/react": "9.12.0",
"@sentry/react-native": "6.11.0-beta.0",
"delay": "^6.0.0",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion samples/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@react-navigation/native": "^7.0.14",
"@react-navigation/native-stack": "^7.2.0",
"@react-navigation/stack": "^7.1.1",
"@sentry/core": "9.1.0",
"@sentry/core": "9.12.0",
"@sentry/react-native": "6.11.0-beta.0",
"@shopify/flash-list": "^1.7.3",
"axios": "^1.8.3",
Expand Down
Loading
Loading