Repository navigation
feat: let platforms provide the installation ID - #2150
Conversation
Add the SENTRY_PLATFORM_INSTALLATION_ID build option. When enabled, the installation ID is taken from sentry__platform_installation_id() the first time it is persisted, instead of a generated UUIDv4, so platforms with a stable per-device-and-application identifier can keep the default user.id across losing the SDK database. The hook is only consulted when the ID is created, so a stored ID is never replaced, and it must return a 36-character UUID; anything else falls back to a random one.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2150 +/- ##
==========================================
- Coverage 75.36% 75.30% -0.07%
==========================================
Files 103 103
Lines 28025 28105 +80
Branches 5115 5133 +18
==========================================
+ Hits 21122 21164 +42
- Misses 5570 5602 +32
- Partials 1333 1339 +6 🚀 New features to boost your workflow:
|
|
Did you consider passing it as a normal option? |
Do you mean via |
|
Oh right, consoles have a different init structure/sequence. Another idea: what if installation ID was part of the existing (platform) integration interface? |
Replace the dedicated build option and hook symbol with an installation_id_func on sentry_integration_t. Integrations that don't set it are unaffected, since they are zero-initialized, and sentry_database.c no longer needs a conditional at all.
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.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f188909. Configure here.
Resolving the ID at the call site meant installation_id_func ran on every sentry_init, including when a stored ID was reused. Pass the options into sentry__run_load_installation_id and resolve lazily in the branch that creates the ID, as the contract describes.
Right, this approach seems to be much cleaner + no additional cmake flags. |
jpnurmi
left a comment
There was a problem hiding this comment.
LGTM 👍 with one cosmetic proposal to keep the run a.k.a. "self" argument.
## DESCRIBE YOUR PR The data collection spec doesn't say whether `userInfo` covers the installation ID that some SDKs generate and send as `user.id`, so SDKs have read it both ways. Java keeps the ID independent of `userInfo` in getsentry/sentry-java#5937, and Cocoa's v10 builds gate it in getsentry/sentry-cocoa#8415. .NET has to pick one in getsentry/sentry-dotnet#5932. This PR adds an "Installation Identifier" section that writes down what Java does: - `dataCollection` options don't gate the installation identifier. It identifies an installation, not a person. - SDKs should generate it at random. They may use an ID the platform provides and scopes to the app, like the console IDs getsentry/sentry-native#2150 allows. They must not use values that identify the device outside the app, like a MAC address or a host name. It also points the `userInfo` row, the "Disable User Identity" example and the technical context examples at the new section. The section adds requirements, so the spec moves to 0.18.0. Why Java's reading: - The spec suggests `userInfo: false` to roughly match `sendDefaultPii: false`, and `sendDefaultPii: false` always sent the installation ID. - Gating only `user.id` doesn't keep the ID on the device, because sessions send the same value as `did`. It would drop the "users affected" counts and protect very little. - Every SDK that has shipped already sends it. Only Cocoa's unreleased v10 builds gate it. I also considered gating it on `userInfo`, the way Cocoa v10 does. That would need a rule for the session `did` too, and it would change behavior in every shipped SDK. For the SDKs, Java already follows this, Cocoa would drop the `SDK_V10` gate before v10 ships, and .NET will follow up on its side. ## IS YOUR CHANGE URGENT? - [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD - [ ] Other deadline: YYYY-MM-DD - [x] No deadline: Not urgent, can wait up to 1 week+

This PR lets a platform integration supply the persisted installation ID that backs the default
user.id, instead of the randomly generated UUID. Platforms that expose a stable, pseudonymous per-device-and-application identifier can use it so the ID survives losing the SDK database.Key Changes
installation_id_funconsentry_integration_t. Integrations that don't set it are unaffected, sinceSENTRY_MAKEzero-initializes them.sentry_init()resolves it before loading the ID, taking the first integration that returns one, and passes the result tosentry__run_load_installation_id(). It is only consulted when the ID is first persisted, so an ID stored by an earlier run is never replaced.<uuid>\n<public_key>\n) and rotation on DSN change are untouched, andsentry_database.cneeds no conditional compilation.Related Items
user.id#1661