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,141 @@
1
+ /**
2
+ * Benchmark Dungeon Configuration
3
+ * Generates one million events across 10,000 users
4
+ * ensure we have multiple property types and distributions
5
+ */
6
+
7
+
8
+
9
+
10
+ import Chance from 'chance';
11
+ let chance = new Chance();
12
+ import dayjs from "dayjs";
13
+ import utc from "dayjs/plugin/utc.js";
14
+ dayjs.extend(utc);
15
+ import { uid, comma } from 'ak-tools';
16
+ import { pickAWinner, weighNumRange, date, integer, weighChoices } from "../lib/utils/utils.js";
17
+ import { createTextGenerator } from '../lib/generators/text.js';
18
+
19
+ /** @type {import('../types.js').Dungeon} */
20
+ const config = {
21
+ // token: "",
22
+ name: "5M-Events-Light",
23
+ format: 'json', //csv or json
24
+ seed: "one million events",
25
+ numDays: 92, //how many days worth of data
26
+ numEvents: 5_000_000, //how many events
27
+ numUsers: 10_000, //how many users
28
+ strictEventCount: true,
29
+
30
+ region: "US",
31
+ hasAnonIds: false, //if true, anonymousIds are created for each user
32
+ hasSessionIds: false, //if true, hasSessionIds are created for each user
33
+ hasAdSpend: false,
34
+ makeChart: false,
35
+ hasLocation: false,
36
+ hasAndroidDevices: false,
37
+ hasIOSDevices: false,
38
+ hasDesktopDevices: false,
39
+ hasBrowser: false,
40
+ hasCampaigns: false,
41
+ isAnonymous: false,
42
+ alsoInferFunnels: true,
43
+ // concurrency automatically set to 1 when strictEventCount is enabled
44
+ writeToDisk: false,
45
+ batchSize: 12_500_000,
46
+
47
+ events: [
48
+ {
49
+ event: "Page View",
50
+ weight: 50,
51
+
52
+ },
53
+ {
54
+ event: "Product View",
55
+ weight: 30,
56
+ },
57
+ {
58
+ event: "Add to Cart",
59
+ weight: 10,
60
+ },
61
+ {
62
+ event: "Checkout Started",
63
+ weight: 5,
64
+ },
65
+ {
66
+ event: "Purchase",
67
+ weight: 1,
68
+ },
69
+ {
70
+ event: "Product Review",
71
+ weight: 3,
72
+ },
73
+ {
74
+ event: "Search",
75
+ weight: 17,
76
+ },
77
+ {
78
+ event: "Browse",
79
+ weight: 25,
80
+
81
+ },
82
+ {
83
+ event: "Save for Later",
84
+ weight: 4,
85
+ },
86
+ {
87
+ event: "Remove from Cart",
88
+ weight: 2,
89
+ },
90
+ {
91
+ event: "Empty Cart",
92
+ weight: 4,
93
+ }
94
+ ],
95
+ funnels: [
96
+ {
97
+ "name": "Purchase Funnel",
98
+ "sequence": [
99
+ "Page View",
100
+ "Product View",
101
+ "Add to Cart",
102
+ "Checkout Started",
103
+ "Purchase"
104
+ ],
105
+ requireRepeats: true,
106
+ "conversionRate": 30,
107
+ "order": "fixed",
108
+ "weight": 1,
109
+ "isFirstFunnel": false,
110
+ "timeToConvert": 5,
111
+ "experiment": true,
112
+ }
113
+ ],
114
+ superProps: {
115
+ },
116
+ /*
117
+ user properties work the same as event properties
118
+ each key should be an array or function reference
119
+ */
120
+ userProps: {},
121
+ scdProps: {},
122
+ mirrorProps: {},
123
+
124
+ /*
125
+ for group analytics keys, we need an array of arrays [[],[],[]]
126
+ each pair represents a group_key and the number of profiles for that key
127
+ */
128
+ groupKeys: [],
129
+ groupProps: {},
130
+ lookupTables: [],
131
+ hook: function (record, type, meta) {
132
+ // if (type === "everything") {
133
+ // debugger;
134
+ // }
135
+ return record;
136
+ }
137
+ };
138
+
139
+
140
+
141
+ export default config;
package/dungeons/big.js CHANGED
@@ -1,34 +1,35 @@
1
1
  import Chance from 'chance';
2
2
  import dayjs from 'dayjs';
3
- import utc from 'dayjs/plugin/utc';
3
+ import utc from 'dayjs/plugin/utc.js';
4
4
  import { uid, comma, makeName } from 'ak-tools';
