Skip to content

feat: let platforms provide the installation ID - #2150

Merged
tustanivsky merged 8 commits into
masterfrom
feat/platform-installation-id
Oct 1, 2026
Merged

tustanivsky merged 8 commits into
masterfrom
feat/platform-installation-id

Conversation

@tustanivsky

@tustanivsky tustanivsky commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • New installation_id_func on sentry_integration_t. Integrations that don't set it are unaffected, since SENTRY_MAKE zero-initializes them.
  • sentry_init() resolves it before loading the ID, taking the first integration that returns one, and passes the result to sentry__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.
  • The integration must return a 36-character UUID string, of any version; anything else logs a warning and a random v4 is generated instead.
  • The file format (<uuid>\n<public_key>\n) and rotation on DSN change are untouched, and sentry_database.c needs no conditional compilation.

Related Items

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.
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 9f4e415

@tustanivsky
tustanivsky marked this pull request as ready for review October 1, 2026 07:59
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 51.42857% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.30%. Comparing base (8b67be0) to head (9f4e415).
⚠️ Report is 3 commits behind head on master.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/sentry_database.h Resolved
Comment thread src/sentry_database.c Resolved
@jpnurmi

jpnurmi commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Did you consider passing it as a normal option?

@tustanivsky

Copy link
Copy Markdown
Collaborator Author

Did you consider passing it as a normal option?

Do you mean via sentry_options_set_installation_id? That was my first approach but I then moved to the hook so the wiring doesn't have to be repeated in every integration whether that's downstream SDKs or "raw" sentry-native consumers.

@jpnurmi

jpnurmi commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

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.
@tustanivsky
tustanivsky marked this pull request as draft October 1, 2026 11:16

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/sentry_core.c Resolved
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.
@tustanivsky
tustanivsky marked this pull request as ready for review October 1, 2026 12:01
@tustanivsky

Copy link
Copy Markdown
Collaborator Author

Another idea: what if installation ID was part of the existing (platform) integration interface?

Right, this approach seems to be much cleaner + no additional cmake flags.

@jpnurmi jpnurmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍 with one cosmetic proposal to keep the run a.k.a. "self" argument.

Comment thread src/sentry_database.h Resolved
@tustanivsky
tustanivsky merged commit 3d564a0 into master Oct 1, 2026
107 of 109 checks passed
@tustanivsky
tustanivsky deleted the feat/platform-installation-id branch October 1, 2026 15:32
ric-oliv added a commit to getsentry/sentry-docs that referenced this pull request Nov 18, 2026
## 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+
Sign up for free to 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.

3 participants