Skip to content

v4.0.0-a1

@clord clord tagged this 21 Oct 20:12
* Add percentage-based rollouts feature

Implemented gradual rollout and A/B testing capabilities using percentage-based feature flags.

Key changes:
- Added `enableFor` field to FeatureDescription (0-1 percentage value)
- Added `rolloutStableId` prop to Features component with auto-generation
- Implemented deterministic hash function for consistent user assignment
- Updated testFeature logic to support percentage rollouts
- Added comprehensive test coverage for rollout functionality

Usage example:
```typescript
const FEATURES: FeatureDescription[] = [
  { name: 'v2', enableFor: 0.3 }  // 30% rollout
];

<Features features={FEATURES} rolloutStableId={userId}>
  <Enable feature="v2">
    <NewFeature />
  </Enable>
</Features>
```

The rolloutStableId ensures consistent feature assignment - the same user
will always see the same features. If not provided, an ID is auto-generated
and persisted to sessionStorage.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix rollout tests to use diverse test data

Updated test cases to use more diverse user identifiers (emails, feature
names) instead of sequential numbers like 'user-1', 'user-2', etc. This
ensures better hash distribution and more reliable test results.

Changes:
- Use email-style identifiers for user tests
- Use descriptive feature names for feature variation tests
- Generate more diverse IDs for percentage distribution tests
- Increase test sample size for better reliability

All tests now pass consistently.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Apply Biome formatting to rollout implementation

Fixed formatting issues in test files and useTestCallback to match
project's Biome configuration.

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

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Assets 2
Loading