make-mp-data 1.5.55 → 2.0.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 (56) hide show
  1. package/.claude/settings.local.json +20 -0
  2. package/.gcloudignore +2 -1
  3. package/.vscode/launch.json +6 -3
  4. package/.vscode/settings.json +31 -2
  5. package/dungeons/media.js +371 -0
  6. package/index.js +354 -1757
  7. package/{components → lib/cli}/cli.js +21 -6
  8. package/lib/cloud-function.js +20 -0
  9. package/lib/core/config-validator.js +248 -0
  10. package/lib/core/context.js +180 -0
  11. package/lib/core/storage.js +268 -0
  12. package/{components → lib/data}/defaults.js +17 -14
  13. package/lib/generators/adspend.js +133 -0
  14. package/lib/generators/events.js +242 -0
  15. package/lib/generators/funnels.js +330 -0
  16. package/lib/generators/mirror.js +168 -0
  17. package/lib/generators/profiles.js +93 -0
  18. package/lib/generators/scd.js +102 -0
  19. package/lib/orchestrators/mixpanel-sender.js +222 -0
  20. package/lib/orchestrators/user-loop.js +194 -0
  21. package/lib/orchestrators/worker-manager.js +200 -0
  22. package/{components → lib/utils}/ai.js +8 -36
  23. package/{components → lib/utils}/chart.js +9 -9
  24. package/{components → lib/utils}/project.js +4 -4
  25. package/{components → lib/utils}/utils.js +35 -23
  26. package/package.json +19 -12
  27. package/scripts/dana.mjs +137 -0
  28. package/scripts/new-dungeon.sh +7 -6
  29. package/scripts/update-deps.sh +2 -1
  30. package/tests/cli.test.js +28 -25
  31. package/tests/e2e.test.js +38 -36
  32. package/tests/int.test.js +151 -56
  33. package/tests/testSoup.mjs +1 -1
  34. package/tests/unit.test.js +15 -14
  35. package/tsconfig.json +1 -1
  36. package/types.d.ts +76 -18
  37. package/vitest.config.js +47 -0
  38. package/dungeons/adspend.js +0 -96
  39. package/dungeons/anon.js +0 -104
  40. package/dungeons/big.js +0 -224
  41. package/dungeons/business.js +0 -327
  42. package/dungeons/complex.js +0 -396
  43. package/dungeons/foobar.js +0 -241
  44. package/dungeons/funnels.js +0 -220
  45. package/dungeons/gaming-experiments.js +0 -323
  46. package/dungeons/gaming.js +0 -314
  47. package/dungeons/governance.js +0 -288
  48. package/dungeons/mirror.js +0 -129
  49. package/dungeons/sanity.js +0 -118
  50. package/dungeons/scd.js +0 -205
  51. package/dungeons/session-replay.js +0 -175
  52. package/dungeons/simple.js +0 -150
  53. package/dungeons/userAgent.js +0 -190
  54. package/log.json +0 -1067
  55. package/tests/jest.config.js +0 -47
  56. /package/{components → lib/utils}/prompt.txt +0 -0
