@@ -220,25 +220,25 @@ The `evaluate` method supports two optional parameters:
220
220
221
221
```json hl_lines="2 6 9-11"
222
222
{
223
- "premium_features": {
224
- "default": false,
225
- "rules": {
226
- "customer tier equals premium": {
227
- "when_match": true,
228
- "conditions": [
229
- {
230
- "action": "EQUALS",
231
- "key": "tier",
232
- "value": "premium"
233
- }
234
- ]
235
- }
223
+ "premium_features": {
224
+ "default": false,
225
+ "rules": {
226
+ "customer tier equals premium": {
227
+ "when_match": true,
228
+ "conditions": [
229
+ {
230
+ "action": "EQUALS",
231
+ "key": "tier",
232
+ "value": "premium"
233
+ }
234
+ ]
235
+ }
236
+ }
237
+ },
238
+ "ten_percent_off_campaign": {
239
+ "default": false
236
240
}
237
- },
238
- "ten_percent_off_campaign": {
239
- "default": false
240
- }
241
- }
241
+ }
242
242
```
243
243
244
244
#### Static flags
@@ -273,10 +273,10 @@ In this case, we could omit the `context` parameter and simply evaluate whether
273
273
274
274
```json hl_lines="2-3"
275
275
{
276
- "ten_percent_off_campaign": {
277
- "default": false
278
- }
279
- }
276
+ "ten_percent_off_campaign": {
277
+ "default": false
278
+ }
279
+ }
280
280
```
281
281
282
282
### Getting all enabled features
@@ -328,58 +328,57 @@ You can use `get_enabled_features` method for scenarios where you need a list of
328
328
329
329
```json hl_lines="2 8"
330
330
{
331
- "body": '{ "username": "lessa", "tier": "premium", "basked_id": "random_id"}' ,
332
- "resource": "/products",
333
- "path": "/products",
334
- "httpMethod": "GET",
335
- "isBase64Encoded": false,
336
- "headers": {
337
- "CloudFront-Viewer-Country": "NL",
338
- }
331
+ "body": "{\ "username\ ": \ "lessa\ ", \ "tier\ ": \ "premium\ ", \ "basked_id\ ": \ "random_id\"}" ,
332
+ "resource": "/products",
333
+ "path": "/products",
334
+ "httpMethod": "GET",
335
+ "isBase64Encoded": false,
336
+ "headers": {
337
+ "CloudFront-Viewer-Country": "NL"
338
+ }
339
339
}
340
340
```
341
341
342
342
=== "features.json"
343
343
344
344
```json hl_lines="17-18 20 27-29"
345
345
{
346
- "premium_features": {
347
- "default": false,
348
- "rules": {
349
- "customer tier equals premium": {
350
- "when_match": true,
351
- "conditions": [
352
- {
353
- "action": "EQUALS",
354
- "key": "tier",
355
- "value": "premium"
356
- }
357
- ]
358
- }
359
- }
360
- },
361
- "ten_percent_off_campaign": {
362
- "default": true
363
- },
364
- "geo_customer_campaign": {
365
- "default": false,
366
- "rules": {
367
- "customer in temporary discount geo": {
368
- "when_match": true,
369
- "conditions": [
370
- {
371
- "action": "IN",
372
- "key": "CloudFront-Viewer-Country",
373
- "value": ["NL", "IE", "UK", "PL", "PT"},
374
- }
375
- ]
376
- }
346
+ "premium_features": {
347
+ "default": false,
348
+ "rules": {
349
+ "customer tier equals premium": {
350
+ "when_match": true,
351
+ "conditions": [
352
+ {
353
+ "action": "EQUALS",
354
+ "key": "tier",
355
+ "value": "premium"
356
+ }
357
+ ]
358
+ }
359
+ }
360
+ },
361
+ "ten_percent_off_campaign": {
362
+ "default": true
363
+ },
364
+ "geo_customer_campaign": {
365
+ "default": false,
366
+ "rules": {
367
+ "customer in temporary discount geo": {
368
+ "when_match": true,
369
+ "conditions": [
370
+ {
371
+ "action": "IN",
372
+ "key": "CloudFront-Viewer-Country",
373
+ "value": ["NL", "IE", "UK", "PL", "PT"]
374
+ }
375
+ ]
376
+ }
377
+ }
377
378
}
378
- }
379
- }
379
+ }
380
380
```
381
381
382
-
383
382
## Advanced
384
383
385
384
### Schema
@@ -393,9 +392,9 @@ A feature can simply have its name and a `default` value. This is either on or o
393
392
=== "minimal_schema.json"
394
393
```json hl_lines="2-3"
395
394
{
396
- "global_feature": {
397
- "default": true
398
- }
395
+ "global_feature": {
396
+ "default": true
397
+ }
399
398
}
400
399
```
401
400
@@ -413,21 +412,21 @@ When adding `rules` to a feature, they must contain:
413
412
414
413
```json hl_lines="4-11"
415
414
{
416
- "premium_feature": {
417
- "default": false,
418
- "rules": {
419
- "customer tier equals premium": {
420
- "when_match": true,
421
- "conditions": [
422
- {
423
- "action": "EQUALS",
424
- "key": "tier",
425
- "value": "premium"
426
- }
427
- ]
428
- }
415
+ "premium_feature": {
416
+ "default": false,
417
+ "rules": {
418
+ "customer tier equals premium": {
419
+ "when_match": true,
420
+ "conditions": [
421
+ {
422
+ "action": "EQUALS",
423
+ "key": "tier",
424
+ "value": "premium"
425
+ }
426
+ ]
427
+ }
428
+ }
429
429
}
430
- }
431
430
}
432
431
```
433
432
@@ -442,11 +441,11 @@ The `conditions` block is a list of conditions that contain `action`, `key`, and
442
441
{
443
442
...
444
443
"conditions": [
445
- {
446
- "action": "EQUALS",
447
- "key": "tier",
448
- "value": "premium"
449
- }
444
+ {
445
+ "action": "EQUALS",
446
+ "key": "tier",
447
+ "value": "premium"
448
+ }
450
449
]
451
450
}
452
451
```
0 commit comments