make-mp-data 3.0.4 → 3.0.6

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 (66) hide show
  1. package/README.md +46 -0
  2. package/dungeons/array-of-object-lookup-schema.json +327 -0
  3. package/dungeons/array-of-object-lookup.js +28 -8
  4. package/dungeons/ecommerce-schema.json +462 -0
  5. package/dungeons/{copilot.js → ecommerce.js} +77 -15
  6. package/dungeons/education-schema.json +2409 -0
  7. package/dungeons/education.js +206 -442
  8. package/dungeons/fintech-schema.json +14034 -0
  9. package/dungeons/fintech.js +110 -389
  10. package/dungeons/foobar-schema.json +403 -0
  11. package/dungeons/foobar.js +27 -4
  12. package/dungeons/food-delivery-schema.json +192 -0
  13. package/dungeons/food-delivery.js +602 -0
  14. package/dungeons/food-schema.json +1152 -0
  15. package/dungeons/food.js +150 -383
  16. package/dungeons/gaming-schema.json +1270 -0
  17. package/dungeons/gaming.js +143 -3
  18. package/dungeons/insurance-application-schema.json +204 -0
  19. package/dungeons/insurance-application.js +605 -0
  20. package/dungeons/media-schema.json +906 -0
  21. package/dungeons/media.js +221 -391
  22. package/dungeons/retention-cadence-schema.json +78 -0
  23. package/dungeons/retention-cadence.js +35 -1
  24. package/dungeons/rpg-schema.json +4526 -0
  25. package/dungeons/rpg.js +130 -388
  26. package/dungeons/sanity-schema.json +255 -0
  27. package/dungeons/sanity.js +21 -10
  28. package/dungeons/sass-schema.json +1291 -0
  29. package/dungeons/sass.js +210 -337
  30. package/dungeons/scd-schema.json +919 -0
  31. package/dungeons/scd.js +38 -10
  32. package/dungeons/simple-schema.json +608 -0
  33. package/dungeons/simple.js +48 -11
  34. package/dungeons/simplest-schema.json +1418 -0
  35. package/dungeons/simplest.js +392 -0
  36. package/dungeons/social-schema.json +1118 -0
  37. package/dungeons/social.js +124 -365
  38. package/dungeons/text-generation-schema.json +3096 -0
  39. package/dungeons/text-generation.js +71 -0
  40. package/index.js +6 -3
  41. package/lib/core/config-validator.js +18 -0
  42. package/lib/core/storage.js +5 -5
  43. package/lib/generators/events.js +4 -4
  44. package/lib/orchestrators/mixpanel-sender.js +14 -8
  45. package/lib/orchestrators/user-loop.js +14 -6
  46. package/lib/templates/soup-presets.js +188 -0
  47. package/lib/utils/utils.js +52 -6
  48. package/package.json +2 -2
  49. package/types.d.ts +20 -3
  50. package/dungeons/adspend.js +0 -117
  51. package/dungeons/anon.js +0 -128
  52. package/dungeons/benchmark-heavy.js +0 -240
  53. package/dungeons/benchmark-light.js +0 -126
  54. package/dungeons/big.js +0 -226
  55. package/dungeons/business.js +0 -391
  56. package/dungeons/complex.js +0 -428
  57. package/dungeons/experiments.js +0 -137
  58. package/dungeons/funnels.js +0 -309
  59. package/dungeons/mil.js +0 -323
  60. package/dungeons/mirror.js +0 -160
  61. package/dungeons/soup-test.js +0 -52
  62. package/dungeons/streaming.js +0 -372
  63. package/dungeons/strict-event-test.js +0 -30
  64. package/dungeons/student-teacher.js +0 -438
  65. package/dungeons/too-big-events.js +0 -203
  66. package/dungeons/user-agent.js +0 -209
