16
16
17
17
import Foundation
18
18
19
+ /// Optimizely region identifiers
20
+ public enum Region : String , Codable , Equatable {
21
+ case US
22
+ case EU
23
+ }
24
+
19
25
protocol ProjectProtocol {
20
26
func evaluateAudience( audienceId: String , user: OptimizelyUserContext ) throws -> Bool
21
27
}
@@ -48,6 +54,8 @@ struct Project: Codable, Equatable {
48
54
var environmentKey : String ?
49
55
// Holdouts
50
56
var holdouts : [ Holdout ]
57
+ // Region
58
+ var region : Region ?
51
59
let logger = OPTLoggerFactory . getLogger ( )
52
60
53
61
// Required since logger is not decodable
@@ -57,7 +65,7 @@ struct Project: Codable, Equatable {
57
65
// V3
58
66
case anonymizeIP
59
67
// V4
60
- case rollouts, integrations, typedAudiences, featureFlags, botFiltering, sendFlagDecisions, sdkKey, environmentKey, holdouts
68
+ case rollouts, integrations, typedAudiences, featureFlags, botFiltering, sendFlagDecisions, sdkKey, environmentKey, holdouts, region
61
69
}
62
70
63
71
init ( from decoder: Decoder ) throws {
@@ -88,6 +96,8 @@ struct Project: Codable, Equatable {
88
96
environmentKey = try container. decodeIfPresent ( String . self, forKey: . environmentKey)
89
97
// Holdouts - defaults to empty array if key is not present
90
98
holdouts = try container. decodeIfPresent ( [ Holdout ] . self, forKey: . holdouts) ?? [ ]
99
+ // Region - defaults to US if not present
100
+ region = try container. decodeIfPresent ( Region . self, forKey: . region)
91
101
}
92
102
93
103
// Required since logger is not equatable
@@ -97,7 +107,9 @@ struct Project: Codable, Equatable {
97
107
lhs. accountId == rhs. accountId && lhs. events == rhs. events && lhs. revision == rhs. revision &&
98
108
lhs. anonymizeIP == rhs. anonymizeIP && lhs. rollouts == rhs. rollouts &&
99
109
lhs. integrations == rhs. integrations && lhs. typedAudiences == rhs. typedAudiences &&
100
- lhs. featureFlags == rhs. featureFlags && lhs. botFiltering == rhs. botFiltering && lhs. sendFlagDecisions == rhs. sendFlagDecisions && lhs. sdkKey == rhs. sdkKey && lhs. environmentKey == rhs. environmentKey
110
+ lhs. featureFlags == rhs. featureFlags && lhs. botFiltering == rhs. botFiltering &&
111
+ lhs. sendFlagDecisions == rhs. sendFlagDecisions && lhs. sdkKey == rhs. sdkKey &&
112
+ lhs. environmentKey == rhs. environmentKey && lhs. region == rhs. region
101
113
}
102
114
}
103
115
0 commit comments