Skip to content

Conversation

@zhukaihan
Copy link
Collaborator

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

@promptless
Copy link

promptless bot commented Oct 27, 2025

📝 Documentation updates detected!

New suggestion: Document FetchOptions for PHP Experiment SDK
Updated existing suggestion: Document FetchOptions for Python Experiment SDK

@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 enhances the RemoteEvaluationClient to support additional fetch options for tracking assignments and exposures. The changes introduce a new FetchOptions class that encapsulates flag keys and tracking preferences, making the API more flexible and extensible.

  • Adds tracksAssignment and tracksExposure fields to FetchOptions for controlling tracking behavior
  • Refactors the fetch method to accept either an array of flag keys, a FetchOptions object, or null
  • Implements HTTP header handling (X-Amp-Exp-Track and X-Amp-Exp-Exposure-Track) based on tracking options

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Remote/FetchOptions.php Added tracksAssignment and tracksExposure properties with nullable bool types and default values
src/Remote/RemoteEvaluationClient.php Refactored fetch method to accept multiple argument types and extracted core logic to fetchWithOptions private method
tests/Remote/RemoteEvaluationClientTest.php Added comprehensive test coverage for various FetchOptions scenarios including tracking headers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if ($arg !== null && is_array($arg)) {
return $this->fetchWithOptions($user, new FetchOptions($arg, null, null));
}
if ($arg !== null && is_object($arg) && $arg instanceof FetchOptions) {
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.

The check is_object($arg) is redundant when followed by $arg instanceof FetchOptions. The instanceof operator already returns false for non-objects. Simplify line 131 to just if ($arg !== null && $arg instanceof FetchOptions).

Suggested change
if ($arg !== null && is_object($arg) && $arg instanceof FetchOptions) {
if ($arg !== null && $arg instanceof FetchOptions) {

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