@ak--47/dungeon-master 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +7 -7
  2. package/dungeons/technical/ad-spend-schema.json +128 -0
  3. package/dungeons/technical/ad-spend.js +116 -0
  4. package/dungeons/technical/anonymous-users-schema.json +92 -0
  5. package/dungeons/technical/anonymous-users.js +102 -0
  6. package/dungeons/technical/array-of-object-lookup-schema.json +191 -0
  7. package/dungeons/{array-of-object-lookup.js → technical/array-of-object-lookup.js} +12 -5
  8. package/dungeons/technical/experiments-schema.json +203 -0
  9. package/dungeons/technical/experiments.js +168 -0
  10. package/dungeons/technical/foobar-schema.json +362 -0
  11. package/dungeons/{foobar.js → technical/foobar.js} +3 -3
  12. package/dungeons/technical/group-analytics-schema.json +241 -0
  13. package/dungeons/technical/group-analytics.js +151 -0
  14. package/dungeons/technical/mirror-strategies-schema.json +84 -0
  15. package/dungeons/technical/mirror-strategies.js +126 -0
  16. package/dungeons/technical/nested-objects-schema.json +145 -0
  17. package/dungeons/technical/nested-objects.js +207 -0
  18. package/dungeons/technical/retention-cadence-schema.json +37 -0
  19. package/dungeons/{retention-cadence.js → technical/retention-cadence.js} +2 -3
  20. package/dungeons/technical/sanity-schema.json +185 -0
  21. package/dungeons/{sanity.js → technical/sanity.js} +4 -2
  22. package/dungeons/technical/scale-test-schema.json +70 -0
  23. package/dungeons/technical/scale-test.js +90 -0
  24. package/dungeons/technical/scd-schema.json +467 -0
  25. package/dungeons/{scd.js → technical/scd.js} +20 -10
  26. package/dungeons/technical/simple-schema.json +362 -0
  27. package/dungeons/{simple.js → technical/simple.js} +7 -7
  28. package/dungeons/technical/simplest-schema.json +724 -0
  29. package/dungeons/{simplest.js → technical/simplest.js} +7 -7
  30. package/dungeons/technical/text-generation-schema.json +1062 -0
  31. package/dungeons/{text-generation.js → technical/text-generation.js} +24 -11
  32. package/dungeons/vertical/community-schema.json +579 -0
  33. package/dungeons/vertical/community.js +794 -0
  34. package/dungeons/vertical/devtools-schema.json +601 -0
  35. package/dungeons/vertical/devtools.js +843 -0
  36. package/dungeons/vertical/ecommerce-schema.json +604 -0
  37. package/dungeons/{ecommerce.js → vertical/ecommerce.js} +43 -5
  38. package/dungeons/vertical/education-schema.json +5686 -0
  39. package/dungeons/{education.js → vertical/education.js} +70 -39
  40. package/dungeons/vertical/fintech-schema.json +630 -0
  41. package/dungeons/{fintech.js → vertical/fintech.js} +107 -56
  42. package/dungeons/vertical/fitness-schema.json +530 -0
  43. package/dungeons/vertical/fitness.js +808 -0
  44. package/dungeons/vertical/food-delivery-schema.json +36728 -0
  45. package/dungeons/{food.js → vertical/food-delivery.js} +67 -26
  46. package/dungeons/vertical/gaming-schema.json +438 -0
  47. package/dungeons/{gaming.js → vertical/gaming.js} +29 -16
  48. package/dungeons/vertical/healthcare-schema.json +549 -0
  49. package/dungeons/vertical/healthcare.js +775 -0
  50. package/dungeons/vertical/insurance-application-schema.json +485 -0
  51. package/dungeons/{insurance-application.js → vertical/insurance-application.js} +41 -31
  52. package/dungeons/vertical/logistics-schema.json +574 -0
  53. package/dungeons/vertical/logistics.js +799 -0
  54. package/dungeons/vertical/marketplace-schema.json +533 -0
  55. package/dungeons/vertical/marketplace.js +850 -0
  56. package/dungeons/vertical/media-schema.json +4749 -0
  57. package/dungeons/{media.js → vertical/media.js} +103 -19
  58. package/dungeons/vertical/rpg-schema.json +2491 -0
  59. package/dungeons/{rpg.js → vertical/rpg.js} +87 -60
  60. package/dungeons/vertical/sass-schema.json +3128 -0
  61. package/dungeons/{sass.js → vertical/sass.js} +65 -26
  62. package/dungeons/vertical/social-schema.json +620 -0
  63. package/dungeons/{social.js → vertical/social.js} +76 -17
  64. package/dungeons/vertical/travel-schema.json +580 -0
  65. package/dungeons/vertical/travel.js +742 -0
  66. package/index.js +20 -16
  67. package/lib/core/config-validator.js +286 -1
  68. package/lib/core/context.js +16 -5
  69. package/lib/core/storage.js +2 -0
  70. package/lib/generators/adspend.js +3 -3
  71. package/lib/generators/events.js +141 -14
  72. package/lib/generators/funnels.js +67 -7
  73. package/lib/generators/text.js +2 -2
  74. package/lib/orchestrators/user-loop.js +444 -22
  75. package/lib/templates/soup-presets.js +2 -2
  76. package/lib/utils/utils.js +4 -5
  77. package/package.json +4 -3
  78. package/scripts/dungeon-to-json.mjs +163 -0
  79. package/scripts/extract-dungeon-schema.mjs +343 -0
  80. package/scripts/json-to-dungeon.mjs +200 -0
  81. package/scripts/run-dungeon.mjs +76 -0
  82. package/scripts/run-many.mjs +118 -0
  83. package/scripts/verify-runner.mjs +42 -0
  84. package/types.d.ts +316 -1
  85. package/dungeons/array-of-object-lookup-schema.json +0 -327
  86. package/dungeons/ecommerce-schema.json +0 -462
  87. package/dungeons/education-schema.json +0 -2409
  88. package/dungeons/fintech-schema.json +0 -14034
  89. package/dungeons/foobar-schema.json +0 -403
  90. package/dungeons/food-delivery-schema.json +0 -192
  91. package/dungeons/food-delivery.js +0 -602
  92. package/dungeons/food-schema.json +0 -1152
  93. package/dungeons/gaming-schema.json +0 -1270
  94. package/dungeons/insurance-application-schema.json +0 -204
  95. package/dungeons/media-schema.json +0 -906
  96. package/dungeons/retention-cadence-schema.json +0 -78
  97. package/dungeons/rpg-schema.json +0 -4526
  98. package/dungeons/sanity-schema.json +0 -255
  99. package/dungeons/sass-schema.json +0 -1291
  100. package/dungeons/scd-schema.json +0 -919
  101. package/dungeons/simple-schema.json +0 -608
  102. package/dungeons/simplest-schema.json +0 -1418
  103. package/dungeons/social-schema.json +0 -1118
  104. package/dungeons/text-generation-schema.json +0 -3096
