Skip to content

add device id to feature flag context by default #867

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

msiebert
Copy link

@msiebert msiebert commented Jul 4, 2025

This pull request introduces support for a new device_id field (mapped to anonymousId) in the Mixpanel Feature Flag system. The changes ensure that device_id is properly handled in both the main application logic and the associated tests.

Feature enhancements:

Test updates:

  • src/androidTest/java/com/mixpanel/android/mpmetrics/FeatureFlagManagerTest.java:
    • Modified MockFeatureFlagDelegate to support anonymousIdToReturn. [1] [2]
    • Updated tests (testRequestBodyConstruction_performFetchRequest, testRequestBodyConstruction_withNullContext, testRequestBodyConstruction_withEmptyDistinctId, testFlagsConfigContextUsage_emptyContext) to verify the inclusion and correctness of the device_id field in the request context. [1] [2] [3] [4] [5]

@msiebert msiebert requested review from jaredmixpanel and Copilot July 4, 2025 00:42
@msiebert msiebert self-assigned this Jul 4, 2025
Copy link

@Copilot 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 the device’s anonymous ID to the feature-flag fetch request context by default.

  • Introduces getAnonymousId() in the FeatureFlagDelegate interface and uses it in FeatureFlagManager to populate a new device_id field in the request payload.
  • Updates tests in FeatureFlagManagerTest to verify device_id is present and correct in various scenarios.

Reviewed Changes

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

File Description
src/main/java/com/mixpanel/android/mpmetrics/FeatureFlagManager.java Retrieve anonymous ID and insert device_id into the fetch request JSON context.
src/main/java/com/mixpanel/android/mpmetrics/FeatureFlagDelegate.java Add new abstract getAnonymousId() method to the delegate interface.
src/androidTest/java/com/mixpanel/android/mpmetrics/FeatureFlagManagerTest.java Extend mock delegate and assertions to cover device_id presence and value.
Comments suppressed due to low confidence (1)

src/main/java/com/mixpanel/android/mpmetrics/FeatureFlagDelegate.java:12

  • Adding a new abstract method to the existing interface is a breaking change for all current implementers. Consider providing a default implementation (Java 8 interface default) or a shim to maintain backward compatibility.
    String getAnonymousId();

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.

1 participant