Skip to content

Commit 254a501

Browse files
authored
feat!: Only collect ip addresses with sendDefaultPii: true (#15084)
Ref: #5347 (comment)
1 parent 03e0d02 commit 254a501

File tree

34 files changed

+169
-76
lines changed

34 files changed

+169
-76
lines changed

Diff for: dev-packages/browser-integration-tests/suites/feedback/attachTo/test.ts

-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ sentryTest('should capture feedback with custom button', async ({ getLocalTestUr
5757
event_id: expect.stringMatching(/\w{32}/),
5858
environment: 'production',
5959
tags: {},
60-
user: {
61-
ip_address: '{{auto}}',
62-
},
6360
sdk: {
6461
integrations: expect.arrayContaining(['Feedback']),
6562
version: expect.any(String),

Diff for: dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts

-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
6969
'User-Agent': expect.stringContaining(''),
7070
},
7171
},
72-
user: {
73-
ip_address: '{{auto}}',
74-
},
7572
platform: 'javascript',
7673
});
7774
});

Diff for: dev-packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/hasSampling/test.ts

-3
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ sentryTest('should capture feedback', async ({ forceFlushReplay, getLocalTestUrl
103103
'User-Agent': expect.stringContaining(''),
104104
},
105105
},
106-
user: {
107-
ip_address: '{{auto}}',
108-
},
109106
platform: 'javascript',
110107
});
111108
});

Diff for: dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/test.ts

-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
6969
'User-Agent': expect.stringContaining(''),
7070
},
7171
},
72-
user: {
73-
ip_address: '{{auto}}',
74-
},
7572
platform: 'javascript',
7673
});
7774
const cspViolation = await page.evaluate<boolean>('window.__CSPVIOLATION__');

Diff for: dev-packages/browser-integration-tests/suites/manual-client/browser-context/test.ts

