-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs_sample_config.py
More file actions
109 lines (101 loc) · 3.61 KB
/
Copy pathdocs_sample_config.py
File metadata and controls
109 lines (101 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"""Shared offline config for the Story 4.5 documentation samples.
The advanced topic guides import this so each runnable sample can focus on the
API call under discussion rather than rebuilding a fixture. It is a superset of
the Story 1.6 ``examples/_sample_config.py`` payload: experiences with a
fullStack feature change, declared goals (for the tracking guide), and segments
with a simple country rule (for the evaluation guide's custom-segment sample).
There are no secrets here — every identifier is a placeholder, and the
``sdk_key`` flow in the guides reads its key from ``CONVERT_SDK_KEY``.
"""
from __future__ import annotations
from typing import Any, Dict
def _rule_country(value: str) -> dict:
"""A single-condition rule matching ``country == value`` (segments guide)."""
return {
"OR": [
{
"AND": [
{
"OR_WHEN": [
{
"matching": {"match_type": "equals", "negated": False},
"key": "country",
"value": value,
}
]
}
]
}
]
}
SAMPLE_CONFIG: Dict[str, Any] = {
"account_id": "100123",
"project": {"id": "200456"},
"features": [
{
"id": "10024",
"key": "checkout-banner",
"name": "Checkout Banner",
"variables": [
{"key": "enabled", "type": "boolean"},
{"key": "headline", "type": "string"},
{"key": "max_items", "type": "integer"},
],
}
],
"goals": [
{"id": "g1", "key": "purchase_completed"},
{"id": "g2", "key": "signup"},
],
"segments": [
{"id": "s_us", "key": "us-visitors", "rules": _rule_country("US")},
{"id": "s_de", "key": "de-visitors", "rules": _rule_country("DE")},
],
"audiences": [],
"experiences": [
{
"id": "e1",
"key": "checkout-experiment",
"variations": [
{
"id": "v1",
"key": "control",
"traffic_allocation": 50.0,
"changes": [
{
"id": "c1",
"type": "fullStackFeature",
"data": {
"feature_id": "10024",
"variables_data": {
"enabled": "false",
"headline": "Standard checkout",
"max_items": "3",
},
},
}
],
},
{
"id": "v2",
"key": "treatment",
"traffic_allocation": 50.0,
"changes": [
{
"id": "c2",
"type": "fullStackFeature",
"data": {
"feature_id": "10024",
"variables_data": {
"enabled": "true",
"headline": "Free shipping over $50!",
"max_items": "5",
},
},
}
],
},
],
}
],
}