make-mp-data 2.0.1 → 2.0.12

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 (44) hide show
  1. package/dungeons/adspend.js +96 -0
  2. package/dungeons/anon.js +104 -0
  3. package/dungeons/big.js +224 -0
  4. package/dungeons/business.js +327 -0
  5. package/dungeons/complex.js +396 -0
  6. package/dungeons/experiments.js +124 -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/mirror.js +129 -0
  11. package/dungeons/sanity.js +118 -0
  12. package/dungeons/scd.js +205 -0
  13. package/dungeons/simple.js +150 -0
  14. package/dungeons/userAgent.js +190 -0
  15. package/index.js +5 -1
  16. package/package.json +10 -1
  17. package/.claude/settings.local.json +0 -21
  18. package/.gcloudignore +0 -18
  19. package/.gitattributes +0 -2
  20. package/.prettierrc +0 -0
  21. package/.vscode/launch.json +0 -80
  22. package/.vscode/settings.json +0 -69
  23. package/.vscode/tasks.json +0 -12
  24. package/dungeons/customers/.gitkeep +0 -0
  25. package/env.yaml +0 -1
  26. package/scratch.mjs +0 -62
  27. package/scripts/dana.mjs +0 -137
  28. package/scripts/deploy.sh +0 -15
  29. package/scripts/jsdoctest.js +0 -5
  30. package/scripts/new-dungeon.sh +0 -98
  31. package/scripts/new-project.mjs +0 -14
  32. package/scripts/run-index.sh +0 -2
  33. package/scripts/update-deps.sh +0 -5
  34. package/tests/benchmark/concurrency.mjs +0 -52
  35. package/tests/cli.test.js +0 -124
  36. package/tests/coverage/.gitkeep +0 -0
  37. package/tests/e2e.test.js +0 -379
  38. package/tests/int.test.js +0 -715
  39. package/tests/testCases.mjs +0 -229
  40. package/tests/testSoup.mjs +0 -28
  41. package/tests/unit.test.js +0 -910
  42. package/tmp/.gitkeep +0 -0
  43. package/tsconfig.json +0 -18
  44. 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: 500,
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,124 @@
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");
8
+ const v = require("ak-tools");
9
+ const chance = u.initChance(SEED);
10
+ const num_users = 5_000;
11
+ const days = 100;
12
+
13
+ /** @typedef {import("../types").Dungeon} Config */
14
+
15
+ /** @type {Config} */
16
+ const config = {
17
+ token: "",
18
+ seed: SEED,
19
+ numDays: days,
20
+ numEvents: num_users * 100,
21
+ numUsers: num_users,
22
+ hasAnonIds: false,
23
+ hasSessionIds: false,
24
+ format: "json",
25
+ alsoInferFunnels: true,
26
+ hasLocation: true,
27
+ hasAndroidDevices: true,
28
+ hasIOSDevices: true,
29
+ hasDesktopDevices: true,
30
+ hasBrowser: true,
31
+ hasCampaigns: true,
32
+ isAnonymous: false,
33
+ hasAdSpend: false,
34
+
35
+ hasAvatar: true,
36
+ makeChart: false,
37
+
38
+
39
+ batchSize: 1_500_000,
40
+ concurrency: 1,
41
+ writeToDisk: false,
42
+
43
+ funnels: [],
44
+ events: [
45
+ {
46
+ event: "$experiment_started",
47
+ weight: 5,
48
+ isSessionStartEvent: true,
49
+ properties: {
50
+ "$experiment_type": "all_my_own",
51
+ "Experiment name": "name of experiment",
52
+ "Variant name": ["variant 1", "variant 2", "variant 3", "control"],
53
+ }
54
+ },
55
+ {
56
+ event: "super common event",
57
+ weight: 50,
58
+ properties: {
59
+ "foo": u.pickAWinner(["bar", "baz", "qux"], 0),
60
+ }
61
+ },
62
+ {
63
+ event: "less common event",
64
+ weight: 20,
65
+ properties: {
66
+ "hello": u.pickAWinner(["world", "universe", "galaxy"], 0),
67
+ }
68
+ },
69
+ {
70
+ event: "rare event",
71
+ weight: 5,
72
+ properties: {
73
+ "goodbye": u.pickAWinner(["cruel world", "universe", "galaxy"], 0),
74
+ }
75
+ },
76
+ {
77
+ event: "money event",
78
+ weight: 10,
79
+ properties: {
80
+ "amount": u.weighNumRange(5, 500, .25),
81
+ "currency": u.pickAWinner(["USD", "CAD", "EUR", "BTC", "ETH", "JPY"], 0),
82
+ "numItems": u.weighNumRange(1, 10),
83
+ }
84
+ }
85
+ ],
86
+ superProps: {},
87
+ userProps: {},
88
+ scdProps: {},
89
+ mirrorProps: {},
90
+ groupKeys: [],
91
+ groupProps: {},
92
+ lookupTables: [],
93
+ hook: function (record, type, meta) {
94
+ const NOW = dayjs();
95
+
96
+ if (type === "event") {
97
+ const EVENT_TIME = dayjs(record.time);
98
+ }
99
+
100
+ if (type === "user") {
101
+
102
+ }
103
+
104
+ if (type === "funnel-post") {
105
+
106
+ }
107
+
108
+ if (type === "funnel-pre") {
109
+
110
+ }
111
+
112
+ if (type === "scd") {
113
+
114
+ }
115
+
116
+ if (type === "everything") {
117
+
118
+ }
119
+
120
+ return record;
121
+ }
122
+ };
123
+
124
+ module.exports = config;