Skip to content

Commit 5b1fd7e

Browse files
fix tests
1 parent ead30ff commit 5b1fd7e

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi
2828

2929
### Major Changes
3030

31-
- `ip addresses` is only collected when `sendDefaultPii`: `true`
31+
- Set `{{auto}}` if `user.ip_address` is `undefined` and `sendDefaultPii: true` ([#4466](https://github.com/getsentry/sentry-react-native/pull/4466))
3232
- Exceptions from `captureConsoleIntegration` are now marked as handled: true by default
3333
- `shutdownTimeout` moved from `core` to `@sentry/react-native`
3434
- `hasTracingEnabled` was renamed to `hasSpansEnabled`
@@ -290,7 +290,6 @@ Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](http
290290
- Add mechanism field to unhandled rejection errors ([#4457](https://github.com/getsentry/sentry-react-native/pull/4457))
291291
- Use proper SDK name for Session Replay tags ([#4428](https://github.com/getsentry/sentry-react-native/pull/4428))
292292
- Use `makeDsn` from `core` to extract the URL from DSN avoiding unimplemented `URL.protocol` errors ([#4395](https://github.com/getsentry/sentry-react-native/pull/4395))
293-
- Set `{{auto}}` if `user.ip_address` is `undefined` ([#4466](https://github.com/getsentry/sentry-react-native/pull/4466))
294293

295294
### Changes
296295

packages/core/src/js/client.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
addAutoIpAddressToSession,
3-
addAutoIpAddressToUser,
4-
eventFromException,
5-
eventFromMessage,
6-
} from '@sentry/browser';
1+
import { eventFromException, eventFromMessage } from '@sentry/browser';
72
import type {
83
ClientReportEnvelope,
94
ClientReportItem,
@@ -15,7 +10,14 @@ import type {
1510
TransportMakeRequestResponse,
1611
UserFeedback,
1712
} from '@sentry/core';
18-
import { BaseClient, dateTimestampInSeconds, logger, SentryError } from '@sentry/core';
13+
import {
14+
BaseClient,
15+
dateTimestampInSeconds,
16+
logger,
17+
SentryError,
18+
addAutoIpAddressToSession,
19+
addAutoIpAddressToUser,
20+
} from '@sentry/core';
1921
import { Alert } from 'react-native';
2022

2123
import { getDevServer } from './integrations/debugsymbolicatorutils';

packages/core/test/client.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ describe('Tests ReactNativeClient', () => {
639639
send: mockTransportSend,
640640
flush: jest.fn(),
641641
}),
642+
sendDefaultPii: true,
642643
});
643644
});
644645

@@ -695,6 +696,24 @@ describe('Tests ReactNativeClient', () => {
695696
expect.objectContaining({ ip_address: '{{auto}}' }),
696697
);
697698
});
699+
700+
test('does not add ip_address {{auto}} to undefined user if sendDefaultPii is false', () => {
701+
client = new ReactNativeClient({
702+
...DEFAULT_OPTIONS,
703+
dsn: EXAMPLE_DSN,
704+
transport: () => ({
705+
send: mockTransportSend,
706+
flush: jest.fn(),
707+
}),
708+
sendDefaultPii: false,
709+
});
710+
711+
client.captureEvent({});
712+
713+
expect(
714+
mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user?.ip_address,
715+
).toBeUndefined();
716+
});
698717
});
699718
});
700719

0 commit comments

Comments
 (0)