Skip to content

Conversation

typotter
Copy link
Collaborator

@typotter typotter commented Sep 5, 2025

Summary

Implements OpenFeature Provider for Eppo SDK to enable standardized feature flag evaluation through the vendor-neutral OpenFeature API.

Key Features

  • Full OpenFeature Provider interface compliance - Complete implementation of all required methods
  • All flag types supported - boolean, string, number, and object flags
  • Context mapping - Automatic conversion from OpenFeature format to Eppo attributes
  • Bandit evaluation support - Special handling for bandit evaluations through object flags
  • Comprehensive error handling - Proper error mapping and graceful fallbacks
  • Provider lifecycle management - Initialization, status tracking, and cleanup
  • Event system integration - OpenFeature provider events support
  • Full backward compatibility - Maintains all existing Eppo SDK functionality

Implementation Details

Core Components Added

  • EppoOpenFeatureProvider - Main provider class implementing OpenFeature Provider interface
  • getOpenFeatureProvider() - Factory function to create provider from existing Eppo client
  • Context transformation - Maps targetingKeysubjectKey, flattens nested objects for attributes
  • Flag type handling - Routes to appropriate Eppo SDK methods based on flag type
  • Bandit support - Detects actions in context to trigger bandit evaluation

Files Added/Modified

  • 📄 src/openfeature-provider.ts - Complete provider implementation
  • 📄 src/index.ts - Added getOpenFeatureProvider() method and exports
  • 📄 package.json - Added @openfeature/server-sdk dependency
  • 🧪 src/openfeature-provider.spec.ts - Comprehensive unit tests
  • 🧪 src/openfeature-integration.spec.ts - Integration tests with OpenFeature API
  • 📖 examples/openfeature-example.ts - Complete usage examples
  • 📖 README-OpenFeature.md - Full documentation and migration guide

Usage Example

import { OpenFeature } from '@openfeature/server-sdk';
import { init, getOpenFeatureProvider } from '@eppo/node-server-sdk';

// 1. Initialize Eppo SDK as usual
await init({
  apiKey: 'your-api-key',
  assignmentLogger: { logAssignment: (assignment) => console.log(assignment) }
});

// 2. Get OpenFeature provider and set it
const provider = getOpenFeatureProvider();
OpenFeature.setProvider(provider);

// 3. Use standardized OpenFeature API
const client = OpenFeature.getClient();
const result = await client.getBooleanValue('my-flag', false, {
  targetingKey: 'user-123',
  email: '[email protected]'
});

Test Plan

  • Unit Tests - Complete test coverage for all provider methods
  • Integration Tests - End-to-end testing with OpenFeature SDK
  • Error Handling - Tests for all error scenarios and fallbacks
  • Context Transformation - Tests for nested object flattening and attribute mapping
  • Bandit Support - Tests for bandit evaluation through object flags
  • TypeScript Compilation - All code compiles without errors
  • Lint Checks - Code follows project linting standards

Manual Testing

  • Example code runs successfully
  • All flag types evaluate correctly
  • Context mapping works for complex nested objects
  • Error handling provides appropriate fallbacks
  • Bandit evaluations work through object flags

Benefits

For Developers

  • Standardization - Use vendor-neutral OpenFeature API across different feature flag systems
  • Migration Path - Gradual migration from direct SDK usage to OpenFeature
  • Ecosystem - Access to OpenFeature's growing ecosystem of tools and integrations
  • Flexibility - Easy switching between feature flag providers in the future

For the Eppo Ecosystem

  • Market Reach - Makes Eppo accessible to OpenFeature users
  • Standards Compliance - Aligns with industry-standard feature flag API
  • Integration - Enables integration with OpenFeature-compatible tools
  • Future-Proofing - Positions Eppo for emerging OpenFeature ecosystem

Compatibility & Migration

Full Backward Compatibility

  • All existing Eppo SDK usage continues to work unchanged
  • No breaking changes to existing APIs
  • Direct SDK and OpenFeature usage can coexist

Migration Strategy

// Existing code (continues to work)
const eppoClient = getInstance();
const result = eppoClient.getBooleanAssignment('flag', 'user', {}, false);

// New OpenFeature code (gradually adopted)
const client = OpenFeature.getClient();
const result = await client.getBooleanValue('flag', false, { targetingKey: 'user' });

🤖 Generated with Claude Code

Implements OpenFeature Provider for Eppo SDK to enable standardized
feature flag evaluation through the vendor-neutral OpenFeature API.

Key features:
- Full OpenFeature Provider interface compliance
- Support for all flag types (boolean, string, number, object)
- Context mapping from OpenFeature format to Eppo attributes
- Bandit evaluation support through object flags
- Comprehensive error handling and logging
- Provider lifecycle management and events
- Maintains full compatibility with existing Eppo SDK usage

Added components:
- EppoOpenFeatureProvider class with complete implementation
- getOpenFeatureProvider() method for easy integration
- Comprehensive unit and integration tests
- Usage examples and migration patterns
- Complete documentation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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