-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add tracks assignment and exposure #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
📝 Documentation updates detected! New suggestion: Document FetchOptions for Python Experiment SDK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for FetchOptions to control assignment and exposure tracking behavior when fetching experiment variants. The main feature allows clients to specify whether to track assignment and exposure events via custom HTTP headers.
Key changes:
- Introduced a new
FetchOptionsclass withtracksAssignmentandtracksExposureparameters - Updated
fetch,fetch_v2, and related internal methods to accept and propagateFetchOptions - Modified the HTTP request headers to include
X-Amp-Exp-TrackandX-Amp-Exp-Exposure-Trackbased on options - Updated GitHub Actions workflows to use
actions/setup-python@v6
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/amplitude_experiment/remote/fetch_options.py | New class defining options for tracking assignment and exposure events |
| src/amplitude_experiment/remote/client.py | Updated fetch methods to accept and propagate FetchOptions, added header logic |
| tests/remote/client_test.py | Added test case for FetchOptions and updated existing test assertions |
| .github/workflows/*.yml | Bumped actions/setup-python from v3 to v6 |
Comments suppressed due to low confidence (2)
src/amplitude_experiment/remote/client.py:104
- The
__fetch_async_internalmethod doesn't passfetch_optionsto__fetch_internal, causingFetchOptionsto be ignored in async operations. Update line 104 to:variants = self.__fetch_internal(user, fetch_options)and add afetch_optionsparameter to__fetch_async_internal.
variants = self.__fetch_internal(user)
src/amplitude_experiment/remote/client.py:61
- The
fetch_async_v2method is missing afetch_optionsparameter, creating an inconsistency with the synchronousfetch_v2method. Addfetch_options: FetchOptions = Noneas a parameter and update the thread invocation on line 68 to include it.
def fetch_async_v2(self, user: User, callback=None):
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return {} | ||
|
|
||
| def __fetch_internal(self, user): | ||
| def __fetch_internal(self, user, fetch_options: FetchOptions = None): |
Copilot
AI
Oct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixing implicit and explicit returns may indicate an error, as implicit returns always return None.
Summary
Add track, or not to track, assignment and exposure events options to fetch requests.
Checklist