Skip to content

feat: tag OpenFeature exposures with $openfeature_provider (SDK-448) - #181

Open
ketanmixpanel wants to merge 2 commits into
masterfrom
ketanshikhare-sdk-448-openfeature-provider-marker
Open

ketanmixpanel wants to merge 2 commits into
masterfrom
ketanshikhare-sdk-448-openfeature-provider-marker

Conversation

@ketanmixpanel

Copy link
Copy Markdown

Summary

SDK-448: $experiment_started exposures fired through the Mixpanel OpenFeature provider now include "$openfeature_provider": true, so OpenFeature usage can be told apart from direct SDK flag calls. Direct SDK calls are unchanged (no property).

No public API change: no new public methods, parameters or fields. The provider signals the SDK through an argument it already passes on every evaluation.

How

  • Provider: adds "$openfeature_provider": true to the evaluation context it already passes to getVariant, set after the customer attributes so a same-named attribute cannot override it.
  • SDK: the exposure-tracking code (which already receives the context to read distinct_id) copies the marker onto $experiment_started when the context value is exactly true. Covers local and remote evaluation.
  • Local evaluation is unaffected: it only reads the flag assignment key, distinct_id and custom_properties.

Testing

  • New SDK specs (local and remote): marker present tags the exposure (string or symbol key); absent does not.
  • Provider specs: context passed to get_variant includes the marker, including when the evaluation context is nil; a customer attribute $openfeature_provider => false cannot override it. New specs assert the result too, so the provider rescue cannot hide a failing stub.
  • bundle exec rspec (SDK): 412 examples, 0 failures, 2 pending (pre-existing).
  • bundle exec rspec (provider): 64 examples, 0 failures, 100% line coverage.

Note: marker is sent to the server on remote evaluation

Because the marker lives in the evaluation context, remote evaluation sends it to /flags with the rest of the context. The flags API accepts and ignores it (checked in analytics/go/src/mixpanel.com/flags/api/handlers/evaluatefeatureflags.go):

  • request validation only type-checks distinct_id and device_id;
  • evaluation only reads the assignment key, distinct_id/device_id, custom_properties and hierarchical group IDs;
  • logRequest does not log it.

So it has no effect on targeting, rollout or variant assignment; it is only visible in the GET context query parameter.

Release order

Older SDKs ignore the marker, so the provider change is safe on its own (no errors; the property just does not appear). The property appears once customers run an SDK release containing this change; the provider minimum SDK version was intentionally not bumped here and should be raised after the SDK release. No version or changelog edits.

🤖 Generated with Claude Code

Exposures fired through the Mixpanel OpenFeature provider now include
"$openfeature_provider": true so they can be told apart from direct SDK
flag calls. Direct SDK calls are unchanged. No public API change: the
provider signals the SDK through an argument it already passes on every
evaluation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Nov 12, 2026

Copy link
Copy Markdown

SDK-448

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Reviews (2) · Last reviewed commit: "Merge branch 'master' into ketanshikhare..." · Reviewed by Greptile

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.42%. Comparing base (3fdee83) to head (cdc0d44).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #181   +/-   ##
=======================================
  Coverage   97.41%   97.42%           
=======================================
  Files          16       16           
  Lines         889      892    +3     
=======================================
+ Hits          866      869    +3     
  Misses         23       23           
Flag Coverage Δ
openfeature 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ketanmixpanel
ketanmixpanel marked this pull request as ready for review November 13, 2026 08:54
@ketanmixpanel
ketanmixpanel requested review from a team and tylerjroach November 13, 2026 08:54

@rahul-mixpanel rahul-mixpanel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed against the SDK-448 design. Looks good: build_context sets the marker last so customer attributes can't override it (tested), and track_exposure_event is the single exposure path for local and remote. Local targeting is unaffected (runtime rules read custom_properties); remote sends the marker in context, which the server ignores.

  • Note: accepting both string and symbol keys goes slightly beyond "exactly that key", but it's idiomatic Ruby and tested. Fine.
  • Behaviour change (fine): a nil evaluation context now yields {'$openfeature_provider' => true} instead of {}. No distinct_id means no exposure.
  • Release order: the gemspec doesn't pin the SDK version, so the new SDK is picked up automatically.

Cross-SDK notes:

  • Dedup trade-off: in apps using both direct calls and the provider, the marker undercounts provider exposures (whichever path evaluates a flag first after a fetch wins). Worth recording on SDK-448 / in docs for whoever analyses this property, not only in the PR body.
  • Testing: provider tests mock the SDK; the real provider ↔ SDK contract was only verified manually. An end-to-end test would protect it.

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.

2 participants