make-mp-data 2.1.11 → 3.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 (71) hide show
  1. package/README.md +31 -0
  2. package/dungeons/adspend.js +35 -1
  3. package/dungeons/anon.js +25 -1
  4. package/dungeons/array-of-object-lookup.js +201 -0
  5. package/dungeons/benchmark-heavy.js +241 -0
  6. package/dungeons/benchmark-light.js +141 -0
  7. package/dungeons/big.js +10 -9
  8. package/dungeons/business.js +60 -12
  9. package/dungeons/complex.js +35 -1
  10. package/dungeons/copilot.js +383 -0
  11. package/dungeons/education.js +1005 -0
  12. package/dungeons/experiments.js +18 -4
  13. package/dungeons/fintech.js +976 -0
  14. package/dungeons/foobar.js +32 -0
  15. package/dungeons/food.js +988 -0
  16. package/dungeons/funnels.js +38 -1
  17. package/dungeons/gaming.js +26 -5
  18. package/dungeons/media.js +861 -270
  19. package/dungeons/mil.js +31 -3
  20. package/dungeons/mirror.js +33 -1
  21. package/dungeons/retention-cadence.js +211 -0
  22. package/dungeons/rpg.js +1178 -0
  23. package/dungeons/sanity.js +32 -2
  24. package/dungeons/sass.js +923 -0
  25. package/dungeons/scd.js +47 -1
  26. package/dungeons/simple.js +29 -14
  27. package/dungeons/social.js +928 -0
  28. package/dungeons/streaming.js +373 -0
  29. package/dungeons/strict-event-test.js +30 -0
  30. package/dungeons/student-teacher.js +19 -5
  31. package/dungeons/text-generation.js +120 -84
  32. package/dungeons/too-big-events.js +203 -0
  33. package/dungeons/{userAgent.js → user-agent.js} +23 -2
  34. package/entry.js +5 -4
  35. package/index.js +41 -54
  36. package/lib/core/config-validator.js +122 -7
  37. package/lib/core/context.js +7 -14
  38. package/lib/core/storage.js +57 -25
  39. package/lib/generators/adspend.js +12 -12
  40. package/lib/generators/events.js +6 -5
  41. package/lib/generators/funnels.js +32 -10
  42. package/lib/generators/product-lookup.js +262 -0
  43. package/lib/generators/product-names.js +195 -0
  44. package/lib/generators/profiles.js +3 -3
  45. package/lib/generators/scd.js +13 -3
  46. package/lib/generators/text.js +17 -4
  47. package/lib/orchestrators/mixpanel-sender.js +244 -204
  48. package/lib/orchestrators/user-loop.js +54 -16
  49. package/lib/templates/phrases.js +473 -16
  50. package/lib/templates/schema.d.ts +173 -0
  51. package/lib/templates/verbose-schema.js +140 -206
  52. package/lib/utils/chart.js +210 -0
  53. package/lib/utils/function-registry.js +285 -0
  54. package/lib/utils/json-evaluator.js +172 -0
  55. package/lib/utils/logger.js +34 -0
  56. package/lib/utils/utils.js +41 -4
  57. package/package.json +12 -21
  58. package/types.d.ts +15 -5
  59. package/dungeons/ai-chat-analytics-ed.js +0 -274
  60. package/dungeons/money2020-ed-also.js +0 -277
  61. package/dungeons/money2020-ed.js +0 -579
  62. package/lib/generators/text-bak-old.js +0 -1121
  63. package/lib/orchestrators/worker-manager.js +0 -203
  64. package/lib/templates/hooks-instructions.txt +0 -434
  65. package/lib/templates/phrases-bak.js +0 -925
  66. package/lib/templates/prompt (old).txt +0 -98
  67. package/lib/templates/schema-instructions.txt +0 -155
  68. package/lib/templates/scratch-dungeon-template.js +0 -116
  69. package/lib/templates/textQuickTest.js +0 -172
  70. package/lib/utils/ai.js +0 -120
  71. package/lib/utils/project.js +0 -166