@@ -1,327 +0,0 @@
1
- {
2
- "schema": {
3
- "seed": "test array of objects lookup",
4
- "name": "array-of-object-lookup",
5
- "numDays": 60,
6
- "numEvents": 100000,
7
- "numUsers": 1000,
8
- "format": "json",
9
- "region": "US",
10
- "hasAnonIds": true,
11
- "hasSessionIds": true,
12
- "hasAdSpend": false,
13
- "hasLocation": true,
14
- "hasAndroidDevices": false,
15
- "hasIOSDevices": false,
16
- "hasDesktopDevices": true,
17
- "hasBrowser": true,
18
- "hasCampaigns": false,
19
- "isAnonymous": false,
20
- "alsoInferFunnels": true,
21
- "concurrency": 1,
22
- "batchSize": 250000,
23
- "writeToDisk": false,
24
- "events": [
25
- {
26
- "event": "checkout",
27
- "weight": 2,
28
- "properties": {
29
- "currency": [
30
- "USD",
31
- "CAD",
32
- "EUR",
33
- "BTC",
34
- "ETH",
35
- "JPY"
36
- ],
37
- "coupon": {
38
- "functionName": "arrow",
39
- "body": "function generateWeightedArray() {\n\t\tconst weightedArray = [];\n\n\t\t// Add each value to the array the number of times specified by its weight\n\t\tweightedItems.forEach(({ value, weight }) => {\n\t\t\tif (!weight) weight = 1;\n\t\t\tfor (let i = 0; i < weight; i++) {\n\t\t\t\tweightedArray.push(value);\n\t\t\t}\n\t\t});\n\n\t\treturn weightedArray;\n\t}"
40
- },
41
- "cart": {
42
- "functionName": "arrow",
43
- "body": "function () {\n\t\tconst categories = [\"electronics\", \"books\", \"clothing\", \"home\", \"garden\", \"toys\", \"sports\", \"automotive\", \"beauty\", \"health\", \"grocery\", \"jewelry\", \"shoes\", \"tools\", \"office supplies\"];\n\t\tconst descriptors = [\"brand new\", \"open box\", \"refurbished\", \"used\", \"like new\", \"vintage\", \"antique\", \"collectible\"];\n\t\tconst suffix = [\"item\", \"product\", \"good\", \"merchandise\", \"thing\", \"object\", \"widget\", \"gadget\", \"device\", \"apparatus\", \"contraption\", \"instrument\", \"tool\", \"implement\", \"utensil\", \"appliance\", \"machine\", \"equipment\", \"gear\", \"kit\", \"set\", \"package\"];\n\t\tconst assetPreview = ['.png', '.jpg', '.jpeg', '.heic', '.mp4', '.mov', '.avi'];\n\t\tconst data = [];\n\t\tconst numOfItems = integer(1, maxItems);\n\n\t\tfor (var i = 0; i < numOfItems; i++) {\n\t\t\tconst category = chance.pickone(categories);\n\t\t\tconst descriptor = chance.pickone(descriptors);\n\t\t\tconst suffixWord = chance.pickone(suffix);\n\t\t\tconst slug = `${descriptor.replace(/\\s+/g, '-').toLowerCase()}-${suffixWord.replace(/\\s+/g, '-').toLowerCase()}`;\n\t\t\tconst asset = chance.pickone(assetPreview);\n\n\t\t\t// const product_id = chance.guid();\n\t\t\tconst price = integer(1, 100);\n\t\t\tconst quantity = integer(1, 5);\n\t\t\tconst product_id = integer(1, 1_000);\n\n\t\t\tconst item = {\n\t\t\t\tproduct_id: product_id,\n\t\t\t\tproduct_url: `https://example.com/assets/${product_id}`,\n\t\t\t\t// sku: integer(11111, 99999),\n\t\t\t\t// amount: price,\n\t\t\t\t// quantity: quantity,\n\t\t\t\t// total_value: price * quantity,\n\t\t\t\t// featured: chance.pickone([true, false, false]),\n\t\t\t\t// category: category,\n\t\t\t\t// descriptor: descriptor,\n\t\t\t\t// slug: slug,\n\t\t\t\t\n\t\t\t\t// assetType: asset\n\n\t\t\t};\n\n\t\t\tdata.push(item);\n\t\t}\n\n\t\treturn () => [data];\n\t}"
44
- }
45
- }
46
- },
47
- {
48
- "event": "add to cart",
49
- "weight": 4,
50
- "properties": {
51
- "item": {
52
- "functionName": "arrow",
53
- "body": "function () {\n\t\tconst categories = [\"electronics\", \"books\", \"clothing\", \"home\", \"garden\", \"toys\", \"sports\", \"automotive\", \"beauty\", \"health\", \"grocery\", \"jewelry\", \"shoes\", \"tools\", \"office supplies\"];\n\t\tconst descriptors = [\"brand new\", \"open box\", \"refurbished\", \"used\", \"like new\", \"vintage\", \"antique\", \"collectible\"];\n\t\tconst suffix = [\"item\", \"product\", \"good\", \"merchandise\", \"thing\", \"object\", \"widget\", \"gadget\", \"device\", \"apparatus\", \"contraption\", \"instrument\", \"tool\", \"implement\", \"utensil\", \"appliance\", \"machine\", \"equipment\", \"gear\", \"kit\", \"set\", \"package\"];\n\t\tconst assetPreview = ['.png', '.jpg', '.jpeg', '.heic', '.mp4', '.mov', '.avi'];\n\t\tconst data = [];\n\t\tconst numOfItems = integer(1, maxItems);\n\n\t\tfor (var i = 0; i < numOfItems; i++) {\n\t\t\tconst category = chance.pickone(categories);\n\t\t\tconst descriptor = chance.pickone(descriptors);\n\t\t\tconst suffixWord = chance.pickone(suffix);\n\t\t\tconst slug = `${descriptor.replace(/\\s+/g, '-').toLowerCase()}-${suffixWord.replace(/\\s+/g, '-').toLowerCase()}`;\n\t\t\tconst asset = chance.pickone(assetPreview);\n\n\t\t\t// const product_id = chance.guid();\n\t\t\tconst price = integer(1, 100);\n\t\t\tconst quantity = integer(1, 5);\n\t\t\tconst product_id = integer(1, 1_000);\n\n\t\t\tconst item = {\n\t\t\t\tproduct_id: product_id,\n\t\t\t\tproduct_url: `https://example.com/assets/${product_id}`,\n\t\t\t\t// sku: integer(11111, 99999),\n\t\t\t\t// amount: price,\n\t\t\t\t// quantity: quantity,\n\t\t\t\t// total_value: price * quantity,\n\t\t\t\t// featured: chance.pickone([true, false, false]),\n\t\t\t\t// category: category,\n\t\t\t\t// descriptor: descriptor,\n\t\t\t\t// slug: slug,\n\t\t\t\t\n\t\t\t\t// assetType: asset\n\n\t\t\t};\n\n\t\t\tdata.push(item);\n\t\t}\n\n\t\treturn () => [data];\n\t}"
54
- }
55
- }
56
- },
57
- {
58
- "event": "view item",
59
- "weight": 8,
60
- "properties": {
61
- "item": {
62
- "functionName": "arrow",
63
- "body": "function () {\n\t\tconst categories = [\"electronics\", \"books\", \"clothing\", \"home\", \"garden\", \"toys\", \"sports\", \"automotive\", \"beauty\", \"health\", \"grocery\", \"jewelry\", \"shoes\", \"tools\", \"office supplies\"];\n\t\tconst descriptors = [\"brand new\", \"open box\", \"refurbished\", \"used\", \"like new\", \"vintage\", \"antique\", \"collectible\"];\n\t\tconst suffix = [\"item\", \"product\", \"good\", \"merchandise\", \"thing\", \"object\", \"widget\", \"gadget\", \"device\", \"apparatus\", \"contraption\", \"instrument\", \"tool\", \"implement\", \"utensil\", \"appliance\", \"machine\", \"equipment\", \"gear\", \"kit\", \"set\", \"package\"];\n\t\tconst assetPreview = ['.png', '.jpg', '.jpeg', '.heic', '.mp4', '.mov', '.avi'];\n\t\tconst data = [];\n\t\tconst numOfItems = integer(1, maxItems);\n\n\t\tfor (var i = 0; i < numOfItems; i++) {\n\t\t\tconst category = chance.pickone(categories);\n\t\t\tconst descriptor = chance.pickone(descriptors);\n\t\t\tconst suffixWord = chance.pickone(suffix);\n\t\t\tconst slug = `${descriptor.replace(/\\s+/g, '-').toLowerCase()}-${suffixWord.replace(/\\s+/g, '-').toLowerCase()}`;\n\t\t\tconst asset = chance.pickone(assetPreview);\n\n\t\t\t// const product_id = chance.guid();\n\t\t\tconst price = integer(1, 100);\n\t\t\tconst quantity = integer(1, 5);\n\t\t\tconst product_id = integer(1, 1_000);\n\n\t\t\tconst item = {\n\t\t\t\tproduct_id: product_id,\n\t\t\t\tproduct_url: `https://example.com/assets/${product_id}`,\n\t\t\t\t// sku: integer(11111, 99999),\n\t\t\t\t// amount: price,\n\t\t\t\t// quantity: quantity,\n\t\t\t\t// total_value: price * quantity,\n\t\t\t\t// featured: chance.pickone([true, false, false]),\n\t\t\t\t// category: category,\n\t\t\t\t// descriptor: descriptor,\n\t\t\t\t// slug: slug,\n\t\t\t\t\n\t\t\t\t// assetType: asset\n\n\t\t\t};\n\n\t\t\tdata.push(item);\n\t\t}\n\n\t\treturn () => [data];\n\t}"
64
- }
65
- }
66
- },
67
- {
68
- "event": "save item",
69
- "weight": 5,
70
- "properties": {
71
- "item": {
72
- "functionName": "arrow",
73
- "body": "function () {\n\t\tconst categories = [\"electronics\", \"books\", \"clothing\", \"home\", \"garden\", \"toys\", \"sports\", \"automotive\", \"beauty\", \"health\", \"grocery\", \"jewelry\", \"shoes\", \"tools\", \"office supplies\"];\n\t\tconst descriptors = [\"brand new\", \"open box\", \"refurbished\", \"used\", \"like new\", \"vintage\", \"antique\", \"collectible\"];\n\t\tconst suffix = [\"item\", \"product\", \"good\", \"merchandise\", \"thing\", \"object\", \"widget\", \"gadget\", \"device\", \"apparatus\", \"contraption\", \"instrument\", \"tool\", \"implement\", \"utensil\", \"appliance\", \"machine\", \"equipment\", \"gear\", \"kit\", \"set\", \"package\"];\n\t\tconst assetPreview = ['.png', '.jpg', '.jpeg', '.heic', '.mp4', '.mov', '.avi'];\n\t\tconst data = [];\n\t\tconst numOfItems = integer(1, maxItems);\n\n\t\tfor (var i = 0; i < numOfItems; i++) {\n\t\t\tconst category = chance.pickone(categories);\n\t\t\tconst descriptor = chance.pickone(descriptors);\n\t\t\tconst suffixWord = chance.pickone(suffix);\n\t\t\tconst slug = `${descriptor.replace(/\\s+/g, '-').toLowerCase()}-${suffixWord.replace(/\\s+/g, '-').toLowerCase()}`;\n\t\t\tconst asset = chance.pickone(assetPreview);\n\n\t\t\t// const product_id = chance.guid();\n\t\t\tconst price = integer(1, 100);\n\t\t\tconst quantity = integer(1, 5);\n\t\t\tconst product_id = integer(1, 1_000);\n\n\t\t\tconst item = {\n\t\t\t\tproduct_id: product_id,\n\t\t\t\tproduct_url: `https://example.com/assets/${product_id}`,\n\t\t\t\t// sku: integer(11111, 99999),\n\t\t\t\t// amount: price,\n\t\t\t\t// quantity: quantity,\n\t\t\t\t// total_value: price * quantity,\n\t\t\t\t// featured: chance.pickone([true, false, false]),\n\t\t\t\t// category: category,\n\t\t\t\t// descriptor: descriptor,\n\t\t\t\t// slug: slug,\n\t\t\t\t\n\t\t\t\t// assetType: asset\n\n\t\t\t};\n\n\t\t\tdata.push(item);\n\t\t}\n\n\t\treturn () => [data];\n\t}"
74
- }
75
- }
76
- }
77
- ],
78
- "funnels": [],
79
- "superProps": {
80
- "theme": {
81
- "functionName": "arrow",
82
- "body": "function () {\n\t\tconst weighted = [];\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tconst rand = chance.d10(); // Random number between 1 and 10\n\n\t\t\t// 35% chance to favor the most chosen index\n\t\t\tif (chance.bool({ likelihood: 35 })) {\n\t\t\t\t// 50% chance to slightly alter the index\n\t\t\t\tif (chance.bool({ likelihood: 50 })) {\n\t\t\t\t\tweighted.push(items[mostChosenIndex]);\n\t\t\t\t} else {\n\t\t\t\t\tconst addOrSubtract = chance.bool({ likelihood: 50 }) ? -rand : rand;\n\t\t\t\t\tlet newIndex = mostChosenIndex + addOrSubtract;\n\n\t\t\t\t\t// Ensure newIndex is within bounds\n\t\t\t\t\tif (newIndex < 0) newIndex = 0;\n\t\t\t\t\tif (newIndex >= items.length) newIndex = items.length - 1;\n\t\t\t\t\tweighted.push(items[newIndex]);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// 25% chance to favor the second most chosen index\n\t\t\telse if (chance.bool({ likelihood: 25 })) {\n\t\t\t\tweighted.push(items[secondMostChosenIndex]);\n\t\t\t}\n\t\t\t// 15% chance to favor the third most chosen index\n\t\t\telse if (chance.bool({ likelihood: 15 })) {\n\t\t\t\tweighted.push(items[thirdMostChosenIndex]);\n\t\t\t}\n\t\t\t// Otherwise, pick a random item from the list\n\t\t\telse {\n\t\t\t\tweighted.push(chance.pickone(items));\n\t\t\t}\n\t\t}\n\t\treturn weighted;\n\t}"
83
- }
84
- },
85
- "userProps": {
86
- "spiritAnimal": [
87
- "duck",
88
- "dog",
89
- "otter",
90
- "penguin",
91
- "cat",
92
- "elephant",
93
- "lion",
94
- "cheetah",
95
- "giraffe",
96
- "zebra",
97
- "rhino",
98
- "hippo",
99
- "whale",
100
- "dolphin",
101
- "shark",
102
- "octopus",
103
- "squid",
104
- "jellyfish",
105
- "starfish",
106
- "seahorse",
107
- "crab",
108
- "lobster",
109
- "shrimp",
110
- "clam",
111
- "snail",
112
- "slug",
113
- "butterfly",
114
- "moth",
115
- "bee",
116
- "wasp",
117
- "ant",
118
- "beetle",
119
- "ladybug",
120
- "caterpillar",
121
- "centipede",
122
- "millipede",
123
- "scorpion",
124
- "spider",
125
- "tarantula",
126
- "tick",
127
- "mite",
128
- "mosquito",
129
- "fly",
130
- "dragonfly",
131
- "damselfly",
132
- "grasshopper",
133
- "cricket",
134
- "locust",
135
- "mantis",
136
- "cockroach",
137
- "termite",
138
- "praying mantis",
139
- "walking stick",
140
- "stick bug",
141
- "leaf insect",
142
- "lacewing",
143
- "aphid",
144
- "cicada",
145
- "thrips",
146
- "psyllid",
147
- "scale insect",
148
- "whitefly",
149
- "mealybug",
150
- "planthopper",
151
- "leafhopper",
152
- "treehopper",
153
- "flea",
154
- "louse",
155
- "bedbug",
156
- "flea beetle",
157
- "weevil",
158
- "longhorn beetle",
159
- "leaf beetle",
160
- "tiger beetle",
161
- "ground beetle",
162
- "lady beetle",
163
- "firefly",
164
- "click beetle",
165
- "rove beetle",
166
- "scarab beetle",
167
- "dung beetle",
168
- "stag beetle",
169
- "rhinoceros beetle",
170
- "hercules beetle",
171
- "goliath beetle",
172
- "jewel beetle",
173
- "tortoise beetle"
174
- ]
175
- },
176
- "scdProps": {},
177
- "mirrorProps": {},
178
- "groupKeys": [],
179
- "groupProps": {},
180
- "lookupTables": [
181
- {
182
- "key": "product_id",
183
- "entries": 1000,
184
- "attributes": {
185
- "amount": [
186
- 259,
187
- 247,
188
- 271,
189
- 269,
190
- 209,
191
- 305,
192
- 706,
193
- 344,
194
- 350,
195
- 327,
196
- 259,
197
- 225,
198
- 269,
199
- 267,
200
- 256,
201
- 705,
202
- 196,
203
- 588,
204
- 775,
205
- 235,
206
- 737,
207
- 341,
208
- 268,
209
- 409,
210
- 233,
211
- 246,
212
- 239,
213
- 737,
214
- 701,
215
- 741,
216
- 227,
217
- 230,
218
- 693,
219
- 719,
220
- 277,
221
- 706,
222
- 292,
223
- 274,
224
- 596,
225
- 263,
226
- 250,
227
- 279,
228
- 275,
229
- 799,
230
- 236,
231
- 267,
232
- 221,
233
- 230,
234
- 730,
235
- 789
236
- ],
237
- "quantity": [
238
- 4,
239
- 5,
240
- 7,
241
- 4,
242
- 8,
243
- 6,
244
- 3,
245
- 3,
246
- 4,
247
- 6,
248
- 3,
249
- 3,
250
- 8,
251
- 3,
252
- 3,
253
- 8,
254
- 3,
255
- 8,
256
- 7,
257
- 4,
258
- 8,
259
- 4,
260
- 4,
261
- 4,
262
- 4,
263
- 3,
264
- 5,
265
- 4,
266
- 3,
267
- 3,
268
- 3,
269
- 7,
270
- 3,
271
- 3,
272
- 4,
273
- 4,
274
- 6,
275
- 4,
276
- 7,
277
- 7,
278
- 4,
279
- 3,
280
- 3,
281
- 3,
282
- 3,
283
- 4,
284
- 8,
285
- 3,
286
- 3,
287
- 3
288
- ],
289
- "featured": {
290
- "functionName": "arrow",
291
- "body": "function flip(likelihood = 50) {\n\treturn chance.bool({ likelihood });\n}"
292
- },
293
- "category": [
294
- "electronics",
295
- "books",
296
- "clothing",
297
- "home",
298
- "garden",
299
- "toys",
300
- "sports",
301
- "automotive",
302
- "beauty",
303
- "health",
304
- "grocery",
305
- "jewelry",
306
- "shoes",
307
- "tools",
308
- "office supplies"
309
- ],
310
- "descriptor": [
311
- "brand new",
312
- "open box",
313
- "refurbished",
314
- "used",
315
- "like new",
316
- "vintage",
317
- "antique",
318
- "collectible"
319
- ]
320
- }
321
- }
322
- ]
323
- },
324
- "hooks": "function (record, type, meta) {\n\n\t\tconst NOW = dayjs();\n\n\t\tif (type === \"event\") {\n\t\t\t// Pattern 1: Checkouts with coupons get a discount_applied flag and adjusted total\n\t\t\tif (record.event === \"checkout\" && record.coupon && record.coupon !== \"none\") {\n\t\t\t\trecord.discount_applied = true;\n\t\t\t\tconst pctMatch = record.coupon.match(/(\\d+)%/);\n\t\t\t\tif (pctMatch) {\n\t\t\t\t\trecord.discount_percent = parseInt(pctMatch[1]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Pattern 2: \"save item\" events on weekends are tagged as wishlist behavior\n\t\t\tif (record.event === \"save item\") {\n\t\t\t\tconst dow = dayjs(record.time).day();\n\t\t\t\tif (dow === 0 || dow === 6) {\n\t\t\t\t\trecord.save_context = \"weekend_browse\";\n\t\t\t\t} else {\n\t\t\t\t\trecord.save_context = \"weekday_intent\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (type === \"everything\") {\n\t\t\t// Pattern 3: Users who view 5+ items but never checkout are tagged as window shoppers\n\t\t\tconst views = record.filter(e => e.event === \"view item\").length;\n\t\t\tconst checkouts = record.filter(e => e.event === \"checkout\").length;\n\t\t\tif (views >= 5 && checkouts === 0) {\n\t\t\t\tfor (const e of record) {\n\t\t\t\t\te.user_segment = \"window_shopper\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn record;\n\t}",
325
- "timestamp": "2026-04-10T01:39:06.554Z",
326
- "version": "4.0"
327
- }