-
Notifications
You must be signed in to change notification settings - Fork 39
add support for feature flags #46
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
Conversation
e416a83 to
96a7979
Compare
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 comprehensive feature flags support to the Mixpanel Java SDK, introducing both local and remote evaluation modes. Local evaluation provides fast, low-latency flag checks by polling flag definitions from the API and evaluating them client-side using deterministic hashing. Remote evaluation makes real-time API calls for each flag check.
Key changes:
- Complete feature flags implementation with local and remote evaluation modes
- FNV-1a hash-based variant selection algorithm for consistent user assignment
- Background polling mechanism for automatic flag definition synchronization
- Comprehensive test coverage for both evaluation modes
Reviewed Changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| MixpanelAPI.java | Integrated feature flags support with new constructors accepting LocalFlagsConfig/RemoteFlagsConfig |
| MixpanelFlagsClient.java | Main client coordinating local/remote providers and exposure tracking |
| LocalFlagsProvider.java | Implements local evaluation with polling and hash-based variant selection |
| RemoteFlagsProvider.java | Implements remote evaluation via API calls |
| BaseFlagsProvider.java | Base class providing shared HTTP functionality and evaluation helpers |
| HashUtils.java | FNV-1a hashing implementation for deterministic variant assignment |
| Model classes | Data structures for flags, variants, rollouts, and evaluation results |
| Config classes | Configuration builders for local and remote evaluation modes |
| Test files | Comprehensive unit tests for all providers and utility classes |
| Demo files | Example code demonstrating local and remote evaluation usage |
| README.md | Updated documentation with feature flags usage examples |
| pom.xml | Version bump and resource filtering configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } | ||
|
|
||
| @Test | ||
| public void testIsQaTesterFalseWhenUserGoesthroughNormalRollout() { |
Copilot
AI
Oct 23, 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.
Corrected spelling of 'Goesthrough' to 'GoesThrough' in test method name.
| public void testIsQaTesterFalseWhenUserGoesthroughNormalRollout() { | |
| public void testIsQaTesterFalseWhenUserGoesThroughNormalRollout() { |
| * @param localFlagsConfig configuration for local feature flags evaluation | ||
| */ | ||
| public MixpanelAPI(LocalFlagsConfig localFlagsConfig) { | ||
| mEventsEndpoint = Config.BASE_ENDPOINT + "/track"; |
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.
Can this be simplified by invoking the MixpanelAPI(boolean useGzipCompression) after setting the flags client
| * The EventSender uses the provided MixpanelAPI instance for sending events. | ||
| */ | ||
| private static MixpanelFlagsClient createFlagsClient(LocalFlagsConfig config, MixpanelAPI api) { | ||
| final MessageBuilder builder = new MessageBuilder(config.getProjectToken()); |
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.
Can we use this once & genericize the config passed to it
| * @param localFlagsConfig configuration for local evaluation | ||
| * @param eventSender the EventSender implementation for tracking exposure events | ||
| */ | ||
| public MixpanelFlagsClient(LocalFlagsConfig localFlagsConfig, EventSender eventSender) { |
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.
Given the form of this class, consider splitting the common behavior into an abstract flags client. Or maybe this can just go into the base/local/remote flagsproviders directly. Might not need another layer of indirection here
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.
I'd drop the '-flags' from the version in the pom file. Kind of non-standard for semantic versioning
@efahk I'd done this as sort of a nod to the idea we'd talked about where we wanted it to be beta. Should I just throw a |
82020b0 to
57b8a6a
Compare
API looks like:
GitHub Copilot Summary
This pull request introduces feature flag support to the Mixpanel Java SDK, providing both local and remote evaluation modes. It updates the documentation to describe these new capabilities, adds demo examples, and modifies the main
MixpanelAPIclass to support feature flags configuration. The version is bumped to1.6.0-flags, and build resources are updated to support new features.Feature Flags Support:
Added local and remote feature flag evaluation support to the SDK, allowing users to check feature flags and variants either via background polling (local) or real-time API calls (remote). This includes new constructors and internal logic in
MixpanelAPIto handle feature flag clients. [1] [2] [3] [4] [5] [6] [7]Added two demo files,
LocalEvaluationExample.javaandRemoteEvaluationExample.java, to demonstrate usage of both local and remote feature flag evaluation. [1] [2]Documentation Updates:
README.mdto document the new feature flags support, including usage examples for both local and remote evaluation, and reorganized sections for clarity. [1] [2] [3] [4] [5] [6]Build and Versioning:
1.6.0-flagsinpom.xmlto reflect the new feature flag functionality.pom.xmlto include filtering and resource management for.propertiesfiles.