feat: enrich events by auto-populating user.id#1661
Open
Conversation
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2af7ee3. Configure here.
Generate a stable per-installation UUID and use it as the default `user.id` when the SDK user has no explicit id set. The UUID is persisted in `<db>/installation_id` alongside the DSN public key so that changing DSNs rotates the id, and is stamped onto events at scope-apply time without mutating the user-provided scope. Close: #1324 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Initialize scope->user to an empty object so the null state is reserved for explicit sentry_remove_user(). At event apply, skip user enrichment entirely when scope->user is null (removed). Guard the two sites that previously fell through on is_null(scope->user) against leaking an empty object into events / crash-recovery payloads. Use installation_id as the session distinct_id fallback when user has no explicit id. Drops the previous email/username fallback chain to align with sentry-java/sentry-cocoa and the session spec requirement that did be stable for the session lifetime. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Centralize the "user.id or installation_id" resolution so both the event and session call sites share the same helper. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The helper mutated its user argument, which leaked out through sentry_set_user (caller's value) and sentry__session_sync_user (scope->user). Revert the helper and inline both sites again. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
52ce9c5 to
f2c34a3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Generate a stable per-installation UUID and use it as the default
user.idwhen the SDK user has no explicit ID set. The UUID is persisted in<db>/installation_idalongside the DSN public key so that changing DSNs rotates the ID, and is stamped onto events at scope-apply time without mutating the user-provided scope.Sentry uses
user.idto compute the number of users impacted by an issue (distinct from event counts); this gives developers that metric out of the box. DSN scoping keeps it privacy-conscious — the ID is not a stable identity across installations. Matchessentry-android,sentry-cocoa, andsentry-dotnet.Note:
sentry_value_new_user[_n]now preserves an explicit empty-stringidinstead of dropping it; onlyNULLskips the field. This lets the new auto-ID enrichment distinguish "no ID set" vs. "ID explicitly empty".Close: #1324