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,327 @@
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
+ const Chance = require('chance');
10
+ const chance = new Chance();
11
+ const { weighNumRange, date, integer, pickAWinner, exhaust } = require('../lib/utils/utils.js');
12
+ const u = require('ak-tools');
13
+
14
+ const channel_ids = [...Array(1234).keys()].map(i => i + 1).map(n => `channel_id_${n}`);
15
+ const channel_names = chance.n(u.makeName, 1234);
16
+ const video_ids = [...Array(50000).keys()].map(i => i + 1).map(n => n.toString());
17
+ const video_names = chance.n(u.makeName, 50000);
18
+
19
+ const EVENTS = 50_000
20
+ const USERS = EVENTS / 100
21
+
22
+
23
+ /** @type {import('../types.js').Dungeon} */
24
+ const config = {
25
+ token: "",
26
+ seed: "it's business time...",
27
+ numDays: 90, //how many days worth of data
28
+ numEvents: EVENTS, //how many events
29
+ numUsers: USERS, //how many users
30
+ format: 'json', //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
+ hasLocation: true,
35
+ hasAndroidDevices: true,
36
+ hasIOSDevices: true,
37
+ hasDesktopDevices: true,
38
+ hasBrowser: true,
39
+ hasCampaigns: true,
40
+ isAnonymous: false,
41
+ hasAdSpend: true,
42
+
43
+ hasAvatar: false,
44
+ makeChart: true,
45
+
46
+ batchSize: 500_000,
47
+ concurrency: 500,
48
+
49
+ funnels: [
50
+ {
51
+ sequence: ["watch video", "like video", "subscribe", "purchase video"],
52
+ conversionRate: 35,
53
+ props: {
54
+ channel_id: pickAWinner(channel_ids),
55
+ video_id: weighNumRange(1, 50000, 1.4),
56
+ category: pickAWinner(["funny", "educational", "music", "news", "sports", "cooking", "DIY", "travel", "gaming"]),
57
+ isFeatured: () => { chance.bool({ likelihood: 25 }); },
58
+ }
59
+ },
60
+ {
61
+ sequence: ["watch video", "dislike video"],
62
+ conversionRate: 10,
63
+ order: "sequential",
64
+ props: {
65
+ channel_id: pickAWinner(channel_ids),
66
+ video_id: weighNumRange(1, 50000, .67),
67
+ category: pickAWinner(["funny", "educational", "music", "news", "sports", "cooking", "DIY", "travel", "gaming"]),
68
+ isFeatured: () => { chance.bool({ likelihood: 25 }); },
69
+ }
70
+ },
71
+ ],
72
+ events: [
73
+ {
74
+ "event": "watch video",
75
+ "weight": 75,
76
+ "properties": {
77
+ "#hashtags": makeHashTags,
78
+ "watch time (sec)": weighNumRange(10, 600, .25),
79
+ "quality": pickAWinner(["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p"], 1)
80
+ }
81
+ },
82
+ {
83
+ "event": "like video",
84
+ "weight": 30,
85
+ "properties": {
86
+
87
+ }
88
+ },
89
+ {
90
+ "event": "dislike video",
91
+ "weight": 15,
92
+ "properties": {
93
+
94
+ }
95
+ },
96
+ {
97
+ "event": "subscribe",
98
+ "weight": 10,
99
+ "properties": {
100
+ "UI": pickAWinner(["button", "link", "modal", "menu"]),
101
+ }
102
+ },
103
+ {
104
+ "event": "search",
105
+ "weight": 10,
106
+ "properties": {
107
+ term: () => { return chance.word(); },
108
+ "# results": weighNumRange(1, 100, .25),
109
+ "UI": pickAWinner(["button", "link", "modal", "menu"]),
110
+ }
111
+ },
112
+ {
113
+ "event": "comment",
114
+ "weight": 6,
115
+ "properties": {
116
+ length: weighNumRange(1, 500, .25),
117
+ video_id: weighNumRange(1, 50000, .72),
118
+ "has replies": [true, false, false, false, false],
119
+ "has photos": [true, false, false, false, false],
120
+
121
+ }
122
+ },
123
+ {
124
+ "event": "save video",
125
+ "weight": 17,
126
+ "properties": {
127
+ video_id: weighNumRange(1, 50000, 1.4),
128
+ UI: pickAWinner(["toolbar", "menu", "keyboard"])
129
+
130
+ }
131
+ },
132
+ {
133
+ "event": "create playlist",
134
+ "weight": 5,
135
+ "properties": {
136
+ "# of videos": weighNumRange(1, 100, .25),
137
+ "UI": pickAWinner(["toolbar", "menu", "keyboard"]),
138
+ "visibility": pickAWinner(["public", "private", "unlisted"]),
139
+ }
140
+ },
141
+ {
142
+ "event": "purchase video",
143
+ "weight": 12,
144
+ "properties": {
145
+ video_id: weighNumRange(1, 50000, 1.4),
146
+ basket: makeProducts(5),
147
+
148
+
149
+ }
150
+ },
151
+ {
152
+ "event": "support ticket",
153
+ "weight": 10,
154
+ "properties": {
155
+ description: chance.sentence.bind(chance),
156
+ severity: ["low", "medium", "high"],
157
+ ticket_id: chance.guid.bind(chance)
158
+ }
159
+ },
160
+ {
161
+ "event": "app error",
162
+ "weight": 15,
163
+ "properties": {
164
+ code: pickAWinner(["404", "500", "403", "401", "400", "503", "504", "429"]),
165
+ error: chance.sentence.bind(chance),
166
+ component: pickAWinner(["video player", "search", "comment", "profile", "settings", "billing", "support"]),
167
+ }
168
+ },
169
+ {
170
+ "event": "sign up",
171
+ "isFirstEvent": true,
172
+ "weight": 0,
173
+ "properties": {
174
+
175
+ }
176
+ }
177
+ ],
178
+ superProps: {
179
+
180
+
181
+ },
182
+ /*
183
+ user properties work the same as event properties
184
+ each key should be an array or function reference
185
+ */
186
+ userProps: {
187
+ title: chance.profession.bind(chance),
188
+ luckyNumber: weighNumRange(42, 420),
189
+ experiment: designExperiment(),
190
+ spiritAnimal: ["unicorn", "dragon", "phoenix", "sasquatch", "yeti", "kraken", "jackalope", "thunderbird", "mothman", "nessie", "chupacabra", "jersey devil", "bigfoot", "weindgo", "bunyip", "mokele-mbembe", "tatzelwurm", "megalodon"],
191
+
192
+ ip: chance.ip.bind(chance),
193
+
194
+ },
195
+
196
+ /** each generates it's own table */
197
+ scdProps: {
198
+ plan: ["free", "free", "free", "free", "basic", "basic", "basic", "premium", "premium", "enterprise"],
199
+ MRR: weighNumRange(0, 10000, .15),
200
+ NPS: weighNumRange(0, 10, 2, 150),
201
+ },
202
+
203
+ mirrorProps: {
204
+
205
+ },
206
+
207
+ /*
208
+ for group analytics keys, we need an array of arrays [[],[],[]]
209
+ each pair represents a group_key and the number of profiles for that key
210
+ */
211
+ groupKeys: [
212
+ ['channel_id', 1234, ["save video", "comment", "watch video", "purchase video", "like video", "dislike video", "subscribe"]],
213
+
214
+ ],
215
+ groupProps: {
216
+ channel_id: {
217
+ "name": exhaust(channel_names),
218
+ "viewers": weighNumRange(5, 500, .25),
219
+ "rating": weighNumRange(1, 5),
220
+ "reviews": weighNumRange(0, 35)
221
+ }
222
+
223
+ },
224
+
225
+ lookupTables: [
226
+ {
227
+ key: "video_id",
228
+ entries: 50000,
229
+ attributes: {
230
+ isFlagged: [true, false, false, false, false],
231
+ copyright: ["all rights reserved", "creative commons", "creative commons", "public domain", "fair use"],
232
+ uploader_id: chance.guid.bind(chance),
233
+ "uploader influence": ["low", "low", "low", "medium", "medium", "high"],
234
+ thumbs: weighNumRange(0, 4000, .25),
235
+ video_name: exhaust(video_names),
236
+ rating: ["G", "PG", "PG-13", "R", "NC-17", "PG-13", "R", "NC-17", "R", "PG", "PG"]
237
+ }
238
+
239
+ }
240
+ ],
241
+
242
+ hook: function (record, type, meta) {
243
+ return record;
244
+ }
245
+ };
246
+
247
+
248
+
249
+ function makeHashTags() {
250
+ const possibleHashtags = [];
251
+ for (let i = 0; i < 20; i++) {
252
+ possibleHashtags.push('#' + u.makeName(2, ''));
253
+ }
254
+
255
+ const numHashtags = integer(integer(1, 5), integer(5, 10));
256
+ const hashtags = [];
257
+ for (let i = 0; i < numHashtags; i++) {
258
+ hashtags.push(chance.pickone(possibleHashtags));
259
+ }
260
+ return [hashtags];
261
+ };
262
+
263
+ function makeProducts(maxItems = 10) {
264
+ return function () {
265
+ 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"];
266
+ const slugs = ['/sale/', '/featured/', '/home/', '/search/', '/wishlist/', '/'];
267
+ const assetExtension = ['.png', '.jpg', '.jpeg', '.heic', '.mp4', '.mov', '.avi'];
268
+ const data = [];
269
+ const numOfItems = integer(1, 12);
270
+
271
+ for (var i = 0; i < numOfItems; i++) {
272
+ const category = chance.pickone(categories);
273
+ const slug = chance.pickone(slugs);
274
+ const asset = chance.pickone(assetExtension);
275
+ const product_id = chance.guid();
276
+ const price = integer(1, 300);
277
+ const quantity = integer(1, 5);
278
+
279
+ const item = {
280
+ product_id: product_id,
281
+ sku: integer(11111, 99999),
282
+ amount: price,
283
+ quantity: quantity,
284
+ value: price * quantity,
285
+ featured: chance.pickone([true, false]),
286
+ category: category,
287
+ urlSlug: slug + category,
288
+ asset: `${category}-${integer(1, 20)}${asset}`
289
+ };
290
+
291
+ data.push(item);
292
+ }
293
+
294
+ return [data];
295
+ };
296
+ };
297
+
298
+
299
+ function designExperiment() {
300
+ return function () {
301
+ const variants = ["A", "B", "C", "Control"];
302
+ const variant = chance.pickone(variants);
303
+ const experiments = ["no password", "social sign in", "new tutorial", "new search"];
304
+ const experiment = chance.pickone(experiments);
305
+ const multi_variates = ["A/B", "A/B/C", "A/B/C/D", "Control"];
306
+ const multi_variate = chance.pickone(multi_variates);
307
+ const impression_id = chance.guid();
308
+
309
+
310
+
311
+ const chosen = {
312
+ variant,
313
+ experiment,
314
+ multi_variate,
315
+ impression_id
316
+ };
317
+
318
+ return [chosen];
319
+ };
320
+ }
321
+
322
+
323
+
324
+
325
+
326
+
327
+ module.exports = config;