make-mp-data 3.0.2 → 3.0.4

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 (47) hide show
  1. package/dungeons/adspend.js +13 -26
  2. package/dungeons/anon.js +1 -1
  3. package/dungeons/array-of-object-lookup.js +1 -2
  4. package/dungeons/benchmark-heavy.js +5 -6
  5. package/dungeons/benchmark-light.js +13 -28
  6. package/dungeons/big.js +3 -3
  7. package/dungeons/business.js +11 -12
  8. package/dungeons/complex.js +1 -2
  9. package/dungeons/copilot.js +8 -6
  10. package/dungeons/education.js +21 -22
  11. package/dungeons/experiments.js +4 -5
  12. package/dungeons/fintech.js +25 -26
  13. package/dungeons/foobar.js +1 -1
  14. package/dungeons/food.js +24 -25
  15. package/dungeons/funnels.js +2 -2
  16. package/dungeons/gaming.js +39 -40
  17. package/dungeons/media.js +30 -31
  18. package/dungeons/mil.js +17 -18
  19. package/dungeons/mirror.js +2 -3
  20. package/dungeons/retention-cadence.js +1 -2
  21. package/dungeons/rpg.js +42 -43
  22. package/dungeons/sanity.js +1 -2
  23. package/dungeons/sass.js +32 -33
  24. package/dungeons/scd.js +3 -4
  25. package/dungeons/simple.js +13 -14
  26. package/dungeons/social.js +27 -28
  27. package/dungeons/soup-test.js +52 -0
  28. package/dungeons/streaming.js +17 -18
  29. package/dungeons/student-teacher.js +0 -1
  30. package/dungeons/text-generation.js +0 -1
  31. package/dungeons/user-agent.js +1 -2
  32. package/index.js +18 -6
  33. package/lib/core/config-validator.js +22 -33
  34. package/lib/core/context.js +6 -3
  35. package/lib/generators/events.js +13 -10
  36. package/lib/generators/funnels.js +7 -4
  37. package/lib/generators/scd.js +29 -17
  38. package/lib/generators/text.js +18 -12
  39. package/lib/orchestrators/mixpanel-sender.js +26 -38
  40. package/lib/orchestrators/user-loop.js +68 -15
  41. package/lib/templates/phrases.js +8 -5
  42. package/lib/utils/function-registry.js +17 -0
  43. package/lib/utils/utils.js +15 -84
  44. package/package.json +3 -1
  45. package/types.d.ts +86 -19
  46. package/lib/templates/verbose-schema.js +0 -272
  47. package/lib/utils/chart.js +0 -210
