Skip to content

Commit 51b0387

Browse files
[FSSDK-11373] add holdout support and refactor decision logic in DefaultDecisionService (#587)
1 parent 7c4fee7 commit 51b0387

20 files changed

+1971
-107
lines changed

OptimizelySwiftSDK.xcodeproj/project.pbxproj

Lines changed: 50 additions & 0 deletions
Large diffs are not rendered by default.

Sources/Data Model/FeatureFlag.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ struct FeatureFlag: Codable, Equatable, OptimizelyFeature {
3535
case variables
3636
}
3737

38-
// var holdoutIds: [String] = []
39-
4038
// MARK: - OptimizelyConfig
4139

4240
var experimentsMap: [String: OptimizelyExperiment] = [:]

Sources/Data Model/HoldoutConfig.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,3 @@ struct HoldoutConfig {
115115
return holdoutIdMap[id]
116116
}
117117
}
118-

Sources/Implementation/DecisionInfo.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct DecisionInfo {
2222
let decisionType: Constants.DecisionType
2323

2424
/// The experiment that the decision variation belongs to.
25-
var experiment: Experiment?
25+
var experiment: ExperimentCore?
2626

2727
/// The variation selected by the decision.
2828
var variation: Variation?
@@ -58,7 +58,7 @@ struct DecisionInfo {
5858
var decisionEventDispatched: Bool
5959

6060
init(decisionType: Constants.DecisionType,
61-
experiment: Experiment? = nil,
61+
experiment: ExperimentCore? = nil,
6262
variation: Variation? = nil,
6363
source: String? = nil,
6464
feature: FeatureFlag? = nil,

Sources/Implementation/DefaultBucketer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class DefaultBucketer: OPTBucketer {
120120
return DecisionResponse(result: nil, reasons: reasons)
121121
}
122122

123-
func bucketToVariation(experiment: Experiment,
123+
func bucketToVariation(experiment: ExperimentCore,
124124
bucketingId: String) -> DecisionResponse<Variation> {
125125
let reasons = DecisionReasons()
126126

Sources/Implementation/DefaultDecisionService.swift

Lines changed: 272 additions & 85 deletions
Large diffs are not rendered by default.

Sources/Implementation/Events/BatchEventBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class BatchEventBuilder {
2222
// MARK: - Impression Event
2323

2424
static func createImpressionEvent(config: ProjectConfig,
25-
experiment: Experiment?,
25+
experiment: ExperimentCore?,
2626
variation: Variation?,
2727
userId: String,
2828
attributes: OptimizelyAttributes?,

Sources/Optimizely/OptimizelyClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ extension OptimizelyClient {
804804
return (source == Constants.DecisionSource.featureTest.rawValue && decision?.variation != nil) || config.sendFlagDecisions
805805
}
806806

807-
func sendImpressionEvent(experiment: Experiment?,
807+
func sendImpressionEvent(experiment: ExperimentCore?,
808808
variation: Variation?,
809809
userId: String,
810810
attributes: OptimizelyAttributes? = nil,
@@ -892,7 +892,7 @@ extension OptimizelyClient {
892892

893893
extension OptimizelyClient {
894894

895-
func sendActivateNotification(experiment: Experiment,
895+
func sendActivateNotification(experiment: ExperimentCore,
896896
variation: Variation,
897897
userId: String,
898898
attributes: OptimizelyAttributes?,

Sources/Protocols/OPTBucketer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protocol OPTBucketer {
3636
func bucketExperiment(config: ProjectConfig,
3737
experiment: Experiment,
3838
bucketingId: String) -> DecisionResponse<Variation>
39-
39+
4040
/**
4141
Hash the bucketing ID and map it to the range [0, 10000).
4242
- Parameter bucketingId: The ID for which to generate the hash and bucket values.

Sources/Utils/Constants.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct Constants {
5757
case experiment = "experiment"
5858
case featureTest = "feature-test"
5959
case rollout = "rollout"
60+
case holdout = "holdout"
6061
}
6162

6263
struct DecisionInfoKeys {

0 commit comments

Comments
 (0)