@ak--47/dungeon-master 1.0.0
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/README.md +518 -0
- package/dungeons/array-of-object-lookup-schema.json +327 -0
- package/dungeons/array-of-object-lookup.js +220 -0
- package/dungeons/ecommerce-schema.json +462 -0
- package/dungeons/ecommerce.js +447 -0
- package/dungeons/education-schema.json +2409 -0
- package/dungeons/education.js +768 -0
- package/dungeons/fintech-schema.json +14034 -0
- package/dungeons/fintech.js +696 -0
- package/dungeons/foobar-schema.json +403 -0
- package/dungeons/foobar.js +296 -0
- package/dungeons/food-delivery-schema.json +192 -0
- package/dungeons/food-delivery.js +602 -0
- package/dungeons/food-schema.json +1152 -0
- package/dungeons/food.js +754 -0
- package/dungeons/gaming-schema.json +1270 -0
- package/dungeons/gaming.js +508 -0
- package/dungeons/insurance-application-schema.json +204 -0
- package/dungeons/insurance-application.js +605 -0
- package/dungeons/media-schema.json +906 -0
- package/dungeons/media.js +790 -0
- package/dungeons/retention-cadence-schema.json +78 -0
- package/dungeons/retention-cadence.js +244 -0
- package/dungeons/rpg-schema.json +4526 -0
- package/dungeons/rpg.js +919 -0
- package/dungeons/sanity-schema.json +255 -0
- package/dungeons/sanity.js +152 -0
- package/dungeons/sass-schema.json +1291 -0
- package/dungeons/sass.js +795 -0
- package/dungeons/scd-schema.json +919 -0
- package/dungeons/scd.js +277 -0
- package/dungeons/simple-schema.json +608 -0
- package/dungeons/simple.js +285 -0
- package/dungeons/simplest-schema.json +1418 -0
- package/dungeons/simplest.js +392 -0
- package/dungeons/social-schema.json +1118 -0
- package/dungeons/social.js +686 -0
- package/dungeons/text-generation-schema.json +3096 -0
- package/dungeons/text-generation.js +812 -0
- package/index.js +567 -0
- package/lib/core/config-validator.js +395 -0
- package/lib/core/context.js +204 -0
- package/lib/core/dungeon-loader.js +337 -0
- package/lib/core/storage.js +379 -0
- package/lib/generators/adspend.js +132 -0
- package/lib/generators/events.js +271 -0
- package/lib/generators/funnels.js +407 -0
- package/lib/generators/mirror.js +167 -0
- package/lib/generators/product-lookup.js +262 -0
- package/lib/generators/product-names.js +195 -0
- package/lib/generators/profiles.js +93 -0
- package/lib/generators/scd.js +124 -0
- package/lib/generators/text.js +1192 -0
- package/lib/orchestrators/mixpanel-sender.js +266 -0
- package/lib/orchestrators/user-loop.js +335 -0
- package/lib/templates/abbreviated.d.ts +169 -0
- package/lib/templates/defaults.js +1405 -0
- package/lib/templates/phrases.js +2526 -0
- package/lib/templates/schema.d.ts +173 -0
- package/lib/templates/soup-presets.js +188 -0
- package/lib/utils/function-registry.js +302 -0
- package/lib/utils/json-evaluator.js +172 -0
- package/lib/utils/logger.js +34 -0
- package/lib/utils/utils.js +1490 -0
- package/package.json +89 -0
- package/types.d.ts +865 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import Chance from 'chance';
|
|
2
|
+
let chance = new Chance();
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import utc from "dayjs/plugin/utc.js";
|
|
5
|
+
dayjs.extend(utc);
|
|
6
|
+
import { uid, comma } from 'ak-tools';
|
|
7
|
+
import { pickAWinner, weighNumRange, date, integer, weighChoices } from "../lib/utils/utils.js";
|
|
8
|
+
|
|
9
|
+
const itemCategories = ["Books", "Movies", "Music", "Games", "Electronics", "Computers", "Smart Home", "Home", "Garden", "Pet", "Beauty", "Health", "Toys", "Kids", "Baby", "Handmade", "Sports", "Outdoors", "Automotive", "Industrial", "Entertainment", "Art", "Food", "Appliances", "Office", "Wedding", "Software"];
|
|
10
|
+
|
|
11
|
+
const videoCategories = ["funny", "educational", "inspirational", "music", "news", "sports", "cooking", "DIY", "travel", "gaming"];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* ═══════════════════════════════════════════════════════════════
|
|
15
|
+
* DATASET OVERVIEW
|
|
16
|
+
* ═══════════════════════════════════════════════════════════════
|
|
17
|
+
*
|
|
18
|
+
* Simple E-Commerce + Media App
|
|
19
|
+
* - 5,000 users over 100 days, ~500K events
|
|
20
|
+
* - Events: ad impressions/clicks, page views, video watching,
|
|
21
|
+
* item browsing/saving, cart, checkout, signup
|
|
22
|
+
* - Signup funnel with A/B experiment
|
|
23
|
+
* - Campaigns, location, browser, and device data enabled
|
|
24
|
+
*
|
|
25
|
+
* ═══════════════════════════════════════════════════════════════
|
|
26
|
+
* ANALYTICS HOOKS (3 patterns)
|
|
27
|
+
* ═══════════════════════════════════════════════════════════════
|
|
28
|
+
*
|
|
29
|
+
* 1. TEMPORAL IMPROVEMENT (event hook)
|
|
30
|
+
* After 15 days ago: checkout amounts 1.5x, watch times 1.5x.
|
|
31
|
+
* Before that: 33% of events are dropped (tagged _drop, filtered in everything).
|
|
32
|
+
*
|
|
33
|
+
* Mixpanel Report:
|
|
34
|
+
* - Insights > Line Chart: "checkout", AVG(amount) by Day
|
|
35
|
+
* Expected: visible 1.5x uplift in the last 15 days
|
|
36
|
+
* - Insights > Line Chart: Total event count by Day
|
|
37
|
+
* Expected: ~33% lower volume before 15 days ago, then step-up
|
|
38
|
+
*
|
|
39
|
+
* 2. CUSTOM THEME POWER BUYERS (everything hook)
|
|
40
|
+
* Users whose custom-theme events outnumber light or dark get
|
|
41
|
+
* all checkout events tripled with 2x amount and "50%OFF" coupon.
|
|
42
|
+
*
|
|
43
|
+
* Mixpanel Report:
|
|
44
|
+
* - Funnels: any multi-step funnel, breakdown by theme
|
|
45
|
+
* Expected: "custom" theme users show much higher checkout counts
|
|
46
|
+
* - Insights: "checkout", AVG(amount), breakdown by coupon
|
|
47
|
+
* Expected: "50%OFF" spike from power buyers
|
|
48
|
+
*
|
|
49
|
+
* 3. LOW-QUALITY VIDEO CHURN (everything hook)
|
|
50
|
+
* Users who watch more low-quality (480p/360p/240p) than high-quality
|
|
51
|
+
* video have a 50% chance of losing all events after their midpoint.
|
|
52
|
+
*
|
|
53
|
+
* Mixpanel Report:
|
|
54
|
+
* - Retention: breakdown by video quality
|
|
55
|
+
* Expected: low-quality watchers show ~50% drop-off from midpoint
|
|
56
|
+
* - Insights > Stacked Line: event count by quality
|
|
57
|
+
* Expected: low-quality cohort volume thins out after midpoint
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/** @type {import('../types').Dungeon} */
|
|
61
|
+
const config = {
|
|
62
|
+
token: "",
|
|
63
|
+
seed: "simple is best",
|
|
64
|
+
numDays: 100, //how many days worth1 of data
|
|
65
|
+
numEvents: 500_000, //how many events
|
|
66
|
+
numUsers: 5_000, //how many users
|
|
67
|
+
format: 'json', //csv or json
|
|
68
|
+
region: "US",
|
|
69
|
+
hasAnonIds: true, //if true, anonymousIds are created for each user
|
|
70
|
+
hasSessionIds: true, //if true, hasSessionIds are created for each user
|
|
71
|
+
hasAdSpend: false,
|
|
72
|
+
hasLocation: true,
|
|
73
|
+
hasAndroidDevices: true,
|
|
74
|
+
hasIOSDevices: true,
|
|
75
|
+
hasDesktopDevices: true,
|
|
76
|
+
hasBrowser: true,
|
|
77
|
+
hasCampaigns: true,
|
|
78
|
+
isAnonymous: false,
|
|
79
|
+
alsoInferFunnels: true,
|
|
80
|
+
concurrency: 1,
|
|
81
|
+
batchSize: 2_500_000,
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
events: [
|
|
85
|
+
{
|
|
86
|
+
event: "ad impression",
|
|
87
|
+
weight: 15,
|
|
88
|
+
properties: {
|
|
89
|
+
partner: ["google", "facebook", "twitter", "linkedin", "bing", "taboola", "outbrain", "quora", "pinterest"],
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
event: "ad click",
|
|
94
|
+
weight: 10,
|
|
95
|
+
properties: {
|
|
96
|
+
partner: ["google", "facebook", "twitter", "linkedin", "bing", "taboola", "outbrain", "quora", "pinterest"],
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
event: "checkout",
|
|
101
|
+
weight: 2,
|
|
102
|
+
properties: {
|
|
103
|
+
amount: weighNumRange(5, 500, .25),
|
|
104
|
+
currency: ["USD", "CAD", "EUR", "BTC", "ETH", "JPY"],
|
|
105
|
+
coupon: weighChoices(["none", "none", "none", "none", "10%OFF", "20%OFF", "10%OFF", "20%OFF", "30%OFF", "40%OFF", "50%OFF"]),
|
|
106
|
+
numItems: weighNumRange(1, 10),
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
event: "add to cart",
|
|
112
|
+
weight: 4,
|
|
113
|
+
properties: {
|
|
114
|
+
amount: weighNumRange(5, 500, .25),
|
|
115
|
+
rating: weighNumRange(1, 5),
|
|
116
|
+
reviews: weighNumRange(0, 35),
|
|
117
|
+
isFeaturedItem: [true, false, false],
|
|
118
|
+
itemCategory: pickAWinner(itemCategories, integer(0, 27)),
|
|
119
|
+
dateItemListed: date(30, true, 'YYYY-MM-DD'),
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
event: "page view",
|
|
124
|
+
weight: 10,
|
|
125
|
+
properties: {
|
|
126
|
+
page: pickAWinner(["/", "/", "/help", "/account", "/watch", "/listen", "/product", "/people", "/peace"]),
|
|
127
|
+
utm_source: pickAWinner(["$organic", "$organic", "$organic", "$organic", "google", "google", "google", "facebook", "facebook", "twitter", "linkedin"]),
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
event: "watch video",
|
|
132
|
+
weight: 8,
|
|
133
|
+
properties: {
|
|
134
|
+
videoCategory: pickAWinner(videoCategories, integer(0, 9)),
|
|
135
|
+
isFeaturedItem: [true, false, false],
|
|
136
|
+
watchTimeSec: weighNumRange(10, 600, .25),
|
|
137
|
+
quality: ["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p"],
|
|
138
|
+
format: ["mp4", "avi", "mov", "mpg"],
|
|
139
|
+
uploader_id: chance.guid.bind(chance)
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
event: "view item",
|
|
145
|
+
weight: 8,
|
|
146
|
+
properties: {
|
|
147
|
+
isFeaturedItem: [true, false, false],
|
|
148
|
+
itemCategory: pickAWinner(itemCategories, integer(0, 27)),
|
|
149
|
+
dateItemListed: date(30, true, 'YYYY-MM-DD'),
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
event: "save item",
|
|
154
|
+
weight: 5,
|
|
155
|
+
properties: {
|
|
156
|
+
isFeaturedItem: [true, false, false],
|
|
157
|
+
itemCategory: pickAWinner(itemCategories, integer(0, 27)),
|
|
158
|
+
dateItemListed: date(30, true, 'YYYY-MM-DD'),
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
event: "sign up",
|
|
163
|
+
weight: 1,
|
|
164
|
+
isFirstEvent: true,
|
|
165
|
+
properties: {
|
|
166
|
+
signupMethod: ["email", "google", "facebook", "twitter", "linkedin", "github"],
|
|
167
|
+
referral: weighChoices(["none", "none", "none", "friend", "ad", "ad", "ad", "friend", "friend", "friend", "friend"]),
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
],
|
|
172
|
+
funnels: [
|
|
173
|
+
{
|
|
174
|
+
sequence: ["page view", "view item", "save item", "page view", "sign up"],
|
|
175
|
+
conversionRate: 50,
|
|
176
|
+
order: "first-and-last-fixed",
|
|
177
|
+
weight: 1,
|
|
178
|
+
isFirstFunnel: true,
|
|
179
|
+
timeToConvert: 2,
|
|
180
|
+
experiment: true,
|
|
181
|
+
name: "Signup Flow"
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
],
|
|
186
|
+
superProps: {
|
|
187
|
+
theme: pickAWinner(["light", "dark", "custom", "light", "dark"]),
|
|
188
|
+
},
|
|
189
|
+
/*
|
|
190
|
+
user properties work the same as event properties
|
|
191
|
+
each key should be an array or function reference
|
|
192
|
+
*/
|
|
193
|
+
userProps: {
|
|
194
|
+
title: chance.profession.bind(chance),
|
|
195
|
+
luckyNumber: weighNumRange(42, 420, .3),
|
|
196
|
+
spiritAnimal: pickAWinner(["duck", "dog", "otter", "penguin", "cat", "elephant", "lion", "cheetah", "giraffe", "zebra", "rhino", "hippo", "whale", "dolphin", "shark", "octopus", "squid", "jellyfish", "starfish", "seahorse", "crab", "lobster", "shrimp", "clam", "snail", "slug", "butterfly", "moth", "bee", "wasp", "ant", "beetle", "ladybug", "caterpillar", "centipede", "millipede", "scorpion", "spider", "tarantula", "tick", "mite", "mosquito", "fly", "dragonfly", "damselfly", "grasshopper", "cricket", "locust", "mantis", "cockroach", "termite", "praying mantis", "walking stick", "stick bug", "leaf insect", "lacewing", "aphid", "cicada", "thrips", "psyllid", "scale insect", "whitefly", "mealybug", "planthopper", "leafhopper", "treehopper", "flea", "louse", "bedbug", "flea beetle", "weevil", "longhorn beetle", "leaf beetle", "tiger beetle", "ground beetle", "lady beetle", "firefly", "click beetle", "rove beetle", "scarab beetle", "dung beetle", "stag beetle", "rhinoceros beetle", "hercules beetle", "goliath beetle", "jewel beetle", "tortoise beetle"])
|
|
197
|
+
},
|
|
198
|
+
scdProps: {},
|
|
199
|
+
mirrorProps: {},
|
|
200
|
+
|
|
201
|
+
/*
|
|
202
|
+
for group analytics keys, we need an array of arrays [[],[],[]]
|
|
203
|
+
each pair represents a group_key and the number of profiles for that key
|
|
204
|
+
*/
|
|
205
|
+
groupKeys: [],
|
|
206
|
+
groupProps: {},
|
|
207
|
+
lookupTables: [],
|
|
208
|
+
hook: function (record, type, meta) {
|
|
209
|
+
|
|
210
|
+
const NOW = dayjs();
|
|
211
|
+
// const DATE_HOMEGROWN_LAUNCH = NOW.subtract(25, 'day');
|
|
212
|
+
// const DATE_HOMEGROWN_IMPROVEMENT = NOW.subtract(10, 'day');
|
|
213
|
+
const OVER_THINGS_GET_BETTER = NOW.subtract(15, 'day');
|
|
214
|
+
|
|
215
|
+
if (type === "event") {
|
|
216
|
+
const EVENT_TIME = dayjs(record.time);
|
|
217
|
+
|
|
218
|
+
if (EVENT_TIME.isAfter(OVER_THINGS_GET_BETTER)) {
|
|
219
|
+
// checkouts are bigger
|
|
220
|
+
if (record.event === "checkout") {
|
|
221
|
+
record.amount = Math.round(record.amount * 1.5);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// videos are longer
|
|
225
|
+
if (record.event === "watch video") {
|
|
226
|
+
record.watchTimeSec = Math.round(record.watchTimeSec * 1.5);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (EVENT_TIME.isBefore(OVER_THINGS_GET_BETTER)) {
|
|
231
|
+
// tag 33% for removal (filtered in "everything" hook)
|
|
232
|
+
if (chance.bool({ likelihood: 33 })) record._drop = true;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (type === "everything") {
|
|
237
|
+
|
|
238
|
+
//custom themes purchase more:
|
|
239
|
+
const numCustomMode = record.filter(a => a.theme === 'custom').length;
|
|
240
|
+
const numLightMode = record.filter(a => a.theme === 'light').length;
|
|
241
|
+
const numDarkMode = record.filter(a => a.theme === 'dark').length;
|
|
242
|
+
if (numCustomMode > numLightMode || numCustomMode > numDarkMode) {
|
|
243
|
+
//triple their checkout events
|
|
244
|
+
const checkoutEvents = record.filter(a => a.event === 'checkout');
|
|
245
|
+
const newCheckouts = checkoutEvents.map(a => {
|
|
246
|
+
const randomInt = integer(-48, 48);
|
|
247
|
+
const newCheckout = {
|
|
248
|
+
...a,
|
|
249
|
+
time: dayjs(a.time).add(randomInt, 'hour').toISOString(),
|
|
250
|
+
event: "checkout",
|
|
251
|
+
amount: a.amount * 2,
|
|
252
|
+
coupon: "50%OFF"
|
|
253
|
+
};
|
|
254
|
+
return newCheckout;
|
|
255
|
+
});
|
|
256
|
+
record.push(...newCheckouts);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
//users who watch low quality videos churn more:
|
|
260
|
+
const loQuality = ["480p", "360p", "240p"];
|
|
261
|
+
const lowQualityWatches = record.filter(a => a.event === 'watch video' && loQuality.includes(a.quality));
|
|
262
|
+
const highQualityWatches = record.filter(a => a.event === 'watch video' && !loQuality.includes(a.quality));
|
|
263
|
+
if (lowQualityWatches.length > highQualityWatches.length) {
|
|
264
|
+
if (flip()) {
|
|
265
|
+
// find midpoint of records
|
|
266
|
+
const midpoint = Math.floor(record.length / 2);
|
|
267
|
+
record = record.slice(0, midpoint);
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Filter out events tagged for removal in the event hook
|
|
273
|
+
record = record.filter(e => !e._drop);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return record;
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
function flip(likelihood = 50) {
|
|
281
|
+
return chance.bool({ likelihood });
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
export default config;
|