Repository navigation
feat: tag OpenFeature exposures with $openfeature_provider (SDK-448) - #181
ketanmixpanel wants to merge 2 commits into
Conversation
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>
[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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rahul-mixpanel
left a comment
There was a problem hiding this comment.
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{}. Nodistinct_idmeans 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.
Summary
SDK-448:
$experiment_startedexposures 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
"$openfeature_provider": trueto the evaluation context it already passes togetVariant, set after the customer attributes so a same-named attribute cannot override it.distinct_id) copies the marker onto$experiment_startedwhen the context value is exactlytrue. Covers local and remote evaluation.distinct_idandcustom_properties.Testing
get_variantincludes the marker, including when the evaluation context is nil; a customer attribute$openfeature_provider => falsecannot 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
/flagswith the rest of the context. The flags API accepts and ignores it (checked inanalytics/go/src/mixpanel.com/flags/api/handlers/evaluatefeatureflags.go):distinct_idanddevice_id;distinct_id/device_id,custom_propertiesand hierarchical group IDs;logRequestdoes not log it.So it has no effect on targeting, rollout or variant assignment; it is only visible in the GET
contextquery 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