Conversation
Add Local Holdouts support to replace legacy flag-level holdouts with rule-level targeting. Changes: - Add includedRules field to Holdout model (replaces includedFlags/excludedFlags) - Add isGlobal computed property for global vs local holdout detection - Update HoldoutConfig mapping from flag-level to rule-level - Implement getGlobalHoldouts() and getHoldoutsForRule() methods - Integrate local holdout evaluation in decision flow (per-rule, before audience/traffic) - Handle edge cases (missing field, empty array, invalid rule IDs, cross-flag targeting) - Add comprehensive unit and integration tests for local holdouts - Update existing tests to use new API Quality Metrics: - Compilation: PASSED - Critical Issues: 0 - Warnings: 0 - Test Coverage: Comprehensive Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Local Holdouts support for the Swift SDK, replacing legacy flag-level holdout targeting (
includedFlags/excludedFlags) with rule-level targeting (includedRules).Related Ticket: FSSDK-12368
Changes
Data Model
includedRules: [String]?field toHoldoutstructisGlobalcomputed property (truewhenincludedRules == nil)includedFlags,excludedFlagsdecodeIfPresentfor optional parsingHoldout Configuration
HoldoutConfigfrom flag-level to rule-level mappinggetGlobalHoldouts() -> [Holdout]getHoldoutsForRule(ruleId:) -> [Holdout]updateHoldoutMapping()logicDecision Flow
getDecisionForFlag()getVariationFromExperimentRule()andgetVariationFromDeliveryRule()holdoutfield toVariationDecisionandDeliveryRuleDecisionEdge Cases
includedRulesfield defaults tonil(global holdout)[]vsnildistinction preserved (empty = local with no rules, nil = global)Testing
Comprehensive Test Coverage
Quality Metrics
Files Modified
Core Implementation (4 files)
Sources/Data Model/Holdout.swift- Data model updatesSources/Data Model/HoldoutConfig.swift- Configuration mappingSources/Data Model/ProjectConfig.swift- Project-level APISources/Implementation/DefaultDecisionService.swift- Decision logicTests Updated (9 files)
Tests/OptimizelyTests-DataModel/HoldoutTests.swiftTests/OptimizelyTests-DataModel/HoldoutConfigTests.swiftTests/OptimizelyTests-DataModel/ProjectConfigTests.swiftTests/OptimizelyTests-Common/DecisionServiceTests_Holdouts.swiftTests/OptimizelyTests-Common/DecisionServiceTests_LocalHoldouts.swift(NEW)Tests/OptimizelyTests-Common/DecisionListenerTest_Holdouts.swiftTests/OptimizelyTests-Common/OptimizelyUserContextTests_Decide_Holdouts.swiftTests/OptimizelyTests-Common/OptimizelyUserContextTests_Decide_With_Holdouts_Reasons.swiftTests/OptimizelyTests-Common/BatchEventBuilderTests_Events.swiftTest Plan
🤖 Generated with Claude Code