make-mp-data 2.0.0 → 2.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.
- package/dungeons/adspend.js +96 -0
- package/dungeons/anon.js +104 -0
- package/dungeons/big.js +225 -0
- package/dungeons/business.js +345 -0
- package/dungeons/complex.js +396 -0
- package/dungeons/experiments.js +125 -0
- package/dungeons/foobar.js +241 -0
- package/dungeons/funnels.js +272 -0
- package/dungeons/gaming.js +315 -0
- package/dungeons/media.js +7 -7
- package/dungeons/mirror.js +129 -0
- package/dungeons/sanity.js +113 -0
- package/dungeons/scd.js +205 -0
- package/dungeons/simple.js +195 -0
- package/dungeons/userAgent.js +190 -0
- package/entry.js +57 -0
- package/index.js +96 -68
- package/lib/cli/cli.js +10 -5
- package/lib/core/config-validator.js +28 -12
- package/lib/core/context.js +147 -130
- package/lib/core/storage.js +45 -31
- package/lib/data/defaults.js +2 -2
- package/lib/generators/adspend.js +1 -2
- package/lib/generators/events.js +35 -24
- package/lib/generators/funnels.js +1 -2
- package/lib/generators/mirror.js +1 -2
- package/lib/orchestrators/mixpanel-sender.js +15 -7
- package/lib/orchestrators/user-loop.js +21 -10
- package/lib/orchestrators/worker-manager.js +5 -2
- package/lib/utils/ai.js +36 -63
- package/lib/utils/chart.js +5 -0
- package/lib/utils/instructions.txt +593 -0
- package/lib/utils/utils.js +162 -38
- package/package.json +23 -9
- package/types.d.ts +376 -376
- package/.claude/settings.local.json +0 -20
- package/.gcloudignore +0 -18
- package/.gitattributes +0 -2
- package/.prettierrc +0 -0
- package/.vscode/launch.json +0 -80
- package/.vscode/settings.json +0 -69
- package/.vscode/tasks.json +0 -12
- package/dungeons/customers/.gitkeep +0 -0
- package/env.yaml +0 -1
- package/lib/cloud-function.js +0 -20
- package/scratch.mjs +0 -62
- package/scripts/dana.mjs +0 -137
- package/scripts/deploy.sh +0 -15
- package/scripts/jsdoctest.js +0 -5
- package/scripts/new-dungeon.sh +0 -98
- package/scripts/new-project.mjs +0 -14
- package/scripts/run-index.sh +0 -2
- package/scripts/update-deps.sh +0 -5
- package/tests/benchmark/concurrency.mjs +0 -52
- package/tests/cli.test.js +0 -124
- package/tests/coverage/.gitkeep +0 -0
- package/tests/e2e.test.js +0 -379
- package/tests/int.test.js +0 -715
- package/tests/testCases.mjs +0 -229
- package/tests/testSoup.mjs +0 -28
- package/tests/unit.test.js +0 -910
- package/tmp/.gitkeep +0 -0
- package/tsconfig.json +0 -18
- package/vitest.config.js +0 -47
|
@@ -0,0 +1,345 @@
|
|
|
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
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const Chance = require('chance');
|
|
10
|
+
const chance = new Chance();
|
|
11
|
+
const { weighNumRange, date, integer, pickAWinner, exhaust } = require('../lib/utils/utils.js');
|
|
12
|
+
const u = require('ak-tools');
|
|
13
|
+
|
|
14
|
+
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 video_ids = [...Array(50000).keys()].map(i => i + 1).map(n => n.toString());
|
|
17
|
+
const video_names = chance.n(u.makeName, 50000);
|
|
18
|
+
|
|
19
|
+
const EVENTS = 50_000
|
|
20
|
+
const USERS = EVENTS / 100
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/** @type {import('../types.js').Dungeon} */
|
|
24
|
+
const config = {
|
|
25
|
+
token: "",
|
|
26
|
+
seed: "it's business time...",
|
|
27
|
+
numDays: 90, //how many days worth of data
|
|
28
|
+
numEvents: EVENTS, //how many events
|
|
29
|
+
numUsers: USERS, //how many users
|
|
30
|
+
format: 'json', //csv or json
|
|
31
|
+
region: "US",
|
|
32
|
+
hasAnonIds: false, //if true, anonymousIds are created for each user
|
|
33
|
+
hasSessionIds: false, //if true, hasSessionIds are created for each user
|
|
34
|
+
hasLocation: true,
|
|
35
|
+
hasAndroidDevices: true,
|
|
36
|
+
hasIOSDevices: true,
|
|
37
|
+
hasDesktopDevices: true,
|
|
38
|
+
hasBrowser: true,
|
|
39
|
+
hasCampaigns: true,
|
|
40
|
+
isAnonymous: false,
|
|
41
|
+
hasAdSpend: true,
|
|
42
|
+
|
|
43
|
+
hasAvatar: false,
|
|
44
|
+
makeChart: true,
|
|
45
|
+
|
|
46
|
+
batchSize: 500_000,
|
|
47
|
+
concurrency: 500,
|
|
48
|
+
|
|
49
|
+
funnels: [
|
|
50
|
+
{
|
|
51
|
+
sequence: ["watch video", "like video", "subscribe", "purchase video"],
|
|
52
|
+
conversionRate: 35,
|
|
53
|
+
props: {
|
|
54
|
+
channel_id: pickAWinner(channel_ids),
|
|
55
|
+
video_id: weighNumRange(1, 50000, 1.4),
|
|
56
|
+
category: pickAWinner(["funny", "educational", "music", "news", "sports", "cooking", "DIY", "travel", "gaming"]),
|
|
57
|
+
isFeatured: () => { chance.bool({ likelihood: 25 }); },
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
sequence: ["watch video", "dislike video"],
|
|
62
|
+
conversionRate: 10,
|
|
63
|
+
order: "sequential",
|
|
64
|
+
props: {
|
|
65
|
+
channel_id: pickAWinner(channel_ids),
|
|
66
|
+
video_id: weighNumRange(1, 50000, .67),
|
|
67
|
+
category: pickAWinner(["funny", "educational", "music", "news", "sports", "cooking", "DIY", "travel", "gaming"]),
|
|
68
|
+
isFeatured: () => { chance.bool({ likelihood: 25 }); },
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
events: [
|
|
73
|
+
{
|
|
74
|
+
"event": "watch video",
|
|
75
|
+
"weight": 75,
|
|
76
|
+
"properties": {
|
|
77
|
+
"#hashtags": makeHashTags,
|
|
78
|
+
"watch time (sec)": weighNumRange(10, 600, .25),
|
|
79
|
+
"quality": pickAWinner(["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p"], 1)
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"event": "like video",
|
|
84
|
+
"weight": 30,
|
|
85
|
+
"properties": {
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"event": "dislike video",
|
|
91
|
+
"weight": 15,
|
|
92
|
+
"properties": {
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"event": "subscribe",
|
|
98
|
+
"weight": 10,
|
|
99
|
+
"properties": {
|
|
100
|
+
"UI": pickAWinner(["button", "link", "modal", "menu"]),
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"event": "search",
|
|
105
|
+
"weight": 10,
|
|
106
|
+
"properties": {
|
|
107
|
+
term: () => { return chance.word(); },
|
|
108
|
+
"# results": weighNumRange(1, 100, .25),
|
|
109
|
+
"UI": pickAWinner(["button", "link", "modal", "menu"]),
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"event": "comment",
|
|
114
|
+
"weight": 6,
|
|
115
|
+
"properties": {
|
|
116
|
+
length: weighNumRange(1, 500, .25),
|
|
117
|
+
video_id: weighNumRange(1, 50000, .72),
|
|
118
|
+
"has replies": [true, false, false, false, false],
|
|
119
|
+
"has photos": [true, false, false, false, false],
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"event": "save video",
|
|
125
|
+
"weight": 17,
|
|
126
|
+
"properties": {
|
|
127
|
+
video_id: weighNumRange(1, 50000, 1.4),
|
|
128
|
+
UI: pickAWinner(["toolbar", "menu", "keyboard"])
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"event": "create playlist",
|
|
134
|
+
"weight": 5,
|
|
135
|
+
"properties": {
|
|
136
|
+
"# of videos": weighNumRange(1, 100, .25),
|
|
137
|
+
"UI": pickAWinner(["toolbar", "menu", "keyboard"]),
|
|
138
|
+
"visibility": pickAWinner(["public", "private", "unlisted"]),
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"event": "purchase video",
|
|
143
|
+
"weight": 12,
|
|
144
|
+
"properties": {
|
|
145
|
+
video_id: weighNumRange(1, 50000, 1.4),
|
|
146
|
+
basket: makeProducts(5),
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"event": "support ticket",
|
|
153
|
+
"weight": 10,
|
|
154
|
+
"properties": {
|
|
155
|
+
description: chance.sentence.bind(chance),
|
|
156
|
+
severity: ["low", "medium", "high"],
|
|
157
|
+
ticket_id: chance.guid.bind(chance)
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"event": "app error",
|
|
162
|
+
"weight": 15,
|
|
163
|
+
"properties": {
|
|
164
|
+
code: pickAWinner(["404", "500", "403", "401", "400", "503", "504", "429"]),
|
|
165
|
+
error: chance.sentence.bind(chance),
|
|
166
|
+
component: pickAWinner(["video player", "search", "comment", "profile", "settings", "billing", "support"]),
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"event": "sign up",
|
|
171
|
+
"isFirstEvent": true,
|
|
172
|
+
"weight": 0,
|
|
173
|
+
"properties": {
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
superProps: {
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
},
|
|
182
|
+
/*
|
|
183
|
+
user properties work the same as event properties
|
|
184
|
+
each key should be an array or function reference
|
|
185
|
+
*/
|
|
186
|
+
userProps: {
|
|
187
|
+
title: chance.profession.bind(chance),
|
|
188
|
+
luckyNumber: weighNumRange(42, 420),
|
|
189
|
+
experiment: designExperiment(),
|
|
190
|
+
spiritAnimal: ["unicorn", "dragon", "phoenix", "sasquatch", "yeti", "kraken", "jackalope", "thunderbird", "mothman", "nessie", "chupacabra", "jersey devil", "bigfoot", "weindgo", "bunyip", "mokele-mbembe", "tatzelwurm", "megalodon"],
|
|
191
|
+
|
|
192
|
+
ip: chance.ip.bind(chance),
|
|
193
|
+
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
/** each generates it's own table */
|
|
197
|
+
scdProps: {
|
|
198
|
+
plan: {
|
|
199
|
+
type: "user",
|
|
200
|
+
frequency: "month",
|
|
201
|
+
values: ["free", "free", "free", "free", "basic", "basic", "basic", "premium", "premium", "enterprise"],
|
|
202
|
+
timing: "fixed",
|
|
203
|
+
max: 3
|
|
204
|
+
},
|
|
205
|
+
MRR: {
|
|
206
|
+
type: "user",
|
|
207
|
+
frequency: "month",
|
|
208
|
+
values: weighNumRange(0, 10000, .15),
|
|
209
|
+
timing: "fixed",
|
|
210
|
+
max: 5
|
|
211
|
+
},
|
|
212
|
+
NPS: {
|
|
213
|
+
type: "user",
|
|
214
|
+
frequency: "month",
|
|
215
|
+
values: weighNumRange(0, 10, 2, 150),
|
|
216
|
+
timing: "fixed",
|
|
217
|
+
max: 3
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
mirrorProps: {
|
|
222
|
+
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
/*
|
|
226
|
+
for group analytics keys, we need an array of arrays [[],[],[]]
|
|
227
|
+
each pair represents a group_key and the number of profiles for that key
|
|
228
|
+
*/
|
|
229
|
+
groupKeys: [
|
|
230
|
+
['channel_id', 1234, ["save video", "comment", "watch video", "purchase video", "like video", "dislike video", "subscribe"]],
|
|
231
|
+
|
|
232
|
+
],
|
|
233
|
+
groupProps: {
|
|
234
|
+
channel_id: {
|
|
235
|
+
"name": exhaust(channel_names),
|
|
236
|
+
"viewers": weighNumRange(5, 500, .25),
|
|
237
|
+
"rating": weighNumRange(1, 5),
|
|
238
|
+
"reviews": weighNumRange(0, 35)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
lookupTables: [
|
|
244
|
+
{
|
|
245
|
+
key: "video_id",
|
|
246
|
+
entries: 50000,
|
|
247
|
+
attributes: {
|
|
248
|
+
isFlagged: [true, false, false, false, false],
|
|
249
|
+
copyright: ["all rights reserved", "creative commons", "creative commons", "public domain", "fair use"],
|
|
250
|
+
uploader_id: chance.guid.bind(chance),
|
|
251
|
+
"uploader influence": ["low", "low", "low", "medium", "medium", "high"],
|
|
252
|
+
thumbs: weighNumRange(0, 4000, .25),
|
|
253
|
+
video_name: exhaust(video_names),
|
|
254
|
+
rating: ["G", "PG", "PG-13", "R", "NC-17", "PG-13", "R", "NC-17", "R", "PG", "PG"]
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
|
|
260
|
+
hook: function (record, type, meta) {
|
|
261
|
+
return record;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
function makeHashTags() {
|
|
268
|
+
const possibleHashtags = [];
|
|
269
|
+
for (let i = 0; i < 20; i++) {
|
|
270
|
+
possibleHashtags.push('#' + u.makeName(2, ''));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const numHashtags = integer(integer(1, 5), integer(5, 10));
|
|
274
|
+
const hashtags = [];
|
|
275
|
+
for (let i = 0; i < numHashtags; i++) {
|
|
276
|
+
hashtags.push(chance.pickone(possibleHashtags));
|
|
277
|
+
}
|
|
278
|
+
return [hashtags];
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
function makeProducts(maxItems = 10) {
|
|
282
|
+
return function () {
|
|
283
|
+
const categories = ["Device Accessories", "eBooks", "Automotive", "Baby Products", "Beauty", "Books", "Camera & Photo", "Cell Phones & Accessories", "Collectible Coins", "Consumer Electronics", "Entertainment Collectibles", "Fine Art", "Grocery & Gourmet Food", "Health & Personal Care", "Home & Garden", "Independent Design", "Industrial & Scientific", "Accessories", "Major Appliances", "Music", "Musical Instruments", "Office Products", "Outdoors", "Personal Computers", "Pet Supplies", "Software", "Sports", "Sports Collectibles", "Tools & Home Improvement", "Toys & Games", "Video, DVD & Blu-ray", "Video Games", "Watches"];
|
|
284
|
+
const slugs = ['/sale/', '/featured/', '/home/', '/search/', '/wishlist/', '/'];
|
|
285
|
+
const assetExtension = ['.png', '.jpg', '.jpeg', '.heic', '.mp4', '.mov', '.avi'];
|
|
286
|
+
const data = [];
|
|
287
|
+
const numOfItems = integer(1, 12);
|
|
288
|
+
|
|
289
|
+
for (var i = 0; i < numOfItems; i++) {
|
|
290
|
+
const category = chance.pickone(categories);
|
|
291
|
+
const slug = chance.pickone(slugs);
|
|
292
|
+
const asset = chance.pickone(assetExtension);
|
|
293
|
+
const product_id = chance.guid();
|
|
294
|
+
const price = integer(1, 300);
|
|
295
|
+
const quantity = integer(1, 5);
|
|
296
|
+
|
|
297
|
+
const item = {
|
|
298
|
+
product_id: product_id,
|
|
299
|
+
sku: integer(11111, 99999),
|
|
300
|
+
amount: price,
|
|
301
|
+
quantity: quantity,
|
|
302
|
+
value: price * quantity,
|
|
303
|
+
featured: chance.pickone([true, false]),
|
|
304
|
+
category: category,
|
|
305
|
+
urlSlug: slug + category,
|
|
306
|
+
asset: `${category}-${integer(1, 20)}${asset}`
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
data.push(item);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return [data];
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
function designExperiment() {
|
|
318
|
+
return function () {
|
|
319
|
+
const variants = ["A", "B", "C", "Control"];
|
|
320
|
+
const variant = chance.pickone(variants);
|
|
321
|
+
const experiments = ["no password", "social sign in", "new tutorial", "new search"];
|
|
322
|
+
const experiment = chance.pickone(experiments);
|
|
323
|
+
const multi_variates = ["A/B", "A/B/C", "A/B/C/D", "Control"];
|
|
324
|
+
const multi_variate = chance.pickone(multi_variates);
|
|
325
|
+
const impression_id = chance.guid();
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
const chosen = {
|
|
330
|
+
variant,
|
|
331
|
+
experiment,
|
|
332
|
+
multi_variate,
|
|
333
|
+
impression_id
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
return [chosen];
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
module.exports = config;
|