Skip to content

Bug 2088185 - Give RecordedContext the client's enrollment state - #7777

Draft
yashikakhurana wants to merge 3 commits into
mainfrom
17762
Draft

yashikakhurana wants to merge 3 commits into
mainfrom
17762

Conversation

@yashikakhurana

@yashikakhurana yashikakhurana commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Desktop records which experiments the client is enrolled in. Mobile can't, because the SDK never gives the app's recorded context that information. This lets population sizing handle targeting that depends on enrollment on Fenix and iOS.

This adds set_enrollment_state to RecordedContext. The SDK calls it just before record(), passing active_experiments, enrollments and enrollments_map. is_already_enrolled is left out because it only applies while one experiment is being evaluated.

The SDK also drops these keys from whatever to_json returns, so an app can never override the real values used for targeting.

Breaking change

Every RecordedContext implementer must add the method. This is a draft until the consumer PRs are ready:

  • Fenix: add the fields to metrics.yaml and record them in RecordedNimbusContext.kt
  • Firefox iOS: record them in RecordedNimbusContext.swift

Testing

  • New tests for the hand-over and for the override guard. Both fail if the behaviour is removed.
  • cargo test -p nimbus-sdk, rustfmt and clippy pass.
  • I haven't built the Kotlin test change locally, so I'm relying on CI for it.

Pull Request checklist

  • Breaking changes: this is a breaking change, and the consumer PRs are still to come.
    • This PR follows the breaking change policy
  • Quality: builds and tests run cleanly
  • Tests: includes tests, described above
  • Changelog: entry added under Breaking Changes, Nimbus SDK
  • Dependencies: none added

Desktop records which experiments the client is enrolled in, but mobile
could not: the SDK knows the enrollment state, yet the recorded context
only ever received event query results, so the apps had nothing to record.

Add set_enrollment_state to RecordedContext, with a RecordedEnrollmentState
carrying active_experiments, enrollments and enrollments_map. The SDK calls
it just before record(), alongside the existing event query hand-over.
is_already_enrolled is left out: it is only meaningful while one experiment
is being evaluated, so it has no single value to record.

These keys also feed targeting, so drop them from whatever to_json returns
before it is stored, and a recorded copy can never shadow the real values.

This is a breaking change for every implementer of RecordedContext, in the
same way adding the event query methods was.

This branch has not been deployed

No deployments
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.

1 participant