Skip to content

Commit 508afcc

Browse files
authored
fix(browser): Ensure IP address is only inferred by Relay if sendDefaultPii is true (#17364)
This PR fixes a long-standing problem in the SDK where it would set incorrect information about when Relay should (not) infer IP addresses from sent envelope requests. Previously, this was thought to be controlled by setting `event.user.ip_address: '{{auto}}'`. However, after an incident in Relay, it was determined that this is in fact not a reliably way to control IP inference. Instead, SDKs should set `event.sdk.settings.infer_ip: 'auto' | 'never'` (see closes #16252). Unfortunately, this wasn't implemented immediately but is now taken care of in this PR.
1 parent 64d1f6a commit 508afcc

File tree

35 files changed

+388
-38
lines changed

35 files changed

+388
-38
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
## Unreleased
8+
9+
### Important Changes
10+
11+
- **fix(browser): Ensure IP address is only inferred by Relay if `sendDefaultPii` is `true`**
12+
13+
This release includes a fix for a [behaviour change](https://docs.sentry.io/platforms/javascript/migration/v8-to-v9/#behavior-changes)
14+
that was originally introduced with v9 of the SDK: User IP Addresses should only be added to Sentry events automatically,
15+
if `sendDefaultPii` was set to `true`.
16+
17+
However, the change in v9 required further internal adjustment, which should have been included in v10 of the SDK.
18+
Unfortunately, the change did not make it into the initial v10 version but is now applied with `10.4.0`.
19+
There is _no API_ breakage involved and hence it is safe to update.
20+
However, after updating the SDK, events (errors, traces, replays, etc.) sent from the browser, will only include
21+
user IP addresses, if you set `sendDefaultPii: true` in your `Sentry.init` options.
22+
23+
We apologize for any inconvenience caused!
24+
725
## 10.3.0
826

927
- feat(core): MCP Server - Capture prompt results from prompt function calls (#17284)

MIGRATION.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ The removal entails **no breaking API changes**. However, in rare cases, you mig
8080
- If you set up Sentry Alerts that depend on FID, be aware that these could trigger once you upgrade the SDK, due to a lack of new values.
8181
To replace them, adjust your alerts (or dashbaords) to use INP.
8282

83+
### Update: User IP Address collection gated by `sendDefaultPii`
84+
85+
Version `10.4.0` introduced a change that should have ideally been introduced with `10.0.0` of the SDK.
86+
Originally destined for [version `9.0.0`](https://docs.sentry.io/platforms/javascript/migration/v8-to-v9/#behavior-changes), but having not the desired effect until v10,
87+
SDKs will now control IP address inference of user IP addresses depending on the value of the top level `sendDefaultPii` init option.
88+
89+
- If `sendDefaultPii` is `true`, Sentry will infer the IP address of users' devices to events (errors, traces, replays, etc) in all browser-based SDKs.
90+
- If `sendDefaultPii` is `false` or not set, Sentry will not infer or collect IP address data.
91+
92+
Given that this was already the advertised behaviour since v9, we classify the change [as a fix](https://github.com/getsentry/sentry-javascript/pull/17364),
93+
though we recognize the potential impact of it. We apologize for any inconvenience caused.
94+
8395
## No Version Support Timeline
8496

8597
Version support timelines are stressful for everybody using the SDK, so we won't be defining one.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ sentryTest('should capture feedback with custom button', async ({ getLocalTestUr
6161
version: expect.any(String),
6262
name: 'sentry.javascript.browser',
6363
packages: expect.anything(),
64+
settings: {
65+
infer_ip: 'never',
66+
},
6467
},
6568
request: {
6669
url: `${TEST_HOST}/index.html`,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
6161
version: expect.any(String),
6262
name: 'sentry.javascript.browser',
6363
packages: expect.anything(),
64+
settings: {
65+
infer_ip: 'never',
66+
},
6467
},
6568
request: {
6669
url: `${TEST_HOST}/index.html`,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ sentryTest('should capture feedback', async ({ forceFlushReplay, getLocalTestUrl
9595
version: expect.any(String),
9696
name: 'sentry.javascript.browser',
9797
packages: expect.anything(),
98+
settings: {
99+
infer_ip: 'never',
100+
},
98101
},
99102
request: {
100103
url: `${TEST_HOST}/index.html`,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
6161
version: expect.any(String),
6262
name: 'sentry.javascript.browser',
6363
packages: expect.anything(),
64+
settings: {
65+
infer_ip: 'never',
66+
},
6467
},
6568
request: {
6669
url: `${TEST_HOST}/index.html`,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ sentryTest('allows to setup a client manually & capture exceptions', async ({ ge
4141
name: 'sentry.javascript.browser',
4242
version: expect.any(String),
4343
packages: [{ name: expect.any(String), version: expect.any(String) }],
44+
settings: {
45+
infer_ip: 'never',
46+
},
4447
},
4548
contexts: {
4649
trace: { trace_id: expect.stringMatching(/[a-f0-9]{32}/), span_id: expect.stringMatching(/[a-f0-9]{16}/) },

dev-packages/browser-integration-tests/suites/public-api/captureException/simpleError/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ sentryTest('should capture correct SDK metadata', async ({ getLocalTestUrl, page
3939
version: SDK_VERSION,
4040
},
4141
],
42+
settings: {
43+
infer_ip: 'never',
44+
},
4245
});
4346
});
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { expect } from '@playwright/test';
2-
import type { Event } from '@sentry/core';
32
import { sentryTest } from '../../../../utils/fixtures';
4-
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
3+
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
54

6-
sentryTest('should default user to {{auto}} on errors when sendDefaultPii: true', async ({ getLocalTestUrl, page }) => {
7-
const url = await getLocalTestUrl({ testDir: __dirname });
8-
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
9-
expect(eventData.user?.ip_address).toBe('{{auto}}');
10-
});
5+
sentryTest(
6+
'sets sdk.settings.infer_ip to "auto" on errors when sendDefaultPii: true',
7+
async ({ getLocalTestUrl, page }) => {
8+
const url = await getLocalTestUrl({ testDir: __dirname });
9+
const eventData = await envelopeRequestParser(await waitForErrorRequestOnUrl(page, url));
10+
expect(eventData.sdk?.settings?.infer_ip).toBe('auto');
11+
},
12+
);

dev-packages/browser-integration-tests/suites/public-api/sendDefaultPii/performance/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '../../../../utils/helpers';
88

99
sentryTest(
10-
'should default user to {{auto}} on transactions when sendDefaultPii: true',
10+
'sets user.ip_address to "auto" on transactions when sendDefaultPii: true',
1111
async ({ getLocalTestUrl, page }) => {
1212
if (shouldSkipTracingTest()) {
1313
sentryTest.skip();
@@ -16,6 +16,6 @@ sentryTest(
1616
const url = await getLocalTestUrl({ testDir: __dirname });
1717
const req = await waitForTransactionRequestOnUrl(page, url);
1818
const transaction = envelopeRequestParser(req);
19-
expect(transaction.user?.ip_address).toBe('{{auto}}');
19+
expect(transaction.sdk?.settings?.infer_ip).toBe('auto');
2020
},
2121
);

0 commit comments

Comments
 (0)