make-mp-data 2.0.1 → 2.0.2

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 (64) hide show
  1. package/dungeons/adspend.js +96 -0
  2. package/dungeons/anon.js +104 -0
  3. package/dungeons/big.js +225 -0
  4. package/dungeons/business.js +345 -0
  5. package/dungeons/complex.js +396 -0
  6. package/dungeons/experiments.js +125 -0
  7. package/dungeons/foobar.js +241 -0
  8. package/dungeons/funnels.js +272 -0
  9. package/dungeons/gaming.js +315 -0
  10. package/dungeons/media.js +7 -7
  11. package/dungeons/mirror.js +129 -0
  12. package/dungeons/sanity.js +113 -0
  13. package/dungeons/scd.js +205 -0
  14. package/dungeons/simple.js +195 -0
  15. package/dungeons/userAgent.js +190 -0
  16. package/entry.js +57 -0
  17. package/index.js +96 -68
  18. package/lib/cli/cli.js +5 -4
  19. package/lib/core/config-validator.js +28 -12
  20. package/lib/core/context.js +147 -130
  21. package/lib/core/storage.js +45 -31
  22. package/lib/data/defaults.js +2 -2
  23. package/lib/generators/adspend.js +1 -2
  24. package/lib/generators/events.js +35 -24
  25. package/lib/generators/funnels.js +1 -2
  26. package/lib/generators/mirror.js +1 -2
  27. package/lib/orchestrators/mixpanel-sender.js +15 -7
  28. package/lib/orchestrators/user-loop.js +21 -10
  29. package/lib/orchestrators/worker-manager.js +5 -2
  30. package/lib/utils/ai.js +36 -63
  31. package/lib/utils/chart.js +5 -0
  32. package/lib/utils/instructions.txt +593 -0
  33. package/lib/utils/utils.js +162 -38
  34. package/package.json +23 -9
  35. package/types.d.ts +376 -376
  36. package/.claude/settings.local.json +0 -21
  37. package/.gcloudignore +0 -18
  38. package/.gitattributes +0 -2
  39. package/.prettierrc +0 -0
  40. package/.vscode/launch.json +0 -80
  41. package/.vscode/settings.json +0 -69
  42. package/.vscode/tasks.json +0 -12
  43. package/dungeons/customers/.gitkeep +0 -0
  44. package/env.yaml +0 -1
  45. package/lib/cloud-function.js +0 -20
  46. package/scratch.mjs +0 -62
  47. package/scripts/dana.mjs +0 -137
  48. package/scripts/deploy.sh +0 -15
  49. package/scripts/jsdoctest.js +0 -5
  50. package/scripts/new-dungeon.sh +0 -98
  51. package/scripts/new-project.mjs +0 -14
  52. package/scripts/run-index.sh +0 -2
  53. package/scripts/update-deps.sh +0 -5
  54. package/tests/benchmark/concurrency.mjs +0 -52
  55. package/tests/cli.test.js +0 -124
  56. package/tests/coverage/.gitkeep +0 -0
  57. package/tests/e2e.test.js +0 -379
  58. package/tests/int.test.js +0 -715
  59. package/tests/testCases.mjs +0 -229
  60. package/tests/testSoup.mjs +0 -28
  61. package/tests/unit.test.js +0 -910
  62. package/tmp/.gitkeep +0 -0
  63. package/tsconfig.json +0 -18
  64. package/vitest.config.js +0 -47