@@ -1,438 +0,0 @@
1
-
2
- import dayjs from "dayjs";
3
- import utc from "dayjs/plugin/utc.js";
4
- import "dotenv/config";
5
- import * as u from "../lib/utils/utils.js";
6
- import * as v from "ak-tools";
7
-
8
- const SEED = "ai-generated-1754199343300";
9
- dayjs.extend(utc);
10
- const chance = u.initChance(SEED);
11
- const num_users = 1_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: false,
27
- hasLocation: true,
28
- hasAndroidDevices: true,
29
- hasIOSDevices: true,
30
- hasDesktopDevices: true,
31
- hasBrowser: true,
32
- hasCampaigns: true,
33
- isAnonymous: false,
34
- hasAdSpend: true,
35
-
36
- hasAvatar: true,
37
-
38
- batchSize: 2_500_000,
39
- concurrency: 1,
40
- writeToDisk: false,
41
-
42
- // AI-generated schema content:
43
-
44
- "funnels": [
45
- {
46
- "name": "Student Onboarding",
47
- "sequence": [
48
- "student: login",
49
- "student: join class"
50
- ],
51
- "isFirstFunnel": true,
52
- "conversionRate": 95,
53
- "timeToConvert": 0.1,
54
- "conditions": {
55
- "role": "student"
56
- },
57
- "order": "sequential",
58
- "props": {
59
- "onboarding_source": [
60
- "email_invite",
61
- "class_code",
62
- "school_roster"
63
- ]
64
- }
65
- },
66
- {
67
- "name": "Teacher Creates Class",
68
- "sequence": [
69
- "teacher: login",
70
- "teacher: create class",
71
- "teacher: post announcement"
72
- ],
73
- "conditions": {
74
- "role": "teacher"
75
- },
76
- "isFirstFunnel": true,
77
- "conversionRate": 98,
78
- "timeToConvert": 0.2,
79
- "order": "sequential"
80
- },
81
- {
82
- "name": "Student Completes Homework",
83
- "sequence": [
84
- "student: view assignment",
85
- "student: start assignment",
86
- "student: submit assignment",
87
- "student: view grade"
88
- ],
89
- "conditions": {
90
- "role": "student"
91
- },
92
- "isFirstFunnel": false,
93
- "conversionRate": 70,
94
- "timeToConvert": 48,
95
- "order": "first-and-last-fixed",
96
- "props": {
97
- "assignment_type": "homework"
98
- }
99
- },
100
- {
101
- "name": "Student Takes Test",
102
- "conditions": {
103
- "role": "student"
104
- },
105
- "sequence": [
106
- "student: view assignment",
107
- "student: start test",
108
- "student: answer question",
109
- "student: submit test",
110
- "student: view grade"
111
- ],
112
- "isFirstFunnel": false,
113
- "conversionRate": 85,
114
- "timeToConvert": 2,
115
- "order": "sequential",
116
- "props": {
117
- "assignment_type": "test"
118
- }
119
- },
120
- {
121
- "name": "Teacher Grades Assignment",
122
- "conditions": {
123
- "role": "teacher"
124
- },
125
- "sequence": [
126
- "teacher: create assignment",
127
- "teacher: assign homework",
128
- "teacher: grade submission"
129
- ],
130
- "isFirstFunnel": false,
131
- "conversionRate": 90,
132
- "timeToConvert": 72,
133
- "order": "sequential"
134
- },
135
- {
136
- "name": "Teacher Daily Lesson",
137
- "sequence": [
138
- "teacher: take attendance",
139
- "teacher: start lesson",
140
- "teacher: end lesson"
141
- ],
142
- "conditions": {
143
- "role": "teacher"
144
- },
145
- "isFirstFunnel": false,
146
- "conversionRate": 99,
147
- "timeToConvert": 1,
148
- "order": "sequential"
149
- },
150
- {
151
- "name": "all peoples doing stuf (no conditions)",
152
- "sequence": [
153
- "foo",
154
- "bar",
155
- "baz"
156
- ]
157
- }
158
- ],
159
- "events": [
160
- {
161
- "event": "student: login",
162
- "weight": 10,
163
- "isFirstEvent": true
164
- },
165
- {
166
- "event": "teacher: login",
167
- "weight": 2,
168
- "isFirstEvent": true
169
- },
170
- {
171
- "event": "student: join class",
172
- "weight": 5,
173
- "properties": {
174
- "join_method": [
175
- "class_code",
176
- "email_invite",
177
- "admin_added"
178
- ]
179
- }
180
- },
181
- {
182
- "event": "teacher: create class",
183
- "weight": 1
184
- },
185
- {
186
- "event": "student: view assignment",
187
- "weight": 15,
188
- "properties": {
189
- "assignment_id": "range(1, 500)",
190
- "subject_id": "range(1, 20)"
191
- }
192
- },
193
- {
194
- "event": "student: start assignment",
195
- "weight": 12,
196
- "properties": {
197
- "assignment_id": "range(1, 500)"
198
- }
199
- },
200
- {
201
- "event": "student: submit assignment",
202
- "weight": 10,
203
- "properties": {
204
- "assignment_id": "range(1, 500)",
205
- "time_spent_minutes": "weighNumRange(5, 120, 0.4)",
206
- "is_late": [
207
- true,
208
- false,
209
- false,
210
- false,
211
- false
212
- ]
213
- }
214
- },
215
- {
216
- "event": "student: start test",
217
- "weight": 8,
218
- "properties": {
219
- "assignment_id": "range(1, 500)",
220
- "subject_id": "range(1, 20)"
221
- }
222
- },
223
- {
224
- "event": "student: answer question",
225
- "weight": 40,
226
- "properties": {
227
- "assignment_id": "range(1, 500)",
228
- "is_correct": [
229
- true,
230
- true,
231
- true,
232
- false
233
- ],
234
- "time_to_answer_sec": "weighNumRange(10, 300, 0.6)"
235
- }
236
- },
237
- {
238
- "event": "student: submit test",
239
- "weight": 7,
240
- "properties": {
241
- "assignment_id": "range(1, 500)",
242
- "time_spent_minutes": "weighNumRange(20, 90, 0.5)"
243
- }
244
- },
245
- {
246
- "event": "student: view grade",
247
- "weight": 9,
248
- "properties": {
249
- "assignment_id": "range(1, 500)",
250
- "score_percent": "weighNumRange(40, 100, 1.5)"
251
- }
252
- },
253
- {
254
- "event": "teacher: take attendance",
255
- "weight": 3,
256
- "properties": {
257
- "absent_students": "weighNumRange(0, 5, 0.2)"
258
- }
259
- },
260
- {
261
- "event": "teacher: start lesson",
262
- "weight": 4,
263
- "properties": {
264
- "subject_id": "range(1, 20)",
265
- "lesson_topic": [
266
- "Review",
267
- "New Material",
268
- "Group Work",
269
- "Lab",
270
- "Presentation"
271
- ]
272
- }
273
- },
274
- {
275
- "event": "teacher: end lesson",
276
- "weight": 4
277
- },
278
- {
279
- "event": "teacher: create assignment",
280
- "weight": 2,
281
- "properties": {
282
- "assignment_id": "range(1, 500)",
283
- "subject_id": "range(1, 20)"
284
- }
285
- },
286
- {
287
- "event": "teacher: assign homework",
288
- "weight": 2,
289
- "properties": {
290
- "assignment_id": "range(1, 500)",
291
- "due_date": "date(14, false, 'YYYY-MM-DD')"
292
- }
293
- },
294
- {
295
- "event": "teacher: grade submission",
296
- "weight": 6,
297
- "properties": {
298
- "assignment_id": "range(1, 500)",
299
- "score_percent": "weighNumRange(40, 100, 1.5)",
300
- "feedback_provided": [
301
- true,
302
- true,
303
- false
304
- ]
305
- }
306
- },
307
- {
308
- "event": "teacher: post announcement",
309
- "weight": 1,
310
- "properties": {
311
- "category": [
312
- "General",
313
- "Reminder",
314
- "Kudos",
315
- "Event"
316
- ]
317
- }
318
- },
319
- {
320
- "event": "foo"
321
- },
322
- {
323
- "event": "bar"
324
- },
325
- {
326
- "event": "baz"
327
- }
328
- ],
329
- "superProps": {
330
- "device_type": [
331
- "desktop",
332
- "tablet",
333
- "desktop",
334
- "chromebook"
335
- ],
336
- "browser": [
337
- "Chrome",
338
- "Chrome",
339
- "Chrome",
340
- "Safari",
341
- "Edge"
342
- ],
343
- "connection_type": [
344
- "wifi",
345
- "wifi",
346
- "ethernet"
347
- ]
348
- },
349
- "userProps": {
350
- "role": [
351
- "student",
352
- "student",
353
- "student",
354
- "student",
355
- "student",
356
- "student",
357
- "student",
358
- "student",
359
- "student",
360
- "teacher"
361
- ],
362
- },
363
- "scdProps": {
364
- "gpa": {
365
- "type": "user",
366
- "frequency": "month",
367
- "values": "weighNumRange(1.0, 4.0, 1.2)",
368
- "timing": "fuzzy",
369
- "max": 12
370
- },
371
- "grade_level": {
372
- "type": "user",
373
- "frequency": "year",
374
- "values": [
375
- "1st",
376
- "2nd",
377
- "3rd",
378
- "4th",
379
- "5th",
380
- "6th",
381
- "7th",
382
- "8th",
383
- "9th",
384
- "10th",
385
- "11th",
386
- "12th"
387
- ],
388
- "timing": "fixed",
389
- "max": 12
390
- }
391
- },
392
-
393
-
394
- hook: function (record, type, meta) {
395
- const NOW = dayjs();
396
-
397
- if (type === "event") {
398
- const EVENT_TIME = dayjs(record.time);
399
- // Pattern 1: Late submissions get lower scores
400
- if (record.event === "student: submit assignment" && record.is_late === true) {
401
- record.late_penalty_percent = chance.integer({ min: 5, max: 25 });
402
- }
403
- }
404
-
405
- if (type === "user") {
406
- // Pattern 2: Teachers get a department assignment
407
- if (record.role === "teacher") {
408
- record.department = chance.pickone(["Math", "Science", "English", "History", "Art", "PE"]);
409
- record.years_experience = chance.integer({ min: 1, max: 30 });
410
- }
411
- }
412
-
413
- if (type === "funnel-pre") {
414
- // Pattern 3: Students on chromebooks have lower test completion rates
415
- if (meta && meta.profile && meta.profile.device_type === "chromebook") {
416
- if (record.name === "Student Takes Test") {
417
- record.conversionRate = Math.max(50, record.conversionRate * 0.7);
418
- }
419
- }
420
- }
421
-
422
- if (type === "funnel-post") {
423
-
424
- }
425
-
426
- if (type === "scd-pre") {
427
-
428
- }
429
-
430
- if (type === "everything") {
431
-
432
- }
433
-
434
- return record;
435
- }
436
- };
437
-
438
- export default config;
@@ -1,203 +0,0 @@
1
- /**
2
- * "Too Big Events" dungeon
3
- * Tests Mixpanel row limit (1MB) and column limit (8KB for arrays of objects)
4
- * Generates events with absurd numbers of properties and oversized array-of-object columns
5
- */
6
-
7
- import dayjs from "dayjs";
8
- import utc from "dayjs/plugin/utc.js";
9
- dayjs.extend(utc);
10
-
11
- function integer(min = 1, max = 100) {
12
- if (min === max) return min;
13
- if (min > max) [min, max] = [max, min];
14
- return Math.floor(Math.random() * (max - min + 1)) + min;
15
- }
16
-
17
- function loremChunk(size = 200) {
18
- const words = ["foo", "bar", "baz", "qux", "garply", "waldo", "fred", "plugh", "xyzzy", "thud", "corge", "grault", "flob", "zorp", "narf", "blip", "snork", "quux", "wobble", "crumn"];
19
- let result = "";
20
- while (result.length < size) {
21
- result += words[Math.floor(Math.random() * words.length)] + " ";
22
- }
23
- return result.trim();
24
- }
25
-
26
- // Generate a fat array of objects (targeting >8KB per column)
27
- function bigArrayOfObjects(numItems = 50) {
28
- numItems = numItems * 2
29
- return () => {
30
- const arr = [];
31
- for (let i = 0; i < numItems; i++) {
32
- arr.push({
33
- id: `item_${i}_${Math.random().toString(36).slice(2, 10)}`,
34
- name: loremChunk(80),
35
- description: loremChunk(150),
36
- category: ["foo", "bar", "baz", "qux"][Math.floor(Math.random() * 4)],
37
- price: parseFloat((Math.random() * 999).toFixed(2)),
38
- quantity: integer(1, 100),
39
- tags: ["alpha", "beta", "gamma", "delta", "epsilon"].slice(0, integer(1, 5)),
40
- metadata: {
41
- source: loremChunk(40),
42
- ref: Math.random().toString(36).slice(2, 14),
43
- ts: new Date().toISOString()
44
- }
45
- });
46
- }
47
- return arr;
48
- };
49
- }
50
-
51
- // Generate a truly massive array of objects (way over 8KB)
52
- function hugeArrayOfObjects() {
53
- return bigArrayOfObjects(150)();
54
- }
55
-
56
- // Build a ton of flat properties to bloat row size toward 1MB
57
- function manyProperties(count = 200) {
58
- count = count * 2
59
- const props = {};
60
- for (let i = 0; i < count; i++) {
61
- const type = i % 4;
62
- if (type === 0) props[`str_prop_${i}`] = () => loremChunk(300);
63
- else if (type === 1) props[`num_prop_${i}`] = () => integer(1, 999999);
64
- else if (type === 2) props[`bool_prop_${i}`] = [true, false];
65
- else props[`list_prop_${i}`] = () => Array.from({ length: integer(5, 20) }, () => loremChunk(50));
66
- }
67
- return props;
68
- }
69
-
70
- const seed = "too-big-" + Math.random().toString(36).slice(2, 8);
71
-
72
- /** @type {import('../types').Dungeon} */
73
- const config = {
74
- token: "",
75
- seed: seed,
76
- numDays: 30,
77
- numEvents: 1000,
78
- numUsers: 50,
79
- format: 'json',
80
- region: "US",
81
- hasAnonIds: false,
82
- hasSessionIds: false,
83
- batchSize: 10000,
84
- hasAdSpend: false,
85
- hasAvatar: false,
86
- hasBrowser: false,
87
- hasCampaigns: false,
88
- hasIOSDevices: false,
89
- hasLocation: false,
90
- isAnonymous: true,
91
- hasAndroidDevices: false,
92
- hasDesktopDevices: false,
93
- writeToDisk: false,
94
- concurrency: 1,
95
-
96
- events: [
97
- {
98
- // ~200 string/number/bool/list properties = fat rows approaching 1MB
99
- event: "mega_row",
100
- weight: 5,
101
- properties: {
102
- ...manyProperties(250),
103
- // also throw in some big array-of-object columns
104
- cart_items: bigArrayOfObjects(60),
105
- order_history: bigArrayOfObjects(80),
106
- }
107
- },
108
- {
109
- // single event focused on huge array-of-object columns (well over 8KB each)
110
- event: "array_bomb",
111
- weight: 5,
112
- properties: {
113
- massive_list_a: bigArrayOfObjects(150),
114
- massive_list_b: bigArrayOfObjects(150),
115
- massive_list_c: bigArrayOfObjects(100),
116
- some_prop: ["foo", "bar", "baz"],
117
- another_prop: () => integer(1, 1000),
118
- }
119
- },
120
- {
121
- // moderate event with a mix of oversized columns
122
- event: "chonky_boi",
123
- weight: 3,
124
- properties: {
125
- ...manyProperties(100),
126
- nested_blob: () => {
127
- const obj = {};
128
- for (let i = 0; i < 50; i++) {
129
- obj[`key_${i}`] = {
130
- value: loremChunk(200),
131
- items: Array.from({ length: 20 }, (_, j) => ({
132
- id: j,
133
- data: loremChunk(100),
134
- flag: Math.random() > 0.5
135
- }))
136
- };
137
- }
138
- return obj;
139
- },
140
- product_catalog: bigArrayOfObjects(120),
141
- }
142
- },
143
- {
144
- // normal-ish event for contrast
145
- event: "smol_event",
146
- weight: 2,
147
- properties: {
148
- color: ["red", "blue", "green"],
149
- count: () => integer(1, 10),
150
- }
151
- }
152
- ],
153
-
154
- superProps: {},
155
- userProps: {
156
- name: () => `user_${Math.random().toString(36).slice(2, 8)}`,
157
- },
158
-
159
- scdProps: {},
160
- mirrorProps: {},
161
- lookupTables: [],
162
- groupKeys: [],
163
- groupProps: {},
164
-
165
- hook: function (record, type, meta) {
166
- // --- event hook: tag events with estimated row size category ---
167
- if (type === "event") {
168
- const propCount = Object.keys(record).length;
169
- if (propCount > 300) {
170
- record.size_class = "mega";
171
- } else if (propCount > 100) {
172
- record.size_class = "large";
173
- } else {
174
- record.size_class = "normal";
175
- }
176
- return record;
177
- }
178
-
179
- // --- everything hook: append a summary event tallying the user's event types ---
180
- if (type === "everything" && record.length > 0) {
181
- const counts = {};
182
- for (const e of record) {
183
- counts[e.event] = (counts[e.event] || 0) + 1;
184
- }
185
- const lastEvent = record[record.length - 1];
186
- record.push({
187
- event: "user_event_summary",
188
- time: dayjs(lastEvent.time).add(1, "second").toISOString(),
189
- user_id: lastEvent.user_id,
190
- mega_row_count: counts["mega_row"] || 0,
191
- array_bomb_count: counts["array_bomb"] || 0,
192
- chonky_boi_count: counts["chonky_boi"] || 0,
193
- smol_event_count: counts["smol_event"] || 0,
194
- total_events: record.length
195
- });
196
- return record;
197
- }
198
-
199
- return record;
200
- }
201
- };
202
-
203
- export default config;