@@ -0,0 +1,383 @@
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
+ import Chance from 'chance';
12
+ let chance = new Chance();
13
+ import dayjs from "dayjs";
14
+ import utc from "dayjs/plugin/utc.js";
15
+ dayjs.extend(utc);
16
+ import { uid, comma } from 'ak-tools';
17
+ import { pickAWinner, weighNumRange, date, integer, weighChoices, decimal } from "../lib/utils/utils.js";
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
+ const videoCategories = ["funny", "educational", "inspirational", "music", "news", "sports", "cooking", "DIY", "travel", "gaming"];
21
+ const spiritAnimals = ["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"];
22
+
23
+
24
+ function makeProducts(maxItems = 5) {
25
+ return function () {
26
+ const categories = ["electronics", "books", "clothing", "home", "garden", "toys", "sports", "automotive", "beauty", "health", "grocery", "jewelry", "shoes", "tools", "office supplies"];
27
+ const descriptors = ["brand new", "open box", "refurbished", "used", "like new", "vintage", "antique", "collectible"];
28
+ const suffix = ["item", "product", "good", "merchandise", "thing", "object", "widget", "gadget", "device", "apparatus", "contraption", "instrument", "tool", "implement", "utensil", "appliance", "machine", "equipment", "gear", "kit", "set", "package"];
29
+ const assetPreview = ['.png', '.jpg', '.jpeg', '.heic', '.mp4', '.mov', '.avi'];
30
+ const data = [];
31
+ const numOfItems = integer(1, maxItems);
32
+
33
+ for (var i = 0; i < numOfItems; i++) {
34
+ const category = chance.pickone(categories);
35
+ const descriptor = chance.pickone(descriptors);
36
+ const suffixWord = chance.pickone(suffix);
37
+ const slug = `${descriptor.replace(/\s+/g, '-').toLowerCase()}-${suffixWord.replace(/\s+/g, '-').toLowerCase()}`;
38
+ const asset = chance.pickone(assetPreview);
39
+
40
+ // const product_id = chance.guid();
41
+ const price = integer(1, 100);
42
+ const quantity = integer(1, 5);
43
+
44
+ const item = {
45
+ // product_id: product_id,
46
+ // sku: integer(11111, 99999),
47
+ amount: price,
48
+ quantity: quantity,
49
+ total_value: price * quantity,
50
+ featured: chance.pickone([true, false, false]),
51
+ category: category,
52
+ descriptor: descriptor,
53
+ slug: slug,
54
+ assetPreview: `https://example.com/assets/${slug}${asset}`,
55
+ assetType: asset
56
+
57
+ };
58
+
59
+ data.push(item);
60
+ }
61
+
62
+ return () => [data];
63
+ };
64
+ };
65
+
66
+
67
+ /** @type {import('../types').Dungeon} */
68
+ const config = {
69
+ token: "",
70
+ seed: "simple is best",
71
+ numDays: 108, //how many days worth1 of data
72
+ numEvents: 2_000_000, //how many events
73
+ numUsers: 50_000, //how many users
74
+ format: 'json', //csv or json
75
+ region: "US",
76
+ hasAnonIds: false, //if true, anonymousIds are created for each user
77
+ hasSessionIds: false, //if true, hasSessionIds are created for each user
78
+ hasAdSpend: false,
79
+ makeChart: false,
80
+ hasLocation: true,
81
+ hasAndroidDevices: true,
82
+ hasIOSDevices: true,
83
+ hasDesktopDevices: true,
84
+ hasBrowser: true,
85
+ hasCampaigns: false,
86
+ isAnonymous: false,
87
+ alsoInferFunnels: false,
88
+ concurrency: 1,
89
+ batchSize: 2_500_000,
90
+ percentUsersBornInDataset: 25,
91
+ events: [
92
+ {
93
+ event: "checkout",
94
+ weight: 2,
95
+ properties: {
96
+ currency: pickAWinner(["USD", "CAD", "EUR", "BTC", "ETH", "JPY"], 0),
97
+ coupon: weighChoices(["none", "none", "none", "none", "10%OFF", "20%OFF", "10%OFF", "20%OFF", "30%OFF", "40%OFF", "50%OFF"]),
98
+ cart: makeProducts()
99
+ }
100
+ },
101
+ {
102
+ event: "add to cart",
103
+ weight: 4,
104
+ properties: {
105
+ item: makeProducts(1),
106
+ }
107
+ },
108
+ {
109
+ event: "view item",
110
+ weight: 8,
111
+ properties: {
112
+ item: makeProducts(1)
113
+ }
114
+ },
115
+ {
116
+ event: "save item",
117
+ weight: 5,
118
+ properties: {
119
+ item: makeProducts(1),
120
+ }
121
+ },
122
+ {
123
+ event: "page view",
124
+ weight: 10,
125
+ properties: {
126
+ page: ["/", "/help", "/account", "/watch", "/listen", "/product", "/people", "/peace"],
127
+ }
128
+ },
129
+ {
130
+ event: "watch video",
131
+ weight: 8,
132
+ properties: {
133
+ watchTimeSec: weighNumRange(10, 600, .25),
134
+ }
135
+ },
136
+ {
137
+ event: "like video",
138
+ weight: 6,
139
+ properties: {
140
+
141
+ }
142
+ },
143
+ {
144
+ event: "dislike video",
145
+ weight: 4,
146
+ properties: {
147
+
148
+ }
149
+ },
150
+ {
151
+ event: "sign up",
152
+ weight: 1,
153
+ isFirstEvent: true,
154
+ properties: {
155
+ signupMethod: pickAWinner(["email", "google", "facebook", "twitter", "linkedin", "github"]),
156
+ referral: weighChoices(["none", "none", "none", "friend", "ad", "ad", "ad", "friend", "friend", "friend", "friend"]),
157
+ }
158
+ },
159
+
160
+ ],
161
+ funnels: [
162
+ {
163
+ sequence: ["page view", "view item", "save item", "page view", "sign up"],
164
+ conversionRate: 50,
165
+ order: "first-and-last-fixed",
166
+ weight: 1,
167
+ isFirstFunnel: true,
168
+ timeToConvert: 2,
169
+ experiment: false,
170
+ name: "Signup Flow"
171
+
172
+ },
173
+ {
174
+ sequence: ["watch video", "like video", "watch video", "like video"],
175
+ name: "Video Likes",
176
+ conversionRate: 60,
177
+ props: {
178
+ videoCategory: videoCategories,
179
+ quality: ["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p"],
180
+ format: ["mp4", "avi", "mov", "mpg"],
181
+ uploader_id: chance.guid.bind(chance)
182
+ }
183
+ },
184
+ {
185
+ name: "Video Dislikes",
186
+ sequence: ["watch video", "dislike video", "watch video", "dislike video"],
187
+ conversionRate: 20,
188
+ props: {
189
+ videoCategory: videoCategories,
190
+ quality: ["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p"],
191
+ format: ["mp4", "avi", "mov", "mpg"],
192
+ uploader_id: chance.guid.bind(chance)
193
+ }
194
+ },
195
+ {
196
+ name: "eCommerce Purchase",
197
+ sequence: ["view item", "view item", "add to cart", "view item", "add to cart", "checkout"],
198
+ conversionRate: 15,
199
+ requireRepeats: true,
200
+ weight: 10,
201
+ order: "last-fixed",
202
+ }
203
+
204
+ ],
205
+ superProps: {
206
+ theme: pickAWinner(["light", "dark", "custom", "light", "dark"]),
207
+ },
208
+ /*
209
+ user properties work the same as event properties
210
+ each key should be an array or function reference
211
+ */
212
+ userProps: {
213
+ title: chance.profession.bind(chance),
214
+ luckyNumber: weighNumRange(42, 420, .3),
215
+ spiritAnimal: spiritAnimals
216
+ },
217
+ scdProps: {},
218
+ mirrorProps: {},
219
+
220
+ /*
221
+ for group analytics keys, we need an array of arrays [[],[],[]]
222
+ each pair represents a group_key and the number of profiles for that key
223
+ */
224
+ groupKeys: [],
225
+ groupProps: {},
226
+ lookupTables: [],
227
+ hook: function (record, type, meta) {
228
+
229
+ if (type === "event") {
230
+ const NOW = dayjs();
231
+ const DAY_SIGNUPS_IMPROVED = NOW.subtract(7, 'day');
232
+ const DAY_WATCH_TIME_WENT_UP = NOW.subtract(30, 'day');
233
+ const eventTime = dayjs(record.time);
234
+
235
+ // unflattering 'items'
236
+ if (record.item && Array.isArray(record.item)) {
237
+ record = { ...record, ...record.item[0] };
238
+ delete record.item;
239
+ }
240
+
241
+ if (record.event === 'sign up') {
242
+ record.signup_flow = "v1";
243
+ if (eventTime.isBefore(DAY_SIGNUPS_IMPROVED)) {
244
+ // 50% of the time kill the signup
245
+ if (chance.bool({ likelihood: 50 })) {
246
+ return null;
247
+ }
248
+ }
249
+ if (eventTime.isAfter(DAY_SIGNUPS_IMPROVED)) {
250
+ record.signup_flow = "v2";
251
+ }
252
+ }
253
+
254
+ if (record.event === 'watch video') {
255
+ const factor = decimal(0.25, 0.79);
256
+ if (eventTime.isBefore(DAY_WATCH_TIME_WENT_UP)) {
257
+ record.watchTimeSec = Math.round(record.watchTimeSec * (1 - factor));
258
+ }
259
+ if (eventTime.isAfter(DAY_WATCH_TIME_WENT_UP)) {
260
+ // increase watch time by 33%
261
+ record.watchTimeSec = Math.round(record.watchTimeSec * (1 + factor));
262
+ }
263
+
264
+ }
265
+
266
+ // toys + shoes frequently purchases together (and are higher cart values)
267
+ if (record.event === 'checkout' && Array.isArray(record.cart)) {
268
+ const hasToys = record.cart.some(item => item.category === 'toys');
269
+ const hasShoes = record.cart.some(item => item.category === 'shoes');
270
+ if (hasToys && !hasShoes) {
271
+ const bigCart = makeProducts(20)()()[0];
272
+ const shoeItems = bigCart.filter(item => item.category === 'shoes');
273
+ if (shoeItems.length > 0) {
274
+ record.cart.push(shoeItems[0]);
275
+ }
276
+ }
277
+
278
+ if (hasShoes && !hasToys) {
279
+ const bigCart = makeProducts(20)()()[0];
280
+ const toyItems = bigCart.filter(item => item.category === 'toys');
281
+ if (toyItems.length > 0) {
282
+ record.cart.push(toyItems[0]);
283
+ }
284
+ }
285
+
286
+ if (!hasToys && !hasShoes) {
287
+ const cheapFactor = decimal(.75, 0.9);
288
+ // make every item a bit cheaper
289
+ record.cart = record.cart.map(item => {
290
+ return {
291
+ ...item,
292
+ amount: Math.round(item.amount * cheapFactor),
293
+ total_value: Math.round(item.total_value * cheapFactor)
294
+ };
295
+ });
296
+ }
297
+ }
298
+ // high quality video means longer watch times (lower quality shorter watch times)
299
+ if (record.event === 'watch video') {
300
+ const qualityFactors = {
301
+ "2160p": 1.5,
302
+ "1440p": 1.4,
303
+ "1080p": 1.3,
304
+ "720p": 1.15,
305
+ "480p": 1.0,
306
+ "360p": 0.85,
307
+ "240p": 0.7
308
+ };
309
+ const quality = record.quality || "480p";
310
+ const factor = qualityFactors[quality] || 1.0;
311
+ record.watchTimeSec = Math.round(record.watchTimeSec * factor);
312
+ }
313
+
314
+
315
+
316
+ }
317
+
318
+
319
+
320
+ if (type === "everything") {
321
+ // big themes!
322
+
323
+ // users who view items in the home and garden category churn more frequently
324
+
325
+
326
+
327
+ // dark mode leads to faster purchase conversion
328
+
329
+
330
+ // people who pay in bitcoin tend to buy more electronics and gadgets
331
+
332
+
333
+ //custom themes purchase more:
334
+ // const numCustomMode = record.filter(a => a.theme === 'custom').length;
335
+ // const numLightMode = record.filter(a => a.theme === 'light').length;
336
+ // const numDarkMode = record.filter(a => a.theme === 'dark').length;
337
+ // if (numCustomMode > numLightMode || numCustomMode > numDarkMode) {
338
+ // //triple their checkout events
339
+ // const checkoutEvents = record.filter(a => a.event === 'checkout');
340
+ // const newCheckouts = checkoutEvents.map(a => {
341
+ // const randomInt = integer(-48, 48);
342
+ // const newCheckout = {
343
+ // ...a,
344
+ // time: dayjs(a.time).add(randomInt, 'hour').toISOString(),
345
+ // event: "checkout",
346
+ // amount: a.amount * 2,
347
+ // coupon: "50%OFF"
348
+ // };
349
+ // return newCheckout;
350
+ // });
351
+ // record.push(...newCheckouts);
352
+ // }
353
+
354
+ // //users who watch low quality videos churn more:
355
+ // const loQuality = ["480p", "360p", "240p"];
356
+ // const lowQualityWatches = record.filter(a => a.event === 'watch video' && loQuality.includes(a.quality));
357
+ // const highQualityWatches = record.filter(a => a.event === 'watch video' && !loQuality.includes(a.quality));
358
+ // if (lowQualityWatches.length > highQualityWatches.length) {
359
+ // if (flip()) {
360
+ // // find midpoint of records
361
+ // const midpoint = Math.floor(record.length / 2);
362
+ // record = record.slice(0, midpoint);
363
+
364
+ // }
365
+ // }
366
+
367
+
368
+
369
+
370
+ }
371
+
372
+
373
+
374
+ return record;
375
+ }
376
+ };
377
+
378
+ function flip(likelihood = 50) {
379
+ return chance.bool({ likelihood });
380
+ }
381
+
382
+
383
+ export default config;