Skip to content

Commit 4de69fc

Browse files
authored
feat: add obfuscated precomputed json (#89)
* feat: add obfuscated precomputed json * Update createdAt to precede fetchedAt * Encode the salt too * Stringify response object instead * Version the test files * Update test files to use ContextAttributes type for subject attributes * Rename json files
1 parent 821f5b1 commit 4de69fc

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"version": 1,
3+
"precomputed": {
4+
"subjectKey": "test-subject-key",
5+
"subjectAttributes": {
6+
"categorical": {
7+
"platform": "ios",
8+
"language": "en-US",
9+
"hasPushEnabled": false,
10+
"buildNumber": 42
11+
},
12+
"numeric": {
13+
"lastLoginDays": 3,
14+
"lifetimeValue": 543.21
15+
}
16+
},
17+
"fetchedAt": "2024-11-18T14:23:39.456Z",
18+
"response": {
19+
"createdAt": "2024-11-18T14:23:25.123Z",
20+
"format": "PRECOMPUTED",
21+
"salt": "sodium-chloride",
22+
"obfuscated": false,
23+
"environment": {
24+
"name": "Test"
25+
},
26+
"flags": {
27+
"string-flag": {
28+
"allocationKey": "allocation-123",
29+
"variationKey": "variation-123",
30+
"variationType": "STRING",
31+
"variationValue": "red",
32+
"extraLogging": {},
33+
"doLog": true
34+
},
35+
"boolean-flag": {
36+
"allocationKey": "allocation-124",
37+
"variationKey": "variation-124",
38+
"variationType": "BOOLEAN",
39+
"variationValue": true,
40+
"extraLogging": {},
41+
"doLog": true
42+
},
43+
"integer-flag": {
44+
"allocationKey": "allocation-125",
45+
"variationKey": "variation-125",
46+
"variationType": "INTEGER",
47+
"variationValue": 42,
48+
"extraLogging": {},
49+
"doLog": true
50+
},
51+
"numeric-flag": {
52+
"allocationKey": "allocation-126",
53+
"variationKey": "variation-126",
54+
"variationType": "NUMERIC",
55+
"variationValue": 3.14,
56+
"extraLogging": {},
57+
"doLog": true
58+
},
59+
"json-flag": {
60+
"allocationKey": "allocation-127",
61+
"variationKey": "variation-127",
62+
"variationType": "JSON",
63+
"variationValue": "{\"key\":\"value\",\"number\":123}",
64+
"extraLogging": {},
65+
"doLog": true
66+
},
67+
"string-flag-with-extra-logging": {
68+
"allocationKey": "allocation-128",
69+
"variationKey": "variation-128",
70+
"variationType": "STRING",
71+
"variationValue": "red",
72+
"extraLogging": {
73+
"holdoutKey": "activeHoldout",
74+
"holdoutVariation": "all_shipped"
75+
},
76+
"doLog": true
77+
}
78+
}
79+
}
80+
}
81+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": 1,
3+
"precomputed": {
4+
"subjectKey": "test-subject-key",
5+
"subjectAttributes": {
6+
"categorical": {
7+
"platform": "ios",
8+
"language": "en-US",
9+
"hasPushEnabled": false,
10+
"buildNumber": 42
11+
},
12+
"numeric": {
13+
"lastLoginDays": 3,
14+
"lifetimeValue": 543.21
15+
}
16+
},
17+
"fetchedAt": "2024-11-18T14:23:39.456Z",
18+
"response": "{\"createdAt\":\"2024-11-18T14:23:25.123Z\",\"format\":\"PRECOMPUTED\",\"salt\":\"c29kaXVtLWNobG9yaWRl\",\"obfuscated\":true,\"environment\":{\"name\":\"Test\"},\"flags\":{\"90d768cef3e1fda4c58bf8c85d3d7018\":{\"allocationKey\":\"YWxsb2NhdGlvbi0xMjM=\",\"variationKey\":\"dmFyaWF0aW9uLTEyMw==\",\"variationType\":\"STRING\",\"variationValue\":\"cmVk\",\"extraLogging\":{},\"doLog\":true},\"19e827f266123ae8d8ffa755092f0462\":{\"allocationKey\":\"YWxsb2NhdGlvbi0xMjQ=\",\"variationKey\":\"dmFyaWF0aW9uLTEyNA==\",\"variationType\":\"BOOLEAN\",\"variationValue\":\"dHJ1ZQ==\",\"extraLogging\":{},\"doLog\":true},\"eb2a68bfa27ba09c0725c487c7603a1e\":{\"allocationKey\":\"YWxsb2NhdGlvbi0xMjU=\",\"variationKey\":\"dmFyaWF0aW9uLTEyNQ==\",\"variationType\":\"INTEGER\",\"variationValue\":\"NDI=\",\"extraLogging\":{},\"doLog\":true},\"050853f1fa3305c26750c2325848f776\":{\"allocationKey\":\"YWxsb2NhdGlvbi0xMjY=\",\"variationKey\":\"dmFyaWF0aW9uLTEyNg==\",\"variationType\":\"NUMERIC\",\"variationValue\":\"My4xNA==\",\"extraLogging\":{},\"doLog\":true},\"413c475444221453d8bd7afc9ede3160\":{\"allocationKey\":\"YWxsb2NhdGlvbi0xMjc=\",\"variationKey\":\"dmFyaWF0aW9uLTEyNw==\",\"variationType\":\"JSON\",\"variationValue\":\"eyJrZXkiOiJ2YWx1ZSIsIm51bWJlciI6MTIzfQ==\",\"extraLogging\":{},\"doLog\":true},\"095f069d330b20585bf77e492c0ac45e\":{\"allocationKey\":\"YWxsb2NhdGlvbi0xMjg=\",\"variationKey\":\"dmFyaWF0aW9uLTEyOA==\",\"variationType\":\"STRING\",\"variationValue\":\"cmVk\",\"extraLogging\":{\"aG9sZG91dEtleQ==\":\"YWN0aXZlSG9sZG91dA==\",\"aG9sZG91dFZhcmlhdGlvbg==\":\"YWxsX3NoaXBwZWQ=\"},\"doLog\":true}}}"
19+
}
20+
}

0 commit comments

Comments
 (0)