@@ -0,0 +1,396 @@
1
+ /**
2
+ * This is the default configuration file for the data generator in COMPLEX 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
+ import Chance from 'chance';
10
+ const chance = new Chance();
11
+ import { weighNumRange, date, integer } from '../lib/utils/utils.js';
12
+ import * as u from 'ak-tools';
13
+
14
+ /** @type {import('../types.js').Dungeon} */
15
+ const config = {
16
+ token: "",
17
+ seed: "quite complexus",
18
+ numDays: 30, //how many days worth of data
19
+ numEvents: 100_000, //how many events
20
+ numUsers: 1000, //how many users
21
+ format: 'json', //csv or json
22
+ region: "US",
23
+ hasAnonIds: true, //if true, anonymousIds are created for each user
24
+ hasSessionIds: true, //if true, hasSessionIds are created for each user
25
+
26
+ hasLocation: true,
27
+ hasAndroidDevices: true,
28
+ hasIOSDevices: true,
29
+ hasDesktopDevices: true,
30
+ hasBrowser: true,
31
+ hasCampaigns: true,
32
+ isAnonymous: false,
33
+ hasAdSpend: true,
34
+
35
+ hasAvatar: true,
36
+ makeChart: false,
37
+
38
+ batchSize: 500_000,
39
+ concurrency: 10,
40
+
41
+ funnels: [],
42
+ events: [
43
+ {
44
+ "event": "checkout",
45
+ "weight": 2,
46
+ "properties": {
47
+ amount: weighNumRange(5, 500, .25),
48
+ currency: ["USD", "USD", "USD", "CAD", "EUR", "EUR", "BTC", "BTC", "ETH", "JPY"],
49
+ cart: makeProducts(12),
50
+ }
51
+ },
52
+ {
53
+ "event": "add to cart",
54
+ "weight": 4,
55
+ "properties": {
56
+ amount: weighNumRange(5, 500, .25),
57
+ qty: integer(1, 5),
58
+ product_id: weighNumRange(1, 1000, 1.4)
59
+ }
60
+ },
61
+ {
62
+ "event": "page view",
63
+ "weight": 10,
64
+ "properties": {
65
+ page: ["/", "/", "/", "/learn-more", "/pricing", "/contact", "/about", "/careers", "/sign-up", "/login", "/app", "/app", "/app", "/app"],
66
+ utm_source: ["$organic", "$organic", "$organic", "$organic", "google", "google", "google", "facebook", "facebook", "twitter", "linkedin"],
67
+ }
68
+ },
69
+ {
70
+ "event": "watch video",
71
+ "weight": 8,
72
+ "properties": {
73
+ category: ["funny", "educational", "inspirational", "music", "news", "sports", "cooking", "DIY", "travel", "gaming"],
74
+ hashTags: makeHashTags,
75
+ watchTimeSec: weighNumRange(10, 600, .25,),
76
+ quality: ["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p"],
77
+ format: ["mp4", "avi", "mov", "mpg"],
78
+ video_id: weighNumRange(1, 50000, 1.4),
79
+
80
+ }
81
+ },
82
+ {
83
+ "event": "comment",
84
+ "weight": 2,
85
+ "properties": {
86
+ length: weighNumRange(1, 500, .25),
87
+ video_id: weighNumRange(1, 50000, 1.4),
88
+ has_replies: [true, false, false, false, false],
89
+ has_photo: [true, false, false, false, false],
90
+
91
+ }
92
+ },
93
+ {
94
+ "event": "save video",
95
+ "weight": 4,
96
+ "properties": {
97
+ video_id: weighNumRange(1, 50000, 1.4),
98
+ ui_control: ["toolbar", "menu", "keyboard"]
99
+
100
+
101
+ }
102
+ },
103
+ {
104
+ "event": "view item",
105
+ "weight": 8,
106
+ "properties": {
107
+ product_id: weighNumRange(1, 24, 3),
108
+ colors: ["light", "dark", "custom", "dark"]
109
+ }
110
+ },
111
+ {
112
+ "event": "save item",
113
+ "weight": 5,
114
+ "properties": {
115
+ product_id: weighNumRange(1, 1000, 12),
116
+ colors: ["light", "dark", "custom", "dark"]
117
+ }
118
+ },
119
+ {
120
+ "event": "support ticket",
121
+ "weight": 2,
122
+ "properties": {
123
+ product_id: weighNumRange(1, 1000, .6),
124
+ description: chance.sentence.bind(chance),
125
+ severity: ["low", "medium", "high"],
126
+ ticket_id: chance.guid.bind(chance)
127
+ }
128
+ },
129
+ {
130
+ "event": "sign up",
131
+ "isFirstEvent": true,
132
+ "weight": 0,
133
+ "properties": {
134
+ plan: ["free", "free", "free", "free", "basic", "basic", "basic", "premium", "premium", "enterprise"],
135
+ dateOfRenewal: date(100, false),
136
+ codewords: u.makeName,
137
+ }
138
+ }
139
+ ],
140
+ superProps: {
141
+ linked_device: deviceAttributes()
142
+ // emotions: generateEmoji(),
143
+
144
+ },
145
+ /*
146
+ user properties work the same as event properties
147
+ each key should be an array or function reference
148
+ */
149
+ userProps: {
150
+ title: chance.profession.bind(chance),
151
+ luckyNumber: weighNumRange(42, 420),
152
+ experiment: designExperiment(),
153
+ spiritAnimal: ["unicorn", "dragon", "phoenix", "sasquatch", "yeti", "kraken", "jackalope", "thunderbird", "mothman", "nessie", "chupacabra", "jersey devil", "bigfoot", "weindgo", "bunyip", "mokele-mbembe", "tatzelwurm", "megalodon"],
154
+ timezone: chance.timezone.bind(chance), // ["America/New_York", "America/Los_Angeles", "America/Chicago", "America/Denver", "America/Phoenix", "America/Anchorage", "Pacific/Honolulu"]
155
+ ip: chance.ip.bind(chance),
156
+ lastCart: makeProducts(5),
157
+
158
+ },
159
+
160
+ /** each generates it's own table */
161
+ scdProps: {
162
+ role: {
163
+ type: "user",
164
+ frequency: "week",
165
+ values: ["admin", "collaborator", "user", "view only", "no access"],
166
+ timing: 'fuzzy',
167
+ max: 10
168
+ },
169
+ NPS: {
170
+ type: "user",
171
+ frequency: "day",
172
+ values: weighNumRange(1, 10, 2, 150),
173
+ timing: 'fuzzy',
174
+ max: 10
175
+ },
176
+ MRR: {
177
+ type: "company_id",
178
+ frequency: "month",
179
+ values: weighNumRange(0, 10000, .15),
180
+ timing: 'fixed',
181
+ max: 10
182
+ },
183
+ AccountHealthScore: {
184
+ type: "company_id",
185
+ frequency: "week",
186
+ values: weighNumRange(1, 10, .15),
187
+ timing: 'fixed',
188
+ max: 40
189
+ },
190
+ plan: {
191
+ type: "company_id",
192
+ frequency: "month",
193
+ values: ["free", "basic", "premium", "enterprise"],
194
+ timing: 'fixed',
195
+ max: 10
196
+ }
197
+ },
198
+
199
+ mirrorProps: {
200
+ isBot: { events: "*", values: [false, false, false, false, true] },
201
+ profit: { events: ["checkout"], values: [4, 2, 42, 420] },
202
+ watchTimeSec: {
203
+ events: ["watch video"],
204
+ values: weighNumRange(50, 1200, 2)
205
+ }
206
+ },
207
+
208
+ /*
209
+ for group analytics keys, we need an array of arrays [[],[],[]]
210
+ each pair represents a group_key and the number of profiles for that key
211
+ */
212
+ groupKeys: [
213
+ ['company_id', 500, []],
214
+ ['room_id', 10000, ["save video", "comment", "watch video"]],
215
+
216
+ ],
217
+ groupProps: {
218
+ company_id: {
219
+ name: () => { return chance.company(); },
220
+ email: () => { return `CSM: ${chance.pickone(["AK", "Jessica", "Michelle", "Dana", "Brian", "Dave"])}`; },
221
+ "# of employees": weighNumRange(3, 10000),
222
+ "industry": ["tech", "finance", "healthcare", "education", "government", "non-profit"],
223
+ "segment": ["enterprise", "SMB", "mid-market"],
224
+ "products": [["core"], ["core"], ["core", "add-ons"], ["core", "pro-serve"], ["core", "add-ons", "pro-serve"], ["core", "BAA", "enterprise"], ["free"], ["free"], ["free", "addons"]],
225
+ },
226
+ room_id: {
227
+ name: () => { return `#${chance.word({ length: integer(4, 24), capitalize: true })}`; },
228
+ email: ["public", "private"],
229
+ "room provider": ["partner", "core", "core", "core"],
230
+ "room capacity": weighNumRange(3, 1000000),
231
+ "isPublic": [true, false, false, false, false],
232
+ "country": chance.country.bind(chance),
233
+ "isVerified": [true, true, false, false, false],
234
+ }
235
+ },
236
+ groupEvents: [{
237
+ attribute_to_user: false,
238
+ event: "card charged",
239
+ weight: 1,
240
+ frequency: 30,
241
+ group_key: "company_id",
242
+ group_size: 500,
243
+ properties: {
244
+ amount: weighNumRange(5, 500, .25),
245
+ currency: ["USD", "USD", "USD", "CAD", "EUR", "EUR", "BTC", "BTC", "ETH", "JPY"],
246
+ plan: ["basic", "premium", "enterprise"],
247
+ "payment method": []
248
+ }
249
+ }],
250
+
251
+ lookupTables: [
252
+ {
253
+ key: "product_id",
254
+ entries: 1000,
255
+ attributes: {
256
+ category: [
257
+ "Books", "Movies", "Music", "Games", "Electronics", "Computers", "Smart Home", "Home", "Garden & Tools", "Pet Supplies", "Food & Grocery", "Beauty", "Health", "Toys", "Kids", "Baby", "Handmade", "Sports", "Outdoors", "Automotive", "Industrial", "Entertainment", "Art"
258
+ ],
259
+ "demand": ["high", "medium", "medium", "low"],
260
+ "supply": ["high", "medium", "medium", "low"],
261
+ "manufacturer": chance.company.bind(chance),
262
+ "price": weighNumRange(5, 500, .25),
263
+ "rating": weighNumRange(1, 5),
264
+ "reviews": weighNumRange(0, 35)
265
+ }
266
+
267
+ },
268
+ {
269
+ key: "video_id",
270
+ entries: 50000,
271
+ attributes: {
272
+ isFlagged: [true, false, false, false, false],
273
+ copyright: ["all rights reserved", "creative commons", "creative commons", "public domain", "fair use"],
274
+ uploader_id: chance.guid.bind(chance),
275
+ "uploader influence": ["low", "low", "low", "medium", "medium", "high"],
276
+ thumbs: weighNumRange(0, 35),
277
+ rating: ["G", "PG", "PG-13", "R", "NC-17", "PG-13", "R", "NC-17", "R", "PG", "PG"]
278
+ }
279
+
280
+ }
281
+ ],
282
+
283
+ hook: function (record, type, meta) {
284
+ return record;
285
+ }
286
+ };
287
+
288
+
289
+
290
+ function makeHashTags() {
291
+ const possibleHashtags = [];
292
+ for (let i = 0; i < 20; i++) {
293
+ possibleHashtags.push('#' + u.makeName(2, ''));
294
+ }
295
+
296
+ const numHashtags = integer(integer(1, 5), integer(5, 10));
297
+ const hashtags = [];
298
+ for (let i = 0; i < numHashtags; i++) {
299
+ hashtags.push(chance.pickone(possibleHashtags));
300
+ }
301
+ return [hashtags];
302
+ };
303
+
304
+ function makeProducts(maxItems = 10) {
305
+
306
+ return function () {
307
+ const categories = ["Device Accessories", "eBooks", "Automotive", "Baby Products", "Beauty", "Books", "Camera & Photo", "Cell Phones & Accessories", "Collectible Coins", "Consumer Electronics", "Entertainment Collectibles", "Fine Art", "Grocery & Gourmet Food", "Health & Personal Care", "Home & Garden", "Independent Design", "Industrial & Scientific", "Accessories", "Major Appliances", "Music", "Musical Instruments", "Office Products", "Outdoors", "Personal Computers", "Pet Supplies", "Software", "Sports", "Sports Collectibles", "Tools & Home Improvement", "Toys & Games", "Video, DVD & Blu-ray", "Video Games", "Watches"];
308
+ const slugs = ['/sale/', '/featured/', '/home/', '/search/', '/wishlist/', '/'];
309
+ const assetExtension = ['.png', '.jpg', '.jpeg', '.heic', '.mp4', '.mov', '.avi'];
310
+ const data = [];
311
+ const numOfItems = integer(1, 12);
312
+
313
+ for (var i = 0; i < numOfItems; i++) {
314
+ const category = chance.pickone(categories);
315
+ const slug = chance.pickone(slugs);
316
+ const asset = chance.pickone(assetExtension);
317
+ const product_id = chance.guid();
318
+ const price = integer(1, 300);
319
+ const quantity = integer(1, 5);
320
+
321
+ const item = {
322
+ product_id: product_id,
323
+ sku: integer(11111, 99999),
324
+ amount: price,
325
+ quantity: quantity,
326
+ value: price * quantity,
327
+ featured: chance.pickone([true, false]),
328
+ category: category,
329
+ urlSlug: slug + category,
330
+ asset: `${category}-${integer(1, 20)}${asset}`
331
+ };
332
+
333
+ data.push(item);
334
+ }
335
+
336
+ return () => [data];
337
+ };
338
+ };
339
+
340
+
341
+ function designExperiment() {
342
+ return function () {
343
+ const variants = ["A", "B", "C", "Control"];
344
+ const variant = chance.pickone(variants);
345
+ const experiments = ["no password", "social sign in", "new tutorial", "new search"];
346
+ const experiment = chance.pickone(experiments);
347
+ const multi_variates = ["A/B", "A/B/C", "A/B/C/D", "Control"];
348
+ const multi_variate = chance.pickone(multi_variates);
349
+ const impression_id = chance.guid();
350
+
351
+
352
+
353
+ const chosen = {
354
+ variant,
355
+ experiment,
356
+ multi_variate,
357
+ impression_id
358
+ };
359
+
360
+ return [chosen];
361
+ };
362
+ }
363
+
364
+ function deviceAttributes(isMobile = false) {
365
+ return function () {
366
+ let devices = ["desktop", "laptop", "desktop", "laptop", "desktop", "laptop", "other"];
367
+ if (isMobile) devices = [...devices, "mobile", "mobile", "mobile", "tablet"];
368
+ const device = chance.pickone(devices);
369
+ let oses = ["Windows", "macOS", "Windows", "macOS", "macOS", "Linux", "Windows", "macOS", "Windows", "macOS", "macOS", "TempleOS"];
370
+ if (isMobile) oses = [...oses, "iOS", "Android", "iOS", "Android"];
371
+ const os = chance.pickone(oses);
372
+ const browser = chance.pickone(["Chrome", "Firefox", "Safari", "Edge", "Opera", "IE", "Brave", "Vivaldi"]);
373
+ const version = chance.integer({ min: 1, max: 15 });
374
+ const resolution = chance.pickone(["1920x1080", "1280x720", "1024x768", "800x600", "640x480"]);
375
+ const language = chance.pickone(["en-US", "en-US", "en-US", "en-GB", "es", "es", "fr", "de", "it", "ja", "zh", "ru"]);
376
+
377
+ const chosen = {
378
+ platform: device,
379
+ os,
380
+ browser,
381
+ version,
382
+ resolution,
383
+ language
384
+ };
385
+
386
+ return chosen;
387
+
388
+ };
389
+ }
390
+
391
+
392
+
393
+
394
+
395
+
396
+ export default config;
@@ -0,0 +1,125 @@
1
+
2
+ import dayjs from 'dayjs';
3
+ import utc from 'dayjs/plugin/utc';
4
+ import 'dotenv/config';
5
+ import * as u from '../lib/utils/utils.js';
6
+ import * as v from 'ak-tools';
7
+
8
+ const SEED = "my-seed";
9
+ dayjs.extend(utc);
10
+ const chance = u.initChance(SEED);
11
+ const num_users = 5_000;
12
+ const days = 100;
13
+
14
+ /** @typedef {import("../types.js").Dungeon} Config */
15
+
16
+ /** @type {Config} */
17
+ const config = {
18
+ token: "",
19
+ seed: SEED,
20
+ numDays: days,
21
+ numEvents: num_users * 100,
22
+ numUsers: num_users,
23
+ hasAnonIds: false,
24
+ hasSessionIds: false,
25
+ format: "json",
26
+ alsoInferFunnels: true,
27
+ hasLocation: true,
28
+ hasAndroidDevices: true,
29
+ hasIOSDevices: true,
30
+ hasDesktopDevices: true,
31
+ hasBrowser: true,
32
+ hasCampaigns: true,
33
+ isAnonymous: false,
34
+ hasAdSpend: false,
35
+
36
+ hasAvatar: true,
37
+ makeChart: false,
38
+
39
+
40
+ batchSize: 1_500_000,
41
+ concurrency: 1,
42
+ writeToDisk: false,
43
+
44
+ funnels: [],
45
+ events: [
46
+ {
47
+ event: "$experiment_started",
48
+ weight: 5,
49
+ isSessionStartEvent: true,
50
+ properties: {
51
+ "$experiment_type": "all_my_own",
52
+ "Experiment name": "name of experiment",
53
+ "Variant name": ["variant 1", "variant 2", "variant 3", "control"],
54
+ }
55
+ },
56
+ {
57
+ event: "super common event",
58
+ weight: 50,
59
+ properties: {
60
+ "foo": u.pickAWinner(["bar", "baz", "qux"], 0),
61
+ }
62
+ },
63
+ {
64
+ event: "less common event",
65
+ weight: 20,
66
+ properties: {
67
+ "hello": u.pickAWinner(["world", "universe", "galaxy"], 0),
68
+ }
69
+ },
70
+ {
71
+ event: "rare event",
72
+ weight: 5,
73
+ properties: {
74
+ "goodbye": u.pickAWinner(["cruel world", "universe", "galaxy"], 0),
75
+ }
76
+ },
77
+ {
78
+ event: "money event",
79
+ weight: 10,
80
+ properties: {
81
+ "amount": u.weighNumRange(5, 500, .25),
82
+ "currency": u.pickAWinner(["USD", "CAD", "EUR", "BTC", "ETH", "JPY"], 0),
83
+ "numItems": u.weighNumRange(1, 10),
84
+ }
85
+ }
86
+ ],
87
+ superProps: {},
88
+ userProps: {},
89
+ scdProps: {},
90
+ mirrorProps: {},
91
+ groupKeys: [],
92
+ groupProps: {},
93
+ lookupTables: [],
94
+ hook: function (record, type, meta) {
95
+ const NOW = dayjs();
96
+
97
+ if (type === "event") {
98
+ const EVENT_TIME = dayjs(record.time);
99
+ }
100
+
101
+ if (type === "user") {
102
+
103
+ }
104
+
105
+ if (type === "funnel-post") {
106
+
107
+ }
108
+
109
+ if (type === "funnel-pre") {
110
+
111
+ }
112
+
113
+ if (type === "scd") {
114
+
115
+ }
116
+
117
+ if (type === "everything") {
118
+
119
+ }
120
+
121
+ return record;
122
+ }
123
+ };
124
+
125
+ export default config;