feat: support flagKeys param for remote evaluations#76
Open
svihang8 wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for flagKeys param to fetch_v2() to allow emitting exposure events for designated flagKeys, in line with implementation matching core amplitude experiment sdk reference
Checklist
Hello team. Recently we ran into an issue where when setting
fetch_v2(trackExposure=True), this would cause firing exposure events for all our experiments in a deployment. The workaround fix for this is to call the v1 Experiment Evaluation API directly ; reference that allows settingflag_keysexplicitly to prevent firing exposure events for all keys in a deployment. From my understanding, this is supported in the node.js sdk and the core experiment sdk, so we should support it in the python sdk as well.Cheers! 🥳
Note
Low Risk
Small, backward-compatible optional parameter and request header with test coverage; no auth or data-model changes.
Overview
Adds optional
flagKeysonFetchOptionssofetch_v2()can ask the evaluation API to focus on specific flags (aligned with other Experiment SDKs).When
flagKeysis a non-empty list,RemoteEvaluationClientsetsX-Amp-Exp-Flag-Keysto a URL-safe base64 encoding of the JSON array (padding stripped). An empty list omits the header, matching existing behavior for assignment/exposure tracking options.Unit tests assert the header value for sample keys and that
flagKeys=[]does not add the header.Reviewed by Cursor Bugbot for commit 2654122. Bugbot is set up for automated code reviews on this repo. Configure here.