Skip to content

Commit e9d01ac

Browse files
CMAB not supported in sync mode
1 parent b51c228 commit e9d01ac

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Sources/Implementation/DefaultDecisionService.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,21 @@ class DefaultDecisionService: OPTDecisionService {
8787
experiment: Experiment,
8888
user: OptimizelyUserContext,
8989
bucketingId: String,
90+
opType: OPType,
9091
options: [OptimizelyDecideOption]?) -> DecisionResponse<VariationDecision> {
9192
let reasons = DecisionReasons(options: options)
9293
guard let cmab = experiment.cmab else {
9394
logger.e("The experiment isn't a CMAB experiment")
9495
return DecisionResponse(result: nil, reasons: reasons)
9596
}
9697

98+
guard opType == .async else {
99+
let info = LogMessage.cmabNotSupportedInSyncMode
100+
logger.w(info)
101+
reasons.addInfo(info)
102+
return DecisionResponse(result: nil, reasons: reasons)
103+
}
104+
97105
let dummyEntityId = "$"
98106
let cmabTrafficAllocation = TrafficAllocation(entityId: dummyEntityId, endOfRange: cmab.trafficAllocation)
99107
let group = config.getGroup(id: experiment.id)
@@ -260,13 +268,11 @@ class DefaultDecisionService: OPTDecisionService {
260268
let bucketingId = getBucketingId(userId: userId, attributes: attributes)
261269

262270
if experiment.isCmab {
263-
if opType == .sync {
264-
/// fixme
265-
}
266271
let cmabDecisionResponse = getDecisionForCmabExperiment(config: config,
267272
experiment: experiment,
268273
user: user,
269274
bucketingId: bucketingId,
275+
opType: opType,
270276
options: options)
271277
reasons.merge(cmabDecisionResponse.reasons)
272278
variationDecision = cmabDecisionResponse.result

Sources/Utils/LogMessage.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ enum LogMessage {
7676
case valueForKeyNotFound(_ key: String)
7777
case lowPeriodicDownloadInterval
7878
case cmabFetchFailed(_ expKey: String)
79+
case cmabNotSupportedInSyncMode
7980
}
8081

8182
extension LogMessage: CustomStringConvertible {
@@ -146,6 +147,7 @@ extension LogMessage: CustomStringConvertible {
146147
case .valueForKeyNotFound(let key): message = "Value for JSON key (\(key)) not found."
147148
case .lowPeriodicDownloadInterval: message = "Polling intervals below 30 seconds are not recommended."
148149
case .cmabFetchFailed(let key): message = "Failed to fetch CMAB data for experiment: \(key)"
150+
case .cmabNotSupportedInSyncMode: message = "CMAB is not supported in sync mode."
149151
}
150152

151153
return message

0 commit comments

Comments
 (0)