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,373 @@
1
+
2
+ const SEED = "my-seed";
3
+ import dayjs from 'dayjs';
4
+ import utc from 'dayjs/plugin/utc.js';
5
+ dayjs.extend(utc);
6
+ import 'dotenv/config';
7
+ import * as u from "../lib/utils/utils.js";
8
+ import * as v from 'ak-tools';
9
+ const chance = u.initChance(SEED);
10
+ const num_users = 10_000;
11
+ const days = 125;
12
+
13
+ /** @typedef {import("../types.js").Dungeon} Config */
14
+
15
+ function genIds(numIds = 1000) {
16
+ const ids = [];
17
+ for (let i = 0; i < numIds; i++) {
18
+ ids.push(v.uid());
19
+ }
20
+ return ids;
21
+ }
22
+
23
+ const videoIds = genIds();
24
+ const channelIds = genIds(100);
25
+
26
+ /** @type {Config} */
27
+ const config = {
28
+ // token: "",
29
+ seed: `LFG!`, //,
30
+ numDays: days,
31
+ numEvents: num_users * 63,
32
+ numUsers: num_users,
33
+ hasAnonIds: false,
34
+ hasSessionIds: false,
35
+ format: "csv",
36
+ alsoInferFunnels: false,
37
+ hasLocation: false,
38
+ hasAndroidDevices: true,
39
+ hasIOSDevices: true,
40
+ hasDesktopDevices: true,
41
+ hasBrowser: false,
42
+ hasCampaigns: false,
43
+ isAnonymous: false,
44
+ hasAdSpend: false,
45
+
46
+ hasAvatar: false,
47
+ makeChart: false,
48
+
49
+ batchSize: 2_500_000,
50
+ concurrency: 10,
51
+ writeToDisk: false,
52
+
53
+ funnels: [],
54
+
55
+ events: [
56
+ {
57
+ event: "watch video",
58
+ weight: 55,
59
+ properties: {
60
+ video_id: u.pickAWinner(videoIds),
61
+ "watch percent": u.pickAWinner([
62
+ 25,
63
+ 50,
64
+ 75,
65
+ 100,
66
+ ]),
67
+ "watch time": u.weighNumRange(1, 65, .89, 100),
68
+
69
+ "category": u.pickAWinner([
70
+ "comedy",
71
+ "educational",
72
+ "music",
73
+ "sports",
74
+ "news",
75
+ "gaming",
76
+ "travel",
77
+ ]),
78
+ quality: u.pickAWinner([
79
+ "240p",
80
+ "360p",
81
+ "480p",
82
+ "720p",
83
+ "1080p",
84
+ "4k",
85
+ ], 4),
86
+ autoplay: [
87
+ true,
88
+ false,
89
+ ],
90
+ fullscreen: [
91
+ true,
92
+ false,
93
+ ],
94
+ "ads?": [
95
+ true, true,
96
+ false,
97
+ ],
98
+ },
99
+ },
100
+ {
101
+ event: "like",
102
+ weight: 10,
103
+ properties: {
104
+ video_id: u.pickAWinner(videoIds),
105
+ },
106
+ },
107
+ {
108
+ event: "comment",
109
+ weight: 5,
110
+ properties: {
111
+ video_id: u.pickAWinner(videoIds),
112
+ comment_length: [
113
+ "short",
114
+ "medium",
115
+ "long",
116
+ ],
117
+ },
118
+ },
119
+ {
120
+ event: "share",
121
+ weight: 3,
122
+ properties: {
123
+ video_id: u.pickAWinner(videoIds),
124
+ "share network": u.pickAWinner([
125
+ "facebook",
126
+ "twitter",
127
+ "reddit",
128
+ "email",
129
+ "whatsapp",
130
+ ]),
131
+ },
132
+ },
133
+ {
134
+ event: "search",
135
+ weight: 25,
136
+ properties: {
137
+ search_term: [
138
+ "cats",
139
+ "dogs",
140
+ "tutorial",
141
+ "news",
142
+ "music",
143
+ ],
144
+ "results count": u.pickAWinner([
145
+ 0,
146
+ 1,
147
+ 2,
148
+ 3,
149
+ 4,
150
+ 5,
151
+ 6, 7, 8, 9, 10
152
+ ], 5),
153
+ "search category": [
154
+ "all",
155
+ "channels",
156
+ "playlists",
157
+ ],
158
+ },
159
+ },
160
+ {
161
+ event: "subscribe",
162
+ weight: 7,
163
+ properties: {
164
+ channel_id: u.pickAWinner(genIds()),
165
+ },
166
+ },
167
+ {
168
+ event: "unsubscribe",
169
+ weight: 2,
170
+ properties: {
171
+ channel_id: u.pickAWinner(genIds()),
172
+ },
173
+ },
174
+ {
175
+ event: "create playlist",
176
+ weight: 4,
177
+ properties: {
178
+ "play list name": u.pickAWinner([
179
+ "favorites",
180
+ "watch later",
181
+ "my music",
182
+ "funny videos",
183
+ "educational",
184
+ ]),
185
+ privacy: u.pickAWinner([
186
+ "public",
187
+ "private",
188
+ "unlisted",
189
+ ]),
190
+ },
191
+ },
192
+ {
193
+ event: "account signup",
194
+ weight: 1,
195
+ isFirstEvent: true,
196
+ properties: {
197
+ "sign up method": [
198
+ "email",
199
+ "google",
200
+ "facebook",
201
+ ],
202
+ },
203
+ },
204
+ {
205
+ event: "account login",
206
+ weight: 9,
207
+ properties: {
208
+ "log in method": u.pickAWinner([
209
+ "email",
210
+ "google",
211
+ "facebook",
212
+ ]),
213
+ success: [
214
+ true,
215
+ false,
216
+ ],
217
+ error_message: [
218
+ "incorrect password",
219
+ "user not found",
220
+ "account locked",
221
+ ],
222
+ },
223
+ },
224
+ {
225
+ event: "$experiment_started",
226
+ weight: 5,
227
+ isSessionStartEvent: true,
228
+ properties: {
229
+ "$experiment_type": "ak_ad_hoc",
230
+ "Experiment name": "show results on empty search",
231
+ "Variant name": ["feature enabled", "feature disabled"],
232
+ }
233
+ }
234
+ ],
235
+ superProps: {
236
+ platform: u.pickAWinner([
237
+ "web",
238
+ "ios",
239
+ "android",
240
+ ]),
241
+ network_type: [
242
+ "wifi",
243
+ "cellular",
244
+ ],
245
+ },
246
+ userProps: {
247
+ subscription_status: [
248
+ "free",
249
+ "free",
250
+ "premium",
251
+ ],
252
+ age_range: [
253
+ "13-17",
254
+ "18-24",
255
+ "25-34",
256
+ "35-44",
257
+ "45-54",
258
+ "55+",
259
+ ],
260
+ preferred_genre: u.pickAWinner([
261
+ "comedy",
262
+ "action",
263
+ "drama",
264
+ "sci-fi",
265
+ "horror",
266
+ ]),
267
+ upload_count: [
268
+ 0,
269
+ 1,
270
+ 5,
271
+ 10,
272
+ 20,
273
+ ],
274
+ following_count: [
275
+ 0,
276
+ 10,
277
+ 50,
278
+ 100,
279
+ 500,
280
+ ],
281
+ dark_mode_enabled: [
282
+ true,
283
+ false,
284
+ ],
285
+ },
286
+
287
+ scdProps: {},
288
+ mirrorProps: {},
289
+ groupKeys: [],
290
+ groupProps: {},
291
+ lookupTables: [],
292
+ hook: function (record, type, meta) {
293
+ const NOW = dayjs();
294
+ const TIME_WHEN_SEARCH_GOT_BAD = NOW.subtract(21, 'days');
295
+ const TIME_WE_EXPERIMENTED = NOW.subtract(14, 'days');
296
+
297
+ if (type === "event") {
298
+ const EVENT_TIME = dayjs(record.time);
299
+ //when search got bad, people started searching less
300
+ //and got fewer results
301
+ if (EVENT_TIME.isAfter(TIME_WHEN_SEARCH_GOT_BAD)) {
302
+ if (chance.bool({ likelihood: 50 })) {
303
+ if (record.event === "search") {
304
+ record["results count"] = 0;
305
+ }
306
+ }
307
+
308
+ if (chance.bool({ likelihood: 18 })) {
309
+ record._drop = true;
310
+ }
311
+ }
312
+
313
+ if (EVENT_TIME.isBefore(TIME_WE_EXPERIMENTED)) {
314
+ if (record.event === "$experiment_started") {
315
+ record._drop = true;
316
+ }
317
+ }
318
+ }
319
+
320
+
321
+
322
+ if (type === "everything") {
323
+ // Filter out events tagged for dropping by the event hook
324
+ record = record.filter(e => !e._drop);
325
+
326
+ const hadFeatureEnabled = record.some(event =>
327
+ event.event === "$experiment_started" &&
328
+ event["Variant name"] === "feature enabled"
329
+ );
330
+
331
+ const hadFeatureDisabled = record.some(event =>
332
+ event.event === "$experiment_started" &&
333
+ event["Variant name"] === "feature disabled"
334
+ );
335
+
336
+ record.forEach((event, idx) => {
337
+ const EVENT_TIME = dayjs(event.time);
338
+
339
+ if (EVENT_TIME.isAfter(TIME_WE_EXPERIMENTED)) {
340
+ if (hadFeatureEnabled) {
341
+ // Users with feature enabled variant have a higher likelihood of subscribing.
342
+ // Add an extra subscribe event 50% of the time immediately after watching a video.
343
+ if (event.event === "watch video" && chance.bool({ likelihood: 75 })) {
344
+ // watch time goes up
345
+ event["watch time"] = v.round(event["watch time"] * 1.7);
346
+ const subscribeEvent = {
347
+ event: "subscribe",
348
+ time: dayjs(event.time).add(1, 'minute').toISOString(),
349
+ user_id: event.user_id,
350
+ };
351
+ record.splice(idx + 1, 0, subscribeEvent);
352
+ }
353
+ } else if (hadFeatureDisabled) {
354
+ // Users with feature disabled variant have lower likelihood of subscribing.
355
+ // Drop subscribe events 50% of the time.
356
+ if (event.event === "subscribe" && chance.bool({ likelihood: 75 })) {
357
+ record.splice(idx, 1);
358
+ }
359
+
360
+ // watch time goes down
361
+ if (event.event === "watch video") {
362
+ event["watch time"] = v.round(event["watch time"] * 0.5);
363
+ }
364
+ }
365
+ }
366
+ });
367
+ }
368
+
369
+ return record;
370
+ }
371
+ };
372
+
373
+ export default config;
@@ -0,0 +1,30 @@
1
+ export default {
2
+ name: "strict-event-count-test",
3
+ seed: "test-123",
4
+
5
+ // We want exactly 1000 events
6
+ numEvents: 1000,
7
+
8
+ // Even though we specify 500 users, we should stop early when we hit 1000 events
9
+ numUsers: 500,
10
+
11
+ numDays: 7,
12
+
13
+ // Enable strict event count - this will bail out at exactly numEvents
14
+ strictEventCount: true,
15
+
16
+ verbose: true,
17
+ writeToDisk: false,
18
+ format: 'json',
19
+
20
+ events: [
21
+ { event: "page_view", weight: 5 },
22
+ { event: "click", weight: 3 },
23
+ { event: "purchase", weight: 1 }
24
+ ],
25
+
26
+ userProps: {
27
+ plan: ["free", "pro", "enterprise"],
28
+ region: ["US", "EU", "APAC"]
29
+ }
30
+ };
@@ -34,8 +34,9 @@ const config = {
34
34
  hasAdSpend: true,
35
35
 
36
36
  hasAvatar: true,
37
+ makeChart: false,
37
38
 
38
- batchSize: 1_500_000,
39
+ batchSize: 2_500_000,
39
40
  concurrency: 1,
40
41
  writeToDisk: false,
41
42
 
@@ -396,17 +397,30 @@ const config = {
396
397
 
397
398
  if (type === "event") {
398
399
  const EVENT_TIME = dayjs(record.time);
400
+ // Pattern 1: Late submissions get lower scores
401
+ if (record.event === "student: submit assignment" && record.is_late === true) {
402
+ record.late_penalty_percent = chance.integer({ min: 5, max: 25 });
403
+ }
399
404
  }
400
405
 
401
406
  if (type === "user") {
402
-
407
+ // Pattern 2: Teachers get a department assignment
408
+ if (record.role === "teacher") {
409
+ record.department = chance.pickone(["Math", "Science", "English", "History", "Art", "PE"]);
410
+ record.years_experience = chance.integer({ min: 1, max: 30 });
411
+ }
403
412
  }
404
413
 
405
- if (type === "funnel-post") {
406
-
414
+ if (type === "funnel-pre") {
415
+ // Pattern 3: Students on chromebooks have lower test completion rates
416
+ if (meta && meta.profile && meta.profile.device_type === "chromebook") {
417
+ if (record.name === "Student Takes Test") {
418
+ record.conversionRate = Math.max(50, record.conversionRate * 0.7);
419
+ }
420
+ }
407
421
  }
408
422
 
409
- if (type === "funnel-pre") {
423
+ if (type === "funnel-post") {
410
424
 
411
425
  }
412
426