Skip to content

Conversation

@efahk
Copy link
Contributor

@efahk efahk commented Dec 18, 2025

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

  • Added a new FlagsProvider base class (lib/mixpanel-ruby/flags/flags_provider.rb) that handles HTTP requests to the flags API and tracks exposure events for feature flag evaluations.
  • Implemented 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.
  • Implemented 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

  • Added SelectedVariant class (lib/mixpanel-ruby/flags/types.rb) to represent the result of a flag evaluation, including variant key/value and experiment metadata.
  • Added utility functions (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

  • Added example demo scripts for local and remote flag usage (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]
  • Integrated new flag provider files into the SDK (lib/mixpanel-ruby.rb) for seamless usage.

Other

  • Updated Ruby workflow matrix in .github/workflows/ruby.yml to remove support for older Ruby versions (2.3–2.7), focusing CI on Ruby 3.x.

Copy link
Contributor

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 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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link

@msiebert msiebert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. Ruby is wild

@codecov
Copy link

codecov bot commented Dec 22, 2025

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 ☂️

@efahk efahk requested a review from hans-lizihan December 22, 2025 18:26
Copy link
Contributor

@jaredmixpanel jaredmixpanel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@efahk efahk merged commit a3020d2 into master Jan 5, 2026
10 checks passed
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.

5 participants