@@ -1,210 +0,0 @@
1
- /** @typedef {import('../../types.js').EventSchema} EventSchema */
2
- /** @typedef {import('../../types.js').Result} Result */
3
- /** @typedef {import('../../types.js').Context} Context */
4
-
5
- // import { ChartJSNodeCanvas } from 'chartjs-node-canvas';
6
- import fs from 'fs';
7
- import * as u from 'ak-tools';
8
- import dayjs from 'dayjs';
9
- import { openFinder } from './utils.js';
10
- import { dataLogger as logger } from './logger.js';
11
- const { existsSync } = fs;
12
- import path from 'path';
13
- import 'dotenv/config';
14
- const { NODE_ENV = "unknown" } = process.env;
15
-
16
-
17
- let tempDir;
18
- const dataFolder = path.resolve("./data");
19
- if (existsSync(dataFolder)) tempDir = dataFolder;
20
- else tempDir = path.resolve("./");
21
-
22
-
23
- // Function to count events per day
24
- function countDailyEvents(eventData) {
25
- const dailyCounts = {};
26
-
27
- eventData.forEach(event => {
28
- const date = dayjs(event.time).format('YYYY-MM-DD');
29
- if (!dailyCounts[date]) {
30
- dailyCounts[date] = 0;
31
- }
32
- dailyCounts[date]++;
33
- });
34
-
35
- return dailyCounts;
36
- }
37
-
38
- // Function to count daily users
39
- function countDailyUsers(eventData) {
40
- const dailyUsers = {};
41
-
42
- eventData.forEach(event => {
43
- const date = dayjs(event.time).format('YYYY-MM-DD');
44
- if (!dailyUsers[date]) {
45
- dailyUsers[date] = new Set();
46
- }
47
- dailyUsers[date].add(event.user_id);
48
- });
49
-
50
- return dailyUsers;
51
- }
52
-
53
- // Function to count daily new users based on signup events
54
- function countDailyNewUsers(eventData, signupEvents) {
55
- const dailyNewUsers = {};
56
- const seenUsers = new Set();
57
-
58
- eventData.forEach(event => {
59
- const date = dayjs(event.time).format('YYYY-MM-DD');
60
- if (!dailyNewUsers[date]) {
61
- dailyNewUsers[date] = new Set();
62
- }
63
- if (signupEvents.includes(event.event) && !seenUsers.has(event.user_id)) {
64
- dailyNewUsers[date].add(event.user_id);
65
- seenUsers.add(event.user_id);
66
- }
67
- });
68
-
69
- return dailyNewUsers;
70
- }
71
-
72
- // Function to generate line chart
73
- async function generateLineChart(rawData, signupEvents = ["sign up"], fileName) {
74
- // COMMENTED OUT: Canvas dependency removed
75
- throw new Error("Chart generation is temporarily disabled - canvas dependency removed");
76
-
77
- // const width = 1600;
78
- // const height = 1200;
79
- // const chartJSNodeCanvas = new ChartJSNodeCanvas({ width, height, backgroundColour: 'black' });
80
- const eventData = countDailyEvents(rawData);
81
- const userData = countDailyUsers(rawData);
82
- const newUserData = countDailyNewUsers(rawData, signupEvents);
83
-
84
- // @ts-ignore
85
- const sortedEventEntries = Object.entries(eventData).sort((a, b) => new Date(a[0]) - new Date(b[0]));
86
- const eventLabels = sortedEventEntries.map(entry => entry[0]);
87
- const eventValues = sortedEventEntries.map(entry => entry[1]);
88
-
89
- // @ts-ignore
90
- const sortedUserEntries = Object.entries(userData).sort((a, b) => new Date(a[0]) - new Date(b[0]));
91
- const userLabels = sortedUserEntries.map(entry => entry[0]);
92
- const userValues = sortedUserEntries.map(entry => entry[1].size);
93
-
94
- // @ts-ignore
95
- const sortedNewUserEntries = Object.entries(newUserData).sort((a, b) => new Date(a[0]) - new Date(b[0]));
96
- const newUserLabels = sortedNewUserEntries.map(entry => entry[0]);
97
- const newUserValues = sortedNewUserEntries.map(entry => entry[1].size);
98
-
99
- const configuration = {
100
- type: 'line',
101
- data: {
102
- labels: eventLabels,
103
- datasets: [
104
- {
105
- label: '# EVENTS',
106
- data: eventValues,
107
- yAxisID: 'y1',
108
- fill: true,
109
- borderColor: '#4F44E0',
110
- tension: 0.1
111
- },
112
- // {
113
- // label: '# USERS',
114
- // data: userValues,
115
- // yAxisID: 'y2',
116
- // fill: true,
117
- // borderColor: '#E34F2F',
118
- // tension: 0.1
119
- // },
120
- {
121
- label: '# NEW',
122
- data: newUserValues,
123
- yAxisID: 'y3',
124
- fill: true,
125
- borderColor: '#219464',
126
- tension: 0.1
127
- }
128
- ]
129
- },
130
- options: {
131
- scales: {
132
- x: {
133
- title: {
134
- display: true,
135
- text: 'Date',
136
- color: 'white'
137
- },
138
- ticks: {
139
- color: 'white'
140
- }
141
- },
142
- y1: {
143
- type: 'linear',
144
- display: true,
145
- position: 'left',
146
- title: {
147
- display: true,
148
- text: 'Count of Events',
149
- color: '#4F44E0'
150
- },
151
- ticks: {
152
- color: '#4F44E0'
153
- }
154
- },
155
- y3: {
156
- type: 'linear',
157
- display: true,
158
- position: 'right',
159
- offset: true,
160
- title: {
161
- display: true,
162
- text: 'Count of New Users',
163
- color: '#219464'
164
- },
165
- ticks: {
166
- color: '#219464'
167
- },
168
- grid: {
169
- drawOnChartArea: false
170
- }
171
- }
172
- },
173
- plugins: {
174
- legend: {
175
- labels: {
176
- color: 'white'
177
- }
178
- }
179
- }
180
- }
181
- };
182
-
183
- // @ts-ignore
184
- if (typeof fileName === undefined) fileName = 'chart';
185
- if (typeof fileName !== 'string') fileName = 'chart';
186
- // @ts-ignore
187
- // const imageBuffer = await chartJSNodeCanvas.renderToBuffer(configuration);
188
- // const filePath = path.join(tempDir, `${fileName}.png`);
189
- // const removed = await u.rm(filePath);
190
- // @ts-ignore - imageBuffer is a Buffer but touch accepts it
191
- // const file = await u.touch(filePath, imageBuffer);
192
-
193
- // logger.info({ filename: `${fileName}.png` }, `📊 Chart saved as ${fileName}.png`);
194
- // openFinder(path)
195
- // return file;
196
- }
197
-
198
- export { generateLineChart };
199
-
200
-
201
-
202
- if (import.meta.url === `file://${process.argv[1]}`) {
203
- generateLineChart()
204
- .then((result)=>{
205
- if (NODE_ENV === "dev") debugger;
206
- })
207
- .catch((error)=>{
208
- if (NODE_ENV === "dev") debugger;
209
- })
210
- }