-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ sentryTest('allows to setup a client manually & capture exceptions', async ({ ge
3434
'User-Agent': expect.any(String),
3535
}),
3636
},
37-
user: {
38-
ip_address: '{{auto}}',
39-
},
4037
timestamp: expect.any(Number),
4138
environment: 'local',
4239
release: '0.0.1',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Sentry.captureException(new Error('woot'));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { expect } from '@playwright/test';
2+
import type { Event } from '@sentry/core';
3+
4+
import { sentryTest } from '../../../../utils/fixtures';
5+
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
6+
7+
sentryTest('should default user to {{auto}} on errors when sendDefaultPii: true', async ({ getLocalTestUrl, page }) => {
8+
const url = await getLocalTestUrl({ testDir: __dirname });
9+
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
10+
expect(eventData.user?.ip_address).toBe('{{auto}}');
11+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
Sentry.init({
6+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
7+
tracesSampleRate: 1,
8+
sendDefaultPii: true,
9+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Sentry.startSpan({ name: 'woot' }, () => undefined);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { expect } from '@playwright/test';
2+
import { sentryTest } from '../../../../utils/fixtures';
3+
import {
4+
envelopeRequestParser,
5+
shouldSkipTracingTest,
6+
waitForTransactionRequestOnUrl,
7+
} from '../../../../utils/helpers';
8+
9+
sentryTest(
10+
'should default user to {{auto}} on transactions when sendDefaultPii: true',
11+
async ({ getLocalTestUrl, page }) => {
12+
if (shouldSkipTracingTest()) {
13+
sentryTest.skip();
14+
}
15+
16+
const url = await getLocalTestUrl({ testDir: __dirname });
17+
const req = await waitForTransactionRequestOnUrl(page, url);
18+
const transaction = envelopeRequestParser(req);
19+
expect(transaction.user?.ip_address).toBe('{{auto}}');
20+
},
21+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
window.Replay = Sentry.replayIntegration({
6+
flushMinDelay: 200,
7+
flushMaxDelay: 200,
8+
minReplayDuration: 0,
9+
useCompression: false,
10+
blockAllMedia: false,
11+
unmask: ['.sentry-unmask, [data-sentry-unmask]'],
12+
});
13+
14+
Sentry.init({
15+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
16+
replaysSessionSampleRate: 1.0,
17+
replaysOnErrorSampleRate: 0.0,
18+
integrations: [window.Replay],
19+
sendDefaultPii: true,
20+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { getReplayEvent, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers';
5+
6+
sentryTest(
7+
'replay recording should contain default performance spans',
8+
async ({ getLocalTestUrl, page, browserName }) => {
9+
// We only test this against the NPM package and replay bundles
10+
// and only on chromium as most performance entries are only available in chromium
11+
if (shouldSkipReplayTest() || browserName !== 'chromium') {
12+
sentryTest.skip();
13+
}
14+
15+
const reqPromise0 = waitForReplayRequest(page, 0);
16+
17+
const url = await getLocalTestUrl({ testDir: __dirname });
18+
19+
await page.goto(url);
20+
const replayEvent = getReplayEvent(await reqPromise0);
21+
22+
expect(replayEvent.user?.ip_address).toBe('{{auto}}');
23+
},
24+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
Sentry.init({
6+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
7+
sendDefaultPii: true,
8+
release: '1.0',
9+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
5+
6+
sentryTest(
7+
'should default user to {{auto}} on sessions when sendDefaultPii: true',
8+
async ({ getLocalTestUrl, page }) => {
9+
const url = await getLocalTestUrl({ testDir: __dirname });
10+
const session = await getFirstSentryEnvelopeRequest(page, url);
11+
expect((session as any).attrs.ip_address).toBe('{{auto}}');
12+
},
13+
);

Diff for: dev-packages/browser-integration-tests/suites/public-api/setUser/init.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ window.Sentry = Sentry;
44

55
Sentry.init({
66
dsn: 'https://public@dsn.ingest.sentry.io/1337',
7+
sendDefaultPii: true,
78
});

Diff for: dev-packages/browser-integration-tests/suites/public-api/setUser/unset_user/test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ sentryTest('should unset user', async ({ getLocalTestUrl, page }) => {
1010
const eventData = await getMultipleSentryEnvelopeRequests<Event>(page, 3, { url });
1111

1212
expect(eventData[0].message).toBe('no_user');
13+
14+
// because sendDefaultPii: true
1315
expect(eventData[0].user).toEqual({ ip_address: '{{auto}}' });
1416

1517
expect(eventData[1].message).toBe('user');
@@ -20,6 +22,8 @@ sentryTest('should unset user', async ({ getLocalTestUrl, page }) => {
2022
});
2123

2224
expect(eventData[2].message).toBe('unset_user');
25+
26+
// because sendDefaultPii: true
2327
expect(eventData[2].user).toEqual({
2428
ip_address: '{{auto}}',
2529
});

Diff for: dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone-mixed-transaction/test.ts

-3
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ sentryTest(
103103
headers: expect.any(Object),
104104
url: expect.any(String),
105105
},
106-
user: {
107-
ip_address: '{{auto}}',
108-
},
109106
sdk: expect.any(Object),
110107
spans: [
111108
{

Diff for: dev-packages/browser-integration-tests/suites/public-api/withScope/init.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ window.Sentry = Sentry;
44

55
Sentry.init({
66
dsn: 'https://public@dsn.ingest.sentry.io/1337',
7+
sendDefaultPii: true,
78
});

Diff for: dev-packages/browser-integration-tests/suites/public-api/withScope/nested_scopes/test.ts

+19-5
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,36 @@ sentryTest('should allow nested scoping', async ({ getLocalTestUrl, page }) => {
1010
const eventData = await getMultipleSentryEnvelopeRequests<Event>(page, 5, { url });
1111

1212
expect(eventData[0].message).toBe('root_before');
13-
expect(eventData[0].user).toEqual({ id: 'qux', ip_address: '{{auto}}' });
13+
expect(eventData[0].user).toEqual({
14+
id: 'qux',
15+
ip_address: '{{auto}}', // because sendDefaultPii: true
16+
});
1417
expect(eventData[0].tags).toBeUndefined();
1518

1619
expect(eventData[1].message).toBe('outer_before');
17-
expect(eventData[1].user).toEqual({ id: 'qux', ip_address: '{{auto}}' });
20+
expect(eventData[1].user).toEqual({
21+
id: 'qux',
22+
ip_address: '{{auto}}', // because sendDefaultPii: true
23+
});
1824
expect(eventData[1].tags).toMatchObject({ foo: false });
1925

2026
expect(eventData[2].message).toBe('inner');
21-
expect(eventData[2].user).toEqual({ ip_address: '{{auto}}' });
27+
expect(eventData[2].user).toEqual({
28+
ip_address: '{{auto}}', // because sendDefaultPii: true
29+
});
2230
expect(eventData[2].tags).toMatchObject({ foo: false, bar: 10 });
2331

2432
expect(eventData[3].message).toBe('outer_after');
25-
expect(eventData[3].user).toEqual({ id: 'baz', ip_address: '{{auto}}' });
33+
expect(eventData[3].user).toEqual({
34+
id: 'baz',
35+
ip_address: '{{auto}}', // because sendDefaultPii: true
36+
});
2637
expect(eventData[3].tags).toMatchObject({ foo: false });
2738

2839
expect(eventData[4].message).toBe('root_after');
29-
expect(eventData[4].user).toEqual({ id: 'qux', ip_address: '{{auto}}' });
40+
expect(eventData[4].user).toEqual({
41+
id: 'qux',
42+
ip_address: '{{auto}}', // because sendDefaultPii: true
43+
});
3044
expect(eventData[4].tags).toBeUndefined();
3145
});

Diff for: dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts

-6
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ sentryTest('should capture replays (@sentry/browser export)', async ({ getLocalT
5555
'User-Agent': expect.stringContaining(''),
5656
},
5757
},
58-
user: {
59-
ip_address: '{{auto}}',
60-
},
6158
platform: 'javascript',
6259
});
6360

@@ -96,9 +93,6 @@ sentryTest('should capture replays (@sentry/browser export)', async ({ getLocalT
9693
'User-Agent': expect.stringContaining(''),
9794
},
9895
},
99-
user: {
100-
ip_address: '{{auto}}',
101-
},
10296
platform: 'javascript',
10397
});
10498
});

Diff for: dev-packages/browser-integration-tests/suites/replay/captureReplayFromReplayPackage/test.ts

-6
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ sentryTest('should capture replays (@sentry-internal/replay export)', async ({ g
5555
'User-Agent': expect.stringContaining(''),
5656
},
5757
},
58-
user: {
59-
ip_address: '{{auto}}',
60-
},
6158
platform: 'javascript',
6259
});
6360

@@ -96,9 +93,6 @@ sentryTest('should capture replays (@sentry-internal/replay export)', async ({ g
9693
'User-Agent': expect.stringContaining(''),
9794
},
9895
},
99-
user: {
100-
ip_address: '{{auto}}',
101-
},
10296
platform: 'javascript',
10397
});
10498
});

Diff for: dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-standalone-spans/test.ts

-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ sentryTest('captures a "GOOD" CLS vital with its source as a standalone span', a
6969
transaction: expect.stringContaining('index.html'),
7070
'user_agent.original': expect.stringContaining('Chrome'),
7171
'sentry.pageload.span_id': expect.stringMatching(/[a-f0-9]{16}/),
72-
'client.address': '{{auto}}',
7372
},
7473
description: expect.stringContaining('body > div#content > p'),
7574
exclusive_time: 0,
@@ -138,7 +137,6 @@ sentryTest('captures a "MEH" CLS vital with its source as a standalone span', as
138137
transaction: expect.stringContaining('index.html'),
139138
'user_agent.original': expect.stringContaining('Chrome'),
140139
'sentry.pageload.span_id': expect.stringMatching(/[a-f0-9]{16}/),
141-
'client.address': '{{auto}}',
142140
},
143141
description: expect.stringContaining('body > div#content > p'),
144142
exclusive_time: 0,
@@ -205,7 +203,6 @@ sentryTest('captures a "POOR" CLS vital with its source as a standalone span.',
205203
transaction: expect.stringContaining('index.html'),
206204
'user_agent.original': expect.stringContaining('Chrome'),
207205
'sentry.pageload.span_id': expect.stringMatching(/[a-f0-9]{16}/),
208-
'client.address': '{{auto}}',
209206
},
210207
description: expect.stringContaining('body > div#content > p'),
211208
exclusive_time: 0,
@@ -273,7 +270,6 @@ sentryTest(
273270
transaction: expect.stringContaining('index.html'),
274271
'user_agent.original': expect.stringContaining('Chrome'),
275272
'sentry.pageload.span_id': expect.stringMatching(/[a-f0-9]{16}/),
276-
'client.address': '{{auto}}',
277273
},
278274
description: 'Layout shift',
279275
exclusive_time: 0,

Diff for: dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-late/test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ sentryTest('should capture an INP click event span after pageload', async ({ bro
7171
'sentry.source': 'custom',
7272
transaction: 'test-url',
7373
'user_agent.original': expect.stringContaining('Chrome'),
74-
'client.address': '{{auto}}',
7574
},
7675
measurements: {
7776
inp: {

Diff for: dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-parametrized-late/test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ sentryTest(
7474
'sentry.source': 'custom',
7575
transaction: 'test-route',
7676
'user_agent.original': expect.stringContaining('Chrome'),
77-
'client.address': '{{auto}}',
7877
},
7978
measurements: {
8079
inp: {

Diff for: dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-parametrized/test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ sentryTest(
7070
'sentry.origin': 'auto.http.browser.inp',
7171
transaction: 'test-route',
7272
'user_agent.original': expect.stringContaining('Chrome'),
73-
'client.address': '{{auto}}',
7473
},
7574
measurements: {
7675
inp: {

Diff for: dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp/test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ sentryTest('should capture an INP click event span during pageload', async ({ br
6969
'sentry.origin': 'auto.http.browser.inp',
7070
transaction: 'test-url',
7171
'user_agent.original': expect.stringContaining('Chrome'),
72-
'client.address': '{{auto}}',
7372
},
7473
measurements: {
7574
inp: {

Diff for: dev-packages/browser-integration-tests/utils/replayEventTemplates.ts

-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ const DEFAULT_REPLAY_EVENT = {
3737
'User-Agent': expect.any(String),
3838
},
3939
},
40-
user: {
41-
ip_address: '{{auto}}',
42-
},
4340
platform: 'javascript',
4441
};
4542

Diff for: dev-packages/e2e-tests/test-applications/react-17/src/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Sentry.init({
3838
replaysOnErrorSampleRate: 0.0,
3939

4040
tunnel: 'http://localhost:3031',
41+
sendDefaultPii: true,
4142
});
4243

4344
const SentryRoutes = Sentry.withSentryReactRouterV6Routing(Routes);

Diff for: dev-packages/e2e-tests/test-applications/react-router-6/src/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Sentry.init({
4040
replaysOnErrorSampleRate: 0.0,
4141

4242
tunnel: 'http://localhost:3031',
43+
sendDefaultPii: true,
4344
});
4445

4546
const SentryRoutes = Sentry.withSentryReactRouterV6Routing(Routes);

Diff for: dev-packages/e2e-tests/test-applications/react-router-7-spa/src/main.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Sentry.init({
3939
replaysSessionSampleRate: 1.0,
4040
replaysOnErrorSampleRate: 0.0,
4141
tunnel: 'http://localhost:3031',
42+
sendDefaultPii: true,
4243
});
4344

4445
const SentryRoutes = Sentry.withSentryReactRouterV7Routing(Routes);

Diff for: docs/migration/v8-to-v9.md

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Older Typescript versions _may_ still work, but we will not test them anymore an
108108

109109
### `@sentry/browser`
110110

111+
- The SDK no longer instructs the Sentry backend to automatically infer IP addresses by default. This means that places where you previously saw IP addresses in Sentry may now be grouped to anonymous users. Set the `sendDefaultPii` option in `Sentry.init()` to true to instruct the Sentry backend to infer IP addresses.
111112
- The `captureUserFeedback` method has been removed. Use the `captureFeedback` method instead and update the `comments` field to `message`.
112113

113114
### `@sentry/nextjs`

0 commit comments

Comments
 (0)