@@ -1,220 +0,0 @@
1
- /**
2
- * This is the default configuration file for the data generator in SIMPLE mode
3
- * notice how the config object is structured, and see it's type definition in ./types.d.ts
4
- * feel free to modify this file to customize the data you generate
5
- * see helper functions in utils.js for more ways to generate data
6
- */
7
-
8
-
9
-
10
-
11
- const Chance = require('chance');
12
- const chance = new Chance();
13
- const dayjs = require("dayjs");
14
- const utc = require("dayjs/plugin/utc");
15
- dayjs.extend(utc);
16
- const { uid, comma } = require('ak-tools');
17
- const { pickAWinner, weighNumRange, date, integer } = require('../components/utils');
18
-
19
- const itemCategories = ["Books", "Movies", "Music", "Games", "Electronics", "Computers", "Smart Home", "Home", "Garden", "Pet", "Beauty", "Health", "Toys", "Kids", "Baby", "Handmade", "Sports", "Outdoors", "Automotive", "Industrial", "Entertainment", "Art", "Food", "Appliances", "Office", "Wedding", "Software"];
20
-
21
- const videoCategories = ["funny", "educational", "inspirational", "music", "news", "sports", "cooking", "DIY", "travel", "gaming"];
22
-
23
- /** @type {import('../types').Dungeon} */
24
- const config = {
25
- token: "",
26
- seed: "simple is best",
27
- numDays: 30, //how many days worth of data
28
- numEvents: 50000, //how many events
29
- numUsers: 500, //how many users
30
- format: 'csv', //csv or json
31
- region: "US",
32
- hasAnonIds: false, //if true, anonymousIds are created for each user
33
- hasSessionIds: false, //if true, hasSessionIds are created for each user
34
-
35
- events: [
36
- {
37
- event: "checkout",
38
- weight: 2,
39
- properties: {
40
- amount: weighNumRange(5, 500, .25),
41
- currency: ["USD", "CAD", "EUR", "BTC", "ETH", "JPY"],
42
- coupon: ["none", "none", "none", "none", "10%OFF", "20%OFF", "10%OFF", "20%OFF", "30%OFF", "40%OFF", "50%OFF"],
43
- numItems: weighNumRange(1, 10),
44
-
45
- }
46
- },
47
- {
48
- event: "add to cart",
49
- weight: 4,
50
- properties: {
51
- amount: weighNumRange(5, 500, .25),
52
- rating: weighNumRange(1, 5),
53
- reviews: weighNumRange(0, 35),
54
- isFeaturedItem: [true, false, false],
55
- itemCategory: pickAWinner(itemCategories, integer(0, 27)),
56
- dateItemListed: date(30, true, 'YYYY-MM-DD'),
57
- itemId: integer(1000, 9999),
58
- }
59
- },
60
- {
61
- event: "page view",
62
- weight: 10,
63
- properties: {
64
- page: ["/", "/", "/help", "/account", "/watch", "/listen", "/product", "/people", "/peace"],
65
- utm_source: ["$organic", "$organic", "$organic", "$organic", "google", "google", "google", "facebook", "facebook", "twitter", "linkedin"],
66
- }
67
- },
68
- {
69
- event: "watch video",
70
- weight: 8,
71
- properties: {
72
- videoCategory: pickAWinner(videoCategories, integer(0, 9)),
73
- isFeaturedItem: [true, false, false],
74
- watchTimeSec: weighNumRange(10, 600, .25),
75
- quality: ["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p"],
76
- format: ["mp4", "avi", "mov", "mpg"],
77
- uploader_id: chance.guid.bind(chance)
78
-
79
- }
80
- },
81
- {
82
- event: "view item",
83
- weight: 8,
84
- properties: {
85
- isFeaturedItem: [true, false, false],
86
- itemCategory: pickAWinner(itemCategories, integer(0, 27)),
87
- dateItemListed: date(30, true, 'YYYY-MM-DD'),
88
- itemId: integer(1000, 9999),
89
- }
90
- },
91
- {
92
- event: "save item",
93
- weight: 5,
94
- properties: {
95
- isFeaturedItem: [true, false, false],
96
- itemCategory: pickAWinner(itemCategories, integer(0, 27)),
97
- dateItemListed: date(30, true, 'YYYY-MM-DD'),
98
- itemId: integer(1000, 9999),
99
- }
100
- },
101
- {
102
- event: "sign up",
103
- isFirstEvent: true,
104
- weight: 0,
105
- properties: {
106
- CTA: ["sign up", "register", "join", "create account"]
107
- }
108
- }
109
- ],
110
- funnels: [
111
- // {
112
- // sequence: ["page view", "view item", "page view", "sign up"],
113
- // weight: 1,
114
- // isFirstFunnel: true,
115
- // order: "sequential",
116
- // conversionRate: 50,
117
- // timeToConvert: 2,
118
- // props: {
119
- // variants: ["A", "B", "C", "Control"],
120
- // flows: ["new", "existing", "loyal", "churned"],
121
- // flags: ["on", "off"],
122
- // experiment_ids: ["1234", "5678", "9012", "3456", "7890"],
123
- // multiVariate: [true, false]
124
-
125
- // },
126
-
127
- // },
128
- // {
129
- // sequence: ["app install", "app open", "tutorial", "sign up"],
130
- // weight: 1,
131
- // isFirstFunnel: true,
132
- // order: "sequential",
133
- // conversionRate: 50,
134
- // timeToConvert: 2,
135
- // props: {
136
- // variants: ["A", "B", "C", "Control"],
137
- // flows: ["new", "existing", "loyal", "churned"],
138
- // flags: ["on", "off"],
139
- // experiment_ids: ["1234", "5678", "9012", "3456", "7890"],
140
- // multiVariate: [true, false]
141
-
142
- // }
143
- // },
144
- // {
145
- // sequence: ["view item", "add to cart", "checkout", "rage", "cage", "mage"],
146
- // order: "interrupted"
147
- // },
148
- // {
149
- // sequence: ["page view", "view item", "add to cart", "add to cart", "checkout"],
150
- // weight: 3,
151
- // isFirstFunnel: false,
152
- // order: "sequential",
153
- // conversionRate: 70,
154
- // timeToConvert: 7 * 24,
155
- // props: {
156
- // variants: ["A", "B", "C", "Control"],
157
- // flows: ["new", "existing", "loyal", "churned"],
158
- // flags: ["on", "off"],
159
- // experiment_ids: ["1234", "5678", "9012", "3456", "7890"],
160
- // multiVariate: [true, false]
161
-
162
- // }
163
- // },
164
- // {
165
- // timeToConvert: 2,
166
- // conversionRate: 66,
167
- // sequence: ["foo", "bar", "baz", "qux"],
168
- // }, {
169
- // weight: 4,
170
- // sequence: ["video", "video", "attack", "defend", "click"],
171
- // }
172
- ],
173
- superProps: {
174
- platform: ["web", "mobile", "web", "mobile", "web", "web", "kiosk", "smartTV"],
175
- currentTheme: ["light", "dark", "custom", "light", "dark"],
176
- // emotions: generateEmoji(),
177
-
178
- },
179
- /*
180
- user properties work the same as event properties
181
- each key should be an array or function reference
182
- */
183
- userProps: {
184
- title: chance.profession.bind(chance),
185
- luckyNumber: weighNumRange(42, 420),
186
- spiritAnimal: ["duck", "dog", "otter", "penguin", "cat", "elephant", "lion", "cheetah", "giraffe", "zebra", "rhino", "hippo", "whale", "dolphin", "shark", "octopus", "squid", "jellyfish", "starfish", "seahorse", "crab", "lobster", "shrimp", "clam", "snail", "slug", "butterfly", "moth", "bee", "wasp", "ant", "beetle", "ladybug", "caterpillar", "centipede", "millipede", "scorpion", "spider", "tarantula", "tick", "mite", "mosquito", "fly", "dragonfly", "damselfly", "grasshopper", "cricket", "locust", "mantis", "cockroach", "termite", "praying mantis", "walking stick", "stick bug", "leaf insect", "lacewing", "aphid", "cicada", "thrips", "psyllid", "scale insect", "whitefly", "mealybug", "planthopper", "leafhopper", "treehopper", "flea", "louse", "bedbug", "flea beetle", "weevil", "longhorn beetle", "leaf beetle", "tiger beetle", "ground beetle", "lady beetle", "firefly", "click beetle", "rove beetle", "scarab beetle", "dung beetle", "stag beetle", "rhinoceros beetle", "hercules beetle", "goliath beetle", "jewel beetle", "tortoise beetle"]
187
- },
188
-
189
- scdProps: {
190
-
191
- },
192
- mirrorProps: {
193
- isBot: { events: "*", values: [false, false, false, false, true] },
194
- profit: { events: ["checkout"], values: [4, 2, 42] },
195
- watchTimeSec: {
196
- events: ["watch video"],
197
- values: weighNumRange(50, 1200, 6)
198
- }
199
-
200
- },
201
-
202
- /*
203
- for group analytics keys, we need an array of arrays [[],[],[]]
204
- each pair represents a group_key and the number of profiles for that key
205
- */
206
- groupKeys: [
207
- ["company_id", 5000],
208
- ["team_id", 500],
209
- ["department_id", 50]
210
- ],
211
- groupProps: {},
212
- lookupTables: [],
213
- hook: function (record, type, meta) {
214
- return record;
215
- }
216
- };
217
-
218
-
219
-
220
- module.exports = config;
@@ -1,323 +0,0 @@
1
-
2
- const SEED = "my-seed";
3
- const dayjs = require("dayjs");
4
- const utc = require("dayjs/plugin/utc");
5
- dayjs.extend(utc);
6
- require("dotenv").config();
7
- const u = require("../components/utils.js");
8
- const v = require("ak-tools");
9
- const chance = u.initChance(SEED);
10
- const num_users = 10_000;
11
- const days = 108;
12
-
13
- /** @typedef {import("../types.js").Dungeon} Config */
14
-
15
- /** @type {Config} */
16
- const config = {
17
- token: "",
18
- seed: "twerk",
19
- numDays: days,
20
- numEvents: num_users * 100,
21
- numUsers: num_users,
22
- hasAnonIds: false,
23
- hasSessionIds: false,
24
- format: "json",
25
- alsoInferFunnels: false,
26
- hasLocation: true,
27
- hasAndroidDevices: true,
28
- hasIOSDevices: true,
29
- hasDesktopDevices: true,
30
- hasBrowser: false,
31
- hasCampaigns: false,
32
- isAnonymous: false,
33
- hasAdSpend: false,
34
- percentUsersBornInDataset: 35,
35
-
36
- hasAvatar: true,
37
- makeChart: false,
38
-
39
- batchSize: 1_500_000,
40
- concurrency: 1,
41
- writeToDisk: false,
42
- funnels: [
43
- {
44
- "sequence": ["app install", "character creation", "join party"],
45
- "isFirstFunnel": true,
46
- "conversionRate": 0.8,
47
- "timeToConvert": .25,
48
- },
49
- {
50
- "sequence": ["start quest", "gameplay summary", "complete quest"],
51
- conversionRate: 0.99,
52
- timeToConvert: 1,
53
- props: {
54
- "quest type": u.pickAWinner([
55
- "Rescue",
56
- "Retrieve",
57
- "Explore",
58
- "Destroy",
59
- "Investigate",
60
- ]),
61
- "quest difficulty": u.pickAWinner([
62
- "Easy",
63
- "Medium",
64
- "Hard",
65
- "Legendary",
66
- ]),
67
- "quest location": u.pickAWinner([
68
- "Forest",
69
- "Dungeon",
70
- "Mountain",
71
- "City",
72
- "Desert",
73
- ])
74
- }
75
- },
76
- ],
77
- events: [
78
- { event: "app install", weight: 10, isFirstEvent: true },
79
- {
80
- event: "character creation",
81
- weight: 2,
82
- properties: {
83
- mode: u.pickAWinner(["fast", "slow", "template"]),
84
- },
85
- },
86
- {
87
- event: "join party",
88
- weight: 8,
89
- properties: {
90
- "party size": u.weighNumRange(1, 6),
91
- "party leader": u.pickAWinner([
92
- "Bard",
93
- "Cleric",
94
- "Fighter",
95
- "Rogue",
96
- "Wizard",
97
- "Paladin",
98
- "Ranger",
99
- "Sorcerer",
100
- "Warlock",
101
- ]),
102
- },
103
- },
104
- {
105
- event: "start quest",
106
- weight: 12,
107
- properties: {},
108
- },
109
- {
110
- event: "complete quest",
111
- weight: 12,
112
- properties: {},
113
- },
114
- {
115
- "event": "gameplay summary",
116
- "weight": 14,
117
- "properties": {
118
- "# enemies defeated": u.weighNumRange(0, 100),
119
- "# respawns": u.weighNumRange(0, 10, 5),
120
- "# attacks": u.weighNumRange(0, 100, 6, 12),
121
- "# gold found": u.weighNumRange(0, 1000),
122
- }
123
- },
124
- {
125
- "event": "in-game purchase",
126
- "weight": 2,
127
- "properties": {
128
- "purchase type": u.pickAWinner([
129
- "Gold",
130
- "Gems",
131
- "Items: Weapons",
132
- "Items: Armor",
133
- "Items: Potions",
134
- "Items: Scrolls",
135
- "Boosts",
136
- "Currency",
137
- ]),
138
- "purchase amount": u.weighNumRange(1, 50, 1, 20),
139
- }
140
- },
141
- {
142
- event: "fight boss",
143
- weight: 3,
144
- properties: {
145
- "boss type": u.pickAWinner([
146
- "Dragon",
147
- "Demon",
148
- "Lich",
149
- "Vampire",
150
- "Beholder",
151
- ]),
152
- "boss level": u.weighNumRange(10, 20),
153
- "boss difficulty": u.pickAWinner([
154
- "Hard",
155
- "Legendary",
156
- "Impossible",
157
- ]),
158
- "fight duration (mins)": u.weighNumRange(1, 60),
159
-
160
- },
161
- },
162
- {
163
- event: "level up",
164
- weight: 1,
165
- properties: {
166
- "new abilities": u.pickAWinner([
167
- "Attack",
168
- "Spell",
169
- "Feat",
170
- "Skill",
171
- ]),
172
- },
173
- },
174
- // {
175
- // event: "generic event (common)",
176
- // weight: 5,
177
- // properties: {
178
- // generic_prop: u.pickAWinner(["foo", "bar", "baz", "qux"]),
179
- // }
180
- // },
181
- {
182
- event: "$experiment_started",
183
- weight: 3,
184
- properties: {
185
- "Experiment name": u.pickAWinner([
186
- "fast leveling",
187
- "tension economy",
188
- "free trial",
189
- ]),
190
- "Variant": ["A", "B", "C", "Control"],
191
- }
192
- },
193
- ],
194
- superProps: {
195
- platform: u.pickAWinner([
196
- "Mobile",
197
- "Xbox",
198
- "Playstation",
199
- "Switch",
200
- "Web"
201
- ]),
202
- "game mode": u.pickAWinner([
203
- "Single Player",
204
- "Multiplayer",
205
- ], 1),
206
- language: u.pickAWinner([
207
- "English",
208
- "Spanish",
209
- "French",
210
- "German",
211
- "Japanese",
212
- "Korean",
213
- "Chinese",
214
- ], 0),
215
-
216
- },
217
- scdProps: {
218
- // "subscription MRR" : {
219
- // "frequency": "week",
220
- // "type": "number",
221
- // values: u.weighNumRange(0, 250, 1, 200),
222
- // timing: "fixed",
223
- // max: 250,
224
- // }
225
- },
226
- userProps: {
227
-
228
- race: u.pickAWinner([
229
- "Human",
230
- "Elf",
231
- "Dwarf",
232
- "Halfling",
233
- "Dragonborn",
234
- "Gnome",
235
- "Half-Elf",
236
- "Half-Orc",
237
- "Tiefling",
238
- ]),
239
- class: u.pickAWinner([
240
- "Barbarian",
241
- "Bard",
242
- "Cleric",
243
- "Druid",
244
- "Fighter",
245
- "Monk",
246
- "Paladin",
247
- "Ranger",
248
- "Rogue",
249
- "Sorcerer",
250
- "Warlock",
251
- "Wizard",
252
- ]),
253
- alignment: u.pickAWinner([
254
- "Lawful Good",
255
- "Neutral Good",
256
- "Chaotic Good",
257
- "Lawful Neutral",
258
- "True Neutral",
259
- "Chaotic Neutral",
260
- "Lawful Evil",
261
- "Neutral Evil",
262
- "Chaotic Evil",
263
- ]),
264
- level: u.weighNumRange(1, 20),
265
- background: u.pickAWinner([
266
- "Acolyte",
267
- "Charlatan",
268
- "Criminal",
269
- "Entertainer",
270
- "Folk Hero",
271
- "Guild Artisan",
272
- "Hermit",
273
- "Noble",
274
- "Outlander",
275
- "Sage",
276
- "Sailor",
277
- "Soldier",
278
- "Urchin",
279
- ]),
280
- "subscription MRR": u.weighNumRange(0, 250, 1, 200)
281
- },
282
- hook: function (record, type, meta) {
283
- // const NOW = dayjs();
284
-
285
- if (type === "event") {
286
- // const EVENT_TIME = dayjs(record.time);
287
- }
288
-
289
- if (type === "user") {
290
-
291
- }
292
-
293
- if (type === "funnel-post") {
294
-
295
- }
296
-
297
- if (type === "funnel-pre") {
298
- const sequence = v.clone(record.sequence);
299
- if (sequence.includes("$experiment_started")) {
300
- //ensure there's only one experiment per user flow
301
- const newSequence = sequence.filter((event) => event !== "$experiment_started");
302
-
303
- newSequence.unshift("$experiment_started");
304
-
305
-
306
- record.sequence = newSequence;
307
- }
308
-
309
- }
310
-
311
- if (type === "scd") {
312
-
313
- }
314
-
315
- if (type === "everything") {
316
-
317
- }
318
-
319
- return record;
320
- }
321
- };
322
-
323
- module.exports = config;