Skip to content

fix(browser): Ensure IP address is only inferred by Relay if sendDefaultPii is true - #17364

Merged
Lms24 merged 9 commits into
developfrom
lms/fix-browser-sdk-settings-infer_ip
Aug 11, 2025
Merged

fix(browser): Ensure IP address is only inferred by Relay if sendDefaultPii is true#17364
Lms24 merged 9 commits into
developfrom
lms/fix-browser-sdk-settings-infer_ip

Conversation

@Lms24

@Lms24Lms24 commented Aug 8, 2025

Copy link
Copy Markdown
Member

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 taken care of in this PR.

(FWIW, the only reason why Relay continued to infer IP addresses for the JS SDK was because it is excempt from logic that would infer IP addresses only if user.ip_address was set to '{{auto}}'. This is necessary to backwards compatibility with older SDKs.)

Follow-ups: We likely also need to adjust the logic in Electron and Lynx (at the very least remove setting user.ip_address).

closes#17351
closes#16252

@Lms24
Lms24 requested a review from a team as a code ownerAugust 8, 2025 15:01
cursor[bot]

This comment was marked as outdated.

@Lms24Lms24 self-assigned this Aug 8, 2025
@github-actions

github-actionsBot commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser24.16 kB+0.2%+46 B 🔺
@sentry/browser - with treeshaking flags22.73 kB+0.23%+52 B 🔺
@sentry/browser (incl. Tracing)39.87 kB+0.12%+44 B 🔺
@sentry/browser (incl. Tracing, Replay)77.99 kB+0.09%+69 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags67.83 kB+0.1%+62 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas)82.69 kB+0.08%+61 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback)94.79 kB+0.07%+64 B 🔺
@sentry/browser (incl. Feedback)40.83 kB+0.15%+61 B 🔺
@sentry/browser (incl. sendFeedback)28.81 kB+0.13%+36 B 🔺
@sentry/browser (incl. FeedbackAsync)33.7 kB+0.14%+46 B 🔺
@sentry/react25.88 kB+0.19%+49 B 🔺
@sentry/react (incl. Tracing)41.86 kB+0.15%+62 B 🔺
@sentry/vue28.64 kB+0.2%+55 B 🔺
@sentry/vue (incl. Tracing)41.69 kB+0.13%+52 B 🔺
@sentry/svelte24.18 kB+0.19%+44 B 🔺
CDN Bundle25.66 kB+0.18%+46 B 🔺
CDN Bundle (incl. Tracing)39.76 kB+0.1%+39 B 🔺
CDN Bundle (incl. Tracing, Replay)75.82 kB+0.08%+54 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback)81.27 kB+0.1%+81 B 🔺
CDN Bundle - uncompressed74.96 kB+0.1%+70 B 🔺
CDN Bundle (incl. Tracing) - uncompressed117.59 kB+0.06%+70 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed231.88 kB+0.04%+92 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed244.48 kB+0.04%+92 B 🔺
@sentry/nextjs (client)43.89 kB+0.14%+57 B 🔺
@sentry/sveltekit (client)40.32 kB+0.13%+51 B 🔺
@sentry/node-core47.8 kB+0.06%+25 B 🔺
@sentry/node146.68 kB+0.02%+21 B 🔺
@sentry/node - without tracing91.9 kB+0.03%+24 B 🔺
@sentry/aws-serverless103.33 kB+0.03%+23 B 🔺

View base workflow run

@Lms24
Lms24 requested review from cleptric and mydeaAugust 8, 2025 15:36
Comment threadpackages/core/src/types-hoist/sdkinfo.ts Outdated
Comment threadpackages/core/src/utils/sdkMetadata.ts Outdated
cursor[bot]

This comment was marked as outdated.

export { parameterize, fmt } from './utils/parameterize';
export { addAutoIpAddressToSession, addAutoIpAddressToUser } from './utils/ipAddress';

export { addAutoIpAddressToSession } from './utils/ipAddress';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we leave this on purpose iun-deprecated - is this still needed?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for now, let's leave it undeprecated. Checked with @cleptric and @Dav1dde and there are no PII-related concerns. The reason being that there's no special-casing Relay-side for JS that in the absence of '{{auto}}' IP addresses are still inferred.

Comment threadCHANGELOG.md
However, after updating the SDK, events (errors, traces, replays, etc.) sent from the browser, will only include
user IP addresses, if you set `sendDefaultPii: true` in your `Sentry.init` options.

We apologize for any inconvenience caused!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great changelog message ❤️

cursor[bot]

This comment was marked as outdated.

@Lms24
Lms24 merged commit 508afcc into developAug 11, 2025
187 checks passed
@Lms24
Lms24 deleted the lms/fix-browser-sdk-settings-infer_ip branch August 11, 2025 09:22
Lms24 added a commit to getsentry/sentry-docs that referenced this pull request Aug 12, 2025
…tion guide (#14609)
Mentions a fix to be introduced in
[10.4.0](getsentry/sentry-javascript#17364) in
the migration guide given it has quite a lot of impact, albeit belated
(should have been like this since v9).
This change is now mentioned in:
- 10.4.0 changelog
- in-repo migration guide
- in-docs migration guide (this PR)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React sentry events contains user's IP address by default Use settings.infer_ip instead of ip_address: {{auto}}

3 participants

@Lms24@mydea@cleptric