Skip to content

Commit 5f9b7d5

Browse files
Feature toggleability (#214)
* Feature Toggle Ability * Datafile Parsing * Decision Service changes * Unit tests * Change in Decision Service logic * test cases separated * fix - code comment
1 parent 49a9267 commit 5f9b7d5

File tree

9 files changed

+492
-13
lines changed

9 files changed

+492
-13
lines changed
Lines changed: 368 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,368 @@
1-
{"groups":[],"experiments":[{"status":"Running","key":"background_experiment","layerId":"8174477208","trafficAllocation":[{"entityId":"8182320831","endOfRange":5000},{"entityId":"8177401270","endOfRange":10000}],"audienceIds":["8179612088"],"variations":[{"variables":[],"id":"8182320831","key":"variation_a"},{"variables":[],"id":"8177401270","key":"variation_b"}],"forcedVariations":{},"id":"8183190141"}],"audiences":[{"conditions":"[\"and\", [\"or\", [\"or\", {\"name\": \"sample_attribute_key\", \"type\": \"custom_attribute\", \"value\": \"sample_attribute_value\"}]]]","id":"8179612088","name":"sample_audience"}],"anonymizeIP":false,"accountId":"6384711706","projectId":"8182362857","version":"4","attributes":[{"id":"8172478122","key":"sample_attribute_key"}],"events":[{"experimentIds":["8183190141"],"id":"8182211634","key":"sample_conversion"}],"revision":"13","featureFlags":[{"id":"4195505407","key":"boolean_feature","rolloutId":"","experimentIds":[],"variables":[]},{"id":"3926744821","key":"double_single_variable_feature","rolloutId":"","experimentIds":["2201520193"],"variables":[{"id":"4111654444","key":"double_variable","type":"double","defaultValue":"14.99"}]},{"id":"3281420120","key":"integer_single_variable_feature","rolloutId":"2048875663","experimentIds":[],"variables":[{"id":"593964691","key":"integer_variable","type":"integer","defaultValue":"7"}]},{"id":"2591051011","key":"boolean_single_variable_feature","rolloutId":"","experimentIds":[],"variables":[{"id":"3974680341","key":"boolean_variable","type":"boolean","defaultValue":"true"}]},{"id":"2079378557","key":"string_single_variable_feature","rolloutId":"1058508303","experimentIds":[],"variables":[{"id":"2077511132","key":"string_variable","type":"string","defaultValue":"wingardium leviosa"}]},{"id":"3263342226","key":"multi_variate_feature","rolloutId":"813411034","experimentIds":["3262035800"],"variables":[{"id":"675244127","key":"first_letter","type":"string","defaultValue":"H"},{"id":"4052219963","key":"rest_of_name","type":"string","defaultValue":"arry"}]},{"id":"3263342226","key":"mutex_group_feature","rolloutId":"","experimentIds":["4138322202","1786133852"],"variables":[{"id":"2059187672","key":"correlating_variation_name","type":"string","defaultValue":"null"}]}],"rollouts":[{"id":"1058508303","experiments":[{"id":"1785077004","key":"1785077004","status":"Running","layerId":"1058508303","audienceIds":[],"forcedVariations":{},"variations":[{"id":"1566407342","key":"1566407342","variables":[{"id":"2077511132","value":"lumos"}]}],"trafficAllocation":[{"entityId":"1566407342","endOfRange":5000}]}]},{"id":"813411034","experiments":[{"id":"3421010877","key":"3421010877","status":"Running","layerId":"813411034","audienceIds":["3468206642"],"forcedVariations":{},"variations":[{"id":"521740985","key":"521740985","variables":[{"id":"675244127","value":"G"},{"id":"4052219963","value":"odric"}]}],"trafficAllocation":[{"entityId":"521740985","endOfRange":5000}]},{"id":"600050626","key":"600050626","status":"Running","layerId":"813411034","audienceIds":["3988293898"],"forcedVariations":{},"variations":[{"id":"180042646","key":"180042646","variables":[{"id":"675244127","value":"S"},{"id":"4052219963","value":"alazar"}]}],"trafficAllocation":[{"entityId":"180042646","endOfRange":5000}]},{"id":"2637642575","key":"2637642575","status":"Running","layerId":"813411034","audienceIds":["4194404272"],"forcedVariations":{},"variations":[{"id":"2346257680","key":"2346257680","variables":[{"id":"675244127","value":"D"},{"id":"4052219963","value":"udley"}]}],"trafficAllocation":[{"entityId":"2346257680","endOfRange":5000}]},{"id":"828245624","key":"828245624","status":"Running","layerId":"813411034","audienceIds":[],"forcedVariations":{},"variations":[{"id":"3137445031","key":"3137445031","variables":[{"id":"675244127","value":"M"},{"id":"4052219963","value":"uggle"}]}],"trafficAllocation":[{"entityId":"3137445031","endOfRange":5000}]}]},{"id":"2048875663","experiments":[{"id":"3794675122","key":"3794675122","status":"Running","layerId":"2048875663","audienceIds":[],"forcedVariations":{},"variations":[{"id":"589640735","key":"589640735","variables":[]}],"trafficAllocation":[{"entityId":"589640735","endOfRange":10000}]}]}]}
1+
{
2+
"groups": [],
3+
"experiments": [
4+
{
5+
"status": "Running",
6+
"key": "background_experiment",
7+
"layerId": "8174477208",
8+
"trafficAllocation": [
9+
{
10+
"entityId": "8182320831",
11+
"endOfRange": 5000
12+
},
13+
{
14+
"entityId": "8177401270",
15+
"endOfRange": 10000
16+
}
17+
],
18+
"audienceIds": [
19+
"8179612088"
20+
],
21+
"variations": [
22+
{
23+
"variables": [],
24+
"id": "8182320831",
25+
"key": "variation_a",
26+
"featureEnabled": false
27+
},
28+
{
29+
"variables": [],
30+
"id": "8177401270",
31+
"key": "variation_b",
32+
"featureEnabled": false
33+
}
34+
],
35+
"forcedVariations": {},
36+
"id": "8183190141"
37+
}
38+
],
39+
"audiences": [
40+
{
41+
"conditions": "[\"and\", [\"or\", [\"or\", {\"name\": \"sample_attribute_key\", \"type\": \"custom_attribute\", \"value\": \"sample_attribute_value\"}]]]",
42+
"id": "8179612088",
43+
"name": "sample_audience"
44+
}
45+
],
46+
"anonymizeIP": false,
47+
"accountId": "6384711706",
48+
"projectId": "8182362857",
49+
"version": "4",
50+
"attributes": [
51+
{
52+
"id": "8172478122",
53+
"key": "sample_attribute_key"
54+
}
55+
],
56+
"events": [
57+
{
58+
"experimentIds": [
59+
"8183190141"
60+
],
61+
"id": "8182211634",
62+
"key": "sample_conversion"
63+
}
64+
],
65+
"revision": "13",
66+
"featureFlags": [
67+
{
68+
"id": "4195505407",
69+
"key": "boolean_feature",
70+
"rolloutId": "",
71+
"experimentIds": [],
72+
"variables": []
73+
},
74+
{
75+
"id": "3926744821",
76+
"key": "double_single_variable_feature",
77+
"rolloutId": "",
78+
"experimentIds": [
79+
"2201520193"
80+
],
81+
"variables": [
82+
{
83+
"id": "4111654444",
84+
"key": "double_variable",
85+
"type": "double",
86+
"defaultValue": "14.99"
87+
}
88+
]
89+
},
90+
{
91+
"id": "3281420120",
92+
"key": "integer_single_variable_feature",
93+
"rolloutId": "2048875663",
94+
"experimentIds": [],
95+
"variables": [
96+
{
97+
"id": "593964691",
98+
"key": "integer_variable",
99+
"type": "integer",
100+
"defaultValue": "7"
101+
}
102+
]
103+
},
104+
{
105+
"id": "2591051011",
106+
"key": "boolean_single_variable_feature",
107+
"rolloutId": "",
108+
"experimentIds": [],
109+
"variables": [
110+
{
111+
"id": "3974680341",
112+
"key": "boolean_variable",
113+
"type": "boolean",
114+
"defaultValue": "true"
115+
}
116+
]
117+
},
118+
{
119+
"id": "2079378557",
120+
"key": "string_single_variable_feature",
121+
"rolloutId": "1058508303",
122+
"experimentIds": [],
123+
"variables": [
124+
{
125+
"id": "2077511132",
126+
"key": "string_variable",
127+
"type": "string",
128+
"defaultValue": "wingardium leviosa"
129+
}
130+
]
131+
},
132+
{
133+
"id": "3263342226",
134+
"key": "multi_variate_feature",
135+
"rolloutId": "813411034",
136+
"experimentIds": [
137+
"3262035800"
138+
],
139+
"variables": [
140+
{
141+
"id": "675244127",
142+
"key": "first_letter",
143+
"type": "string",
144+
"defaultValue": "H"
145+
},
146+
{
147+
"id": "4052219963",
148+
"key": "rest_of_name",
149+
"type": "string",
150+
"defaultValue": "arry"
151+
}
152+
]
153+
},
154+
{
155+
"id": "3263342226",
156+
"key": "mutex_group_feature",
157+
"rolloutId": "",
158+
"experimentIds": [
159+
"4138322202",
160+
"1786133852"
161+
],
162+
"variables": [
163+
{
164+
"id": "2059187672",
165+
"key": "correlating_variation_name",
166+
"type": "string",
167+
"defaultValue": "null"
168+
}
169+
]
170+
}
171+
],
172+
"rollouts": [
173+
{
174+
"id": "1058508303",
175+
"experiments": [
176+
{
177+
"id": "1785077004",
178+
"key": "1785077004",
179+
"status": "Running",
180+
"layerId": "1058508303",
181+
"audienceIds": [],
182+
"forcedVariations": {},
183+
"variations": [
184+
{
185+
"id": "1566407342",
186+
"key": "1566407342",
187+
"variables": [
188+
{
189+
"id": "2077511132",
190+
"value": "lumos"
191+
}
192+
],
193+
"featureEnabled": true
194+
}
195+
],
196+
"trafficAllocation": [
197+
{
198+
"entityId": "1566407342",
199+
"endOfRange": 5000
200+
}
201+
]
202+
}
203+
]
204+
},
205+
{
206+
"id": "813411034",
207+
"experiments": [
208+
{
209+
"id": "3421010877",
210+
"key": "3421010877",
211+
"status": "Running",
212+
"layerId": "813411034",
213+
"audienceIds": [
214+
"3468206642"
215+
],
216+
"forcedVariations": {},
217+
"variations": [
218+
{
219+
"id": "521740985",
220+
"key": "521740985",
221+
"variables": [
222+
{
223+
"id": "675244127",
224+
"value": "G"
225+
},
226+
{
227+
"id": "4052219963",
228+
"value": "odric"
229+
}
230+
],
231+
"featureEnabled": true
232+
}
233+
],
234+
"trafficAllocation": [
235+
{
236+
"entityId": "521740985",
237+
"endOfRange": 5000
238+
}
239+
]
240+
},
241+
{
242+
"id": "600050626",
243+
"key": "600050626",
244+
"status": "Running",
245+
"layerId": "813411034",
246+
"audienceIds": [
247+
"3988293898"
248+
],
249+
"forcedVariations": {},
250+
"variations": [
251+
{
252+
"id": "180042646",
253+
"key": "180042646",
254+
"variables": [
255+
{
256+
"id": "675244127",
257+
"value": "S"
258+
},
259+
{
260+
"id": "4052219963",
261+
"value": "alazar"
262+
}
263+
],
264+
"featureEnabled": true
265+
}
266+
],
267+
"trafficAllocation": [
268+
{
269+
"entityId": "180042646",
270+
"endOfRange": 5000
271+
}
272+
]
273+
},
274+
{
275+
"id": "2637642575",
276+
"key": "2637642575",
277+
"status": "Running",
278+
"layerId": "813411034",
279+
"audienceIds": [
280+
"4194404272"
281+
],
282+
"forcedVariations": {},
283+
"variations": [
284+
{
285+
"id": "2346257680",
286+
"key": "2346257680",
287+
"variables": [
288+
{
289+
"id": "675244127",
290+
"value": "D"
291+
},
292+
{
293+
"id": "4052219963",
294+
"value": "udley"
295+
}
296+
],
297+
"featureEnabled": true
298+
}
299+
],
300+
"trafficAllocation": [
301+
{
302+
"entityId": "2346257680",
303+
"endOfRange": 5000
304+
}
305+
]
306+
},
307+
{
308+
"id": "828245624",
309+
"key": "828245624",
310+
"status": "Running",
311+
"layerId": "813411034",
312+
"audienceIds": [],
313+
"forcedVariations": {},
314+
"variations": [
315+
{
316+
"id": "3137445031",
317+
"key": "3137445031",
318+
"variables": [
319+
{
320+
"id": "675244127",
321+
"value": "M"
322+
},
323+
{
324+
"id": "4052219963",
325+
"value": "uggle"
326+
}
327+
],
328+
"featureEnabled": true
329+
}
330+
],
331+
"trafficAllocation": [
332+
{
333+
"entityId": "3137445031",
334+
"endOfRange": 5000
335+
}
336+
]
337+
}
338+
]
339+
},
340+
{
341+
"id": "2048875663",
342+
"experiments": [
343+
{
344+
"id": "3794675122",
345+
"key": "3794675122",
346+
"status": "Running",
347+
"layerId": "2048875663",
348+
"audienceIds": [],
349+
"forcedVariations": {},
350+
"variations": [
351+
{
352+
"id": "589640735",
353+
"key": "589640735",
354+
"variables": [],
355+
"featureEnabled": true
356+
}
357+
],
358+
"trafficAllocation": [
359+
{
360+
"entityId": "589640735",
361+
"endOfRange": 10000
362+
}
363+
]
364+
}
365+
]
366+
}
367+
]
368+
}

OptimizelySDKCore/OptimizelySDKCore/OPTLYDatafileKeys.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extern NSString * const OPTLYDatafileKeysTrafficAllocationEndOfRange;
6363
extern NSString * const OPTLYDatafileKeysVariationId;
6464
extern NSString * const OPTLYDatafileKeysVariationKey;
6565
extern NSString * const OPTLYDatafileKeysVariationVariableUsageInstances;
66+
extern NSString * const OPTLYDatafileKeysVariationFeatureEnabled;
6667
// Conditions
6768
extern NSString * const OPTLYDatafileKeysConditionName;
6869
extern NSString * const OPTLYDatafileKeysConditionType;

OptimizelySDKCore/OptimizelySDKCore/OPTLYDatafileKeys.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
NSString * const OPTLYDatafileKeysVariationId = @"id";
6060
NSString * const OPTLYDatafileKeysVariationKey = @"key";
6161
NSString * const OPTLYDatafileKeysVariationVariableUsageInstances = @"variables";
62+
NSString * const OPTLYDatafileKeysVariationFeatureEnabled = @"featureEnabled";
6263
// Conditions
6364
NSString * const OPTLYDatafileKeysConditionName = @"name";
6465
NSString * const OPTLYDatafileKeysConditionType = @"type";

OptimizelySDKCore/OptimizelySDKCore/OPTLYVariation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
@property (nonatomic, strong, nonnull) NSString *variationKey;
3939
/// The array containing the variables usage instances that are part of this variation.
4040
@property (nonatomic, strong, nullable) NSArray<OPTLYVariableUsage, Optional> *variableUsageInstances;
41+
/// Flag for Feature Toggle Ability
42+
@property (nonatomic, assign) BOOL featureEnabled;
4143

4244
/// Gets the variable usage instance for a given variable id
4345
- (nullable OPTLYVariableUsage *)getVariableUsageForVariableId:(nullable NSString *)variableId;

0 commit comments

Comments
 (0)