Skip to content

Comments

fix: Ensure user.ip_address defaults to auto with send_default_pii on#392

Merged
limbonaut merged 13 commits intomainfrom
fix/user-pii
Sep 29, 2025
Merged

fix: Ensure user.ip_address defaults to auto with send_default_pii on#392
limbonaut merged 13 commits intomainfrom
fix/user-pii

Conversation

@limbonaut
Copy link
Collaborator

@limbonaut limbonaut commented Sep 26, 2025

This PR ensures that ip_address is set to {{auto}} when send_default_pii is enabled, and removes get_user() from API since it is unavailable in Native and Android, and probably not needed, and its previous caching-based implementation was prone to stale data issues.


Note

Auto-creates a default user (with ip_address={{auto}} when send_default_pii is enabled), removes SentrySDK.get_user(), and updates SDK init flow/signatures accordingly.

  • Breaking changes:
    • Remove SentrySDK.get_user() from API and docs.
    • Change InternalSDK.init(...) signature to drop the SentryUser parameter; update Android/Cocoa/Native/Disabled implementations.
  • User handling:
    • Add SentryUser.create_default() to generate installation-based id and set ip_address to {{auto}} when send_default_pii is true.
    • Initialize default user on SDK startup across platforms; remove previous cached user logic in SentrySDK and related mutex usage.
  • Docs:
    • Update doc_classes/SentrySDK.xml (remove get_user) and doc_classes/SentryUser.xml (document create_default).
    • Update CHANGELOG.md with breaking change and behavior note.
  • Tests:
    • Add isolated tests for PII enabled/disabled ensuring user.ip_address presence/absence.
    • Refactor user tests to avoid get_user(), validate property behaviors, default user persistence, and ID generation.

Written by Cursor Bugbot for commit f211a42. This will update automatically on new commits. Configure here.

@limbonaut limbonaut added the Bug Something isn't working label Sep 26, 2025
@limbonaut limbonaut marked this pull request as ready for review September 26, 2025 19:14
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@jpnurmi
Copy link
Collaborator

jpnurmi commented Sep 29, 2025

Instead of inferring the IP address at startup, would it help to conditionally fill it in at the time of capturing events?

https://github.com/getsentry/sentry-dotnet/blob/fc55d48911df3b181767f9c3093c9fd556edc356/src/Sentry/Internal/Enricher.cs#L84-L94

@limbonaut
Copy link
Collaborator Author

That would mean we have to expose the user interface on the event object for each platform, so we could manipulate it inside a processor, which is way more involved. I'm not sure if it's the right way to do it either. If a dev sets a user without IP inference, do they want IP not inferred or did they forget to do it? Is it our job to guess based solely on send_default_pii value? I mean, technically, we'd be overriding user-applied value.

@bruno-garcia wdyt?

Copy link
Contributor

@vaind vaind left a comment

Choose a reason for hiding this comment

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

LGTM as is. I don't think there's any benefit delaying setting the user in the event handler.

@limbonaut limbonaut merged commit d092922 into main Sep 29, 2025
124 of 126 checks passed
@limbonaut limbonaut deleted the fix/user-pii branch September 29, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants