Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a comprehensive feature flag system to the Mixpanel Ruby SDK, enabling both local (client-side) and remote (server-side) flag evaluation. The implementation provides a complete solution with core providers, utility functions for variant assignment, exposure event tracking, and example usage demonstrations.
- Implements local and remote feature flag evaluation providers with polling support and runtime rule evaluation
- Adds utility functions for consistent hashing and variant assignment using FNV-1a algorithm
- Integrates feature flags into the main Tracker class with configurable initialization
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
lib/mixpanel-ruby/flags/flags_provider.rb |
Base class providing HTTP communication and exposure event tracking for flag providers |
lib/mixpanel-ruby/flags/local_flags_provider.rb |
Local evaluation provider with polling, rollout logic, and JSON-based runtime rules |
lib/mixpanel-ruby/flags/remote_flags_provider.rb |
Remote evaluation provider that fetches variant assignments via API calls |
lib/mixpanel-ruby/flags/utils.rb |
Utility functions for hashing, query parameters, and distributed tracing headers |
lib/mixpanel-ruby/flags/types.rb |
SelectedVariant class to represent flag evaluation results |
lib/mixpanel-ruby/tracker.rb |
Integrates local and remote flags providers into the main Tracker class |
lib/mixpanel-ruby.rb |
Adds require statements for all new flags modules |
mixpanel-ruby.gemspec |
Updates minimum Ruby version to 3.0.0 and adds json-logic-rb dependency |
lib/mixpanel-ruby/version.rb |
Bumps version to 2.4.0-beta |
spec/mixpanel-ruby/flags/utils_spec.rb |
Comprehensive tests for utility functions including hash consistency and edge cases |
spec/mixpanel-ruby/flags/local_flags_spec.rb |
Extensive tests for local provider including rollout, runtime rules, and polling |
spec/mixpanel-ruby/flags/remote_flags_spec.rb |
Tests for remote provider covering API interactions and exposure tracking |
demo/flags/local_flags.rb |
Example script demonstrating local flag evaluation usage |
demo/flags/remote_flags.rb |
Example script demonstrating remote flag evaluation usage |
.github/workflows/ruby.yml |
Removes Ruby 2.3-2.7 from CI matrix, focusing on Ruby 3.x |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - '2.5' | ||
| - '2.6' | ||
| - '2.7' | ||
| - '3.0' |
There was a problem hiding this comment.
didn't add a test coverage here. i think it's better to add codecov integration here so we know it's being properly covered.
There was a problem hiding this comment.
Added now - Needs to go into default branch but coverage looks solid
Coverage report generated for RSpec to /Users/kwameefah/mixpanel-ruby/coverage. Line Coverage: 96.45% (544 / 564) Coverage report generated for RSpec to /Users/kwameefah/mixpanel-ruby/coverage/coverage.xml. Line Coverage: 96.45% (544 / 564)
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
This PR implements a server-side Mixpanel Feature Flags provider with support for both,
a) Remote evaluation - variant assignment implemented by making a network call to the flags endpoint
b) Local evaluation - flags configuration is polled to the client and variant assignment is performed without making a network call
GitHub Copilot Summary
This pull request introduces a comprehensive feature flag system to the Mixpanel Ruby SDK, enabling both local (client-side) and remote (server-side) flag evaluation. It adds core classes for flag management, utilities for consistent variant assignment, and example usage scripts. The implementation includes robust error handling, exposure event tracking, and support for flag polling and rollout logic.
Feature Flag System Implementation
FlagsProviderbase class (lib/mixpanel-ruby/flags/flags_provider.rb) that handles HTTP requests to the flags API and tracks exposure events for feature flag evaluations.LocalFlagsProvider(lib/mixpanel-ruby/flags/local_flags_provider.rb) for client-side flag evaluation with support for polling, rollout logic, test user overrides, and runtime evaluation using JSON logic.RemoteFlagsProvider(lib/mixpanel-ruby/flags/remote_flags_provider.rb) for server-side flag evaluation via API calls, including methods for variant selection, exposure tracking, and error handling.Utilities and Types
SelectedVariantclass (lib/mixpanel-ruby/flags/types.rb) to represent the result of a flag evaluation, including variant key/value and experiment metadata.lib/mixpanel-ruby/flags/utils.rb) for hashing, query parameter preparation, and distributed tracing headers to support flag assignment and API communication.Demo and Integration
demo/flags/local_flags.rb,demo/flags/remote_flags.rb) to illustrate how to configure and use the new feature flag system in practice. [1] [2]lib/mixpanel-ruby.rb) for seamless usage.Other
.github/workflows/ruby.ymlto remove support for older Ruby versions (2.3–2.7), focusing CI on Ruby 3.x.