5
- import { pickAWinner, weighNumRange, integer, date, choose } from '../lib/utils/utils.js';
5
+ import { pickAWinner, weighNumRange, integer, date, choose } from "../lib/utils/utils.js";
6
6
 
7
7
  const seed = "lets go big";
8
8
  const chance = new Chance();
9
9
  dayjs.extend(utc);
10
10
 
11
11
 
12
- const eventsPerQuarter = 5_000_000_000 // ~5 billion
13
- const numQuarters = 8; // 24 months
14
- const parallelism = 5000;
15
- const totalEvents = Math.floor((eventsPerQuarter * numQuarters) / parallelism);
12
+ const eventsPerQuarter = 10_000_000 // 50M
13
+ const numQuarters = 4; // 12 months
14
+ // const parallelism = 5000;
15
+ const totalEvents = Math.floor((eventsPerQuarter * numQuarters));
16
16
  const eventPerUser = 500;
17
17
  const totalUsers = Math.floor(totalEvents / eventPerUser);
18
18
  const totalDays = (numQuarters * 90) + 10;
19
19
 
20
20
  /** @type {import('../types').Dungeon} */
21
21
  const config = {
22
- token: "",
22
+ // token: "",
23
23
  seed: seed,
24
24
  numDays: totalDays,
25
25
  numEvents: totalEvents,
26
26
  numUsers: totalUsers,
27
+ strictEventCount: true,
27
28
  format: 'json', //csv or json
28
29
  region: "US",
29
30
  hasAnonIds: false, //if true, anonymousIds are created for each user
30
31
  hasSessionIds: false, //if true, hasSessionIds are created for each user
31
- hasLocation: true,
32
+ hasLocation: false,
32
33
  hasAndroidDevices: false,
33
34
  alsoInferFunnels: false,
34
35
  batchSize: 2_000_000,
@@ -38,7 +39,7 @@ const config = {
38
39
  hasCampaigns: false,
39
40
  hasDesktopDevices: false,
40
41
  hasIOSDevices: false,
41
- writeToDisk: "gs://dungeon_master_4/big_data",
42
+ writeToDisk: false,
42
43
  funnels: [
43
44
  {
44
45
  "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny", "fonk", "crumn", "yak"],
@@ -1,20 +1,21 @@
1
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
2
+ * Video platform dungeon (business/complex mode)
6
3
  */
7
4
 
5
+ import Chance from 'chance';
6
+ import dayjs from 'dayjs';
7
+ import utc from 'dayjs/plugin/utc.js';
8
+ dayjs.extend(utc);
9
+ import { weighNumRange, pickAWinner, exhaust } from '../lib/utils/utils.js';
10
+ import * as v from 'ak-tools';
8
11
 
9
- const Chance = require('chance');
10
12
  const chance = new Chance();
11
- const { weighNumRange, date, integer, pickAWinner, exhaust } = require('../lib/utils/utils.js');
12
- const u = require('ak-tools');
13
+ const integer = (min, max) => chance.integer({ min, max });
13
14
 
14
15
  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 channel_names = chance.n(v.makeName, 1234);
16
17
  const video_ids = [...Array(50000).keys()].map(i => i + 1).map(n => n.toString());
17
- const video_names = chance.n(u.makeName, 50000);
18
+ const video_names = chance.n(v.makeName, 50000);
18
19
 
19
20
  const EVENTS = 50_000
20
21
  const USERS = EVENTS / 100
@@ -22,7 +23,7 @@ const USERS = EVENTS / 100
22
23
 
23
24
  /** @type {import('../types.js').Dungeon} */
24
25
  const config = {
25
- token: "",
26
+ token: "",
26
27
  seed: "it's business time...",
27
28
  numDays: 90, //how many days worth of data
28
29
  numEvents: EVENTS, //how many events
@@ -41,6 +42,7 @@ const config = {
41
42
  hasAdSpend: true,
42
43
 
43
44
  hasAvatar: false,
45
+ makeChart: true,
44
46
 
45
47
  batchSize: 500_000,
46
48
  concurrency: 500,
@@ -257,6 +259,52 @@ const config = {
257
259
  ],
258
260
 
259
261
  hook: function (record, type, meta) {
262
+ // --- user hook: tag users by their experiment variant ---
263
+ if (type === "user") {
264
+ const exp = record.experiment;
265
+ if (exp && Array.isArray(exp) && exp[0]) {
266
+ record.experimentGroup = exp[0].variant || "unknown";
267
+ }
268
+ return record;
269
+ }
270
+
271
+ // --- event hook: weekend watch time boost + premium quality bias ---
272
+ if (type === "event") {
273
+ if (record.event === "watch video" && record.time) {
274
+ const day = dayjs(record.time).day();
275
+ if (day === 0 || day === 6) {
276
+ record["watch time (sec)"] = Math.round((record["watch time (sec)"] || 60) * 1.8);
277
+ record.is_weekend_session = true;
278
+ }
279
+ }
280
+ // app errors on weekends are more severe (skeleton crew)
281
+ if (record.event === "app error" && record.time) {
282
+ const day = dayjs(record.time).day();
283
+ if (day === 0 || day === 6) {
284
+ record.weekend_incident = true;
285
+ }
286
+ }
287
+ return record;
288
+ }
289
+
290
+ // --- everything hook: binge watchers (5+ watch events) get a "binge_session" event ---
291
+ if (type === "everything") {
292
+ const watches = record.filter(e => e.event === "watch video");
293
+ if (watches.length >= 5) {
294
+ const totalWatchTime = watches.reduce((sum, e) => sum + (e["watch time (sec)"] || 0), 0);
295
+ const lastWatch = watches[watches.length - 1];
296
+ record.push({
297
+ event: "binge_session",
298
+ time: dayjs(lastWatch.time).add(1, "minute").toISOString(),
299
+ user_id: lastWatch.user_id,
300
+ videos_watched: watches.length,
301
+ total_watch_time_sec: totalWatchTime,
302
+ avg_watch_time_sec: Math.round(totalWatchTime / watches.length)
303
+ });
304
+ }
305
+ return record;
306
+ }
307
+
260
308
  return record;
261
309
  }
262
310
  };
@@ -266,7 +314,7 @@ const config = {
266
314
  function makeHashTags() {
267
315
  const possibleHashtags = [];
268
316
  for (let i = 0; i < 20; i++) {
269
- possibleHashtags.push('#' + u.makeName(2, ''));
317
+ possibleHashtags.push('#' + v.makeName(2, ''));
270
318
  }
271
319
 
272
320
  const numHashtags = integer(integer(1, 5), integer(5, 10));
@@ -341,4 +389,4 @@ function designExperiment() {
341
389
 
342
390
 
343
391
 
344
- module.exports = config;
392
+ export default config;
@@ -8,7 +8,10 @@
8
8
 
9
9
  import Chance from 'chance';
10
10
  const chance = new Chance();
11
- import { weighNumRange, date, integer } from '../lib/utils/utils.js';
11
+ import dayjs from "dayjs";
12
+ import utc from "dayjs/plugin/utc.js";
13
+ dayjs.extend(utc);
14
+ import { weighNumRange, date, integer } from "../lib/utils/utils.js";
12
15
  import * as u from 'ak-tools';
13
16
 
14
17
  /** @type {import('../types.js').Dungeon} */
@@ -33,6 +36,7 @@ const config = {
33
36
  hasAdSpend: true,
34
37
 
35
38
  hasAvatar: true,
39
+ makeChart: false,
36
40
 
37
41
  batchSize: 500_000,
38
42
  concurrency: 10,
@@ -280,6 +284,36 @@ const config = {
280
284
  ],
281
285
 
282
286
  hook: function (record, type, meta) {
287
+ // event hook: weekend watch time boost — videos watched on weekends get 1.5x duration
288
+ if (type === "event") {
289
+ if (record.event === "watch video" && record.time) {
290
+ const day = dayjs(record.time).day();
291
+ if (day === 0 || day === 6) {
292
+ record.watchTimeSec = Math.round((record.watchTimeSec || 60) * 1.5);
293
+ record.is_weekend = true;
294
+ }
295
+ }
296
+ // support tickets on high-severity get escalated flag
297
+ if (record.event === "support ticket" && record.severity === "high") {
298
+ record.escalated = true;
299
+ }
300
+ }
301
+
302
+ // everything hook: simulate cart abandonment — users who "add to cart" but never "checkout" lose their last add-to-cart
303
+ if (type === "everything") {
304
+ const hasCheckout = record.some(e => e.event === "checkout");
305
+ const hasAddToCart = record.some(e => e.event === "add to cart");
306
+ if (hasAddToCart && !hasCheckout) {
307
+ // mark all their add-to-cart events as abandoned
308
+ for (const e of record) {
309
+ if (e.event === "add to cart") {
310
+ e.abandoned = true;
311
+ }
312
+ }
313
+ }
314
+ return record;
315
+ }
316
+
283
317
  return record;
284
318
  }
285
319
  };