Skip to content

Conversation

@zhukaihan
Copy link
Collaborator

Summary

Add track, or not to track, assignment and exposure events options to fetch requests.

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: no

@promptless
Copy link

promptless bot commented Oct 27, 2025

@zhukaihan zhukaihan requested review from a team and Copilot October 30, 2025 09:12
Copy link

Copilot AI left a 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 FetchOptions class with tracksAssignment and tracksExposure parameters
  • Updated fetch, fetch_v2, and related internal methods to accept and propagate FetchOptions
  • Modified the HTTP request headers to include X-Amp-Exp-Track and X-Amp-Exp-Exposure-Track based 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_internal method doesn't pass fetch_options to __fetch_internal, causing FetchOptions to be ignored in async operations. Update line 104 to: variants = self.__fetch_internal(user, fetch_options) and add a fetch_options parameter to __fetch_async_internal.
            variants = self.__fetch_internal(user)

src/amplitude_experiment/remote/client.py:61

  • The fetch_async_v2 method is missing a fetch_options parameter, creating an inconsistency with the synchronous fetch_v2 method. Add fetch_options: FetchOptions = None as 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):
Copy link

Copilot AI Oct 30, 2025

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.

Copilot uses AI. Check for mistakes.
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