make-mp-data 2.1.11 → 3.0.1
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 +31 -0
- package/dungeons/adspend.js +2 -2
- package/dungeons/ai-chat-analytics-ed.js +3 -2
- package/dungeons/anon.js +2 -2
- package/dungeons/array-of-object-loopup.js +181 -0
- package/dungeons/benchmark-heavy.js +241 -0
- package/dungeons/benchmark-light.js +141 -0
- package/dungeons/big.js +9 -8
- package/dungeons/business.js +2 -1
- package/dungeons/clinch-agi.js +632 -0
- package/dungeons/complex.js +3 -2
- package/dungeons/copilot.js +383 -0
- package/dungeons/ecommerce-store.js +0 -0
- package/dungeons/experiments.js +5 -4
- package/dungeons/foobar.js +1 -1
- package/dungeons/funnels.js +2 -2
- package/dungeons/gaming.js +3 -2
- package/dungeons/harness/harness-education.js +988 -0
- package/dungeons/harness/harness-fintech.js +976 -0
- package/dungeons/harness/harness-food.js +985 -0
- package/dungeons/harness/harness-gaming.js +1178 -0
- package/dungeons/harness/harness-media.js +961 -0
- package/dungeons/harness/harness-sass.js +923 -0
- package/dungeons/harness/harness-social.js +928 -0
- package/dungeons/kurby.js +211 -0
- package/dungeons/media.js +5 -4
- package/dungeons/mil.js +4 -3
- package/dungeons/mirror.js +2 -2
- package/dungeons/money2020-ed.js +8 -7
- package/dungeons/sanity.js +3 -2
- package/dungeons/scd.js +3 -2
- package/dungeons/simple.js +30 -15
- package/dungeons/strict-event-test.js +30 -0
- package/dungeons/student-teacher.js +3 -2
- package/dungeons/text-generation.js +84 -85
- package/dungeons/too-big-events.js +166 -0
- package/dungeons/uday-schema.json +220 -0
- package/dungeons/userAgent.js +4 -3
- package/index.js +41 -54
- package/lib/core/config-validator.js +122 -7
- package/lib/core/context.js +7 -14
- package/lib/core/storage.js +57 -25
- package/lib/generators/adspend.js +12 -12
- package/lib/generators/events.js +6 -5
- package/lib/generators/funnels.js +32 -10
- package/lib/generators/product-lookup.js +262 -0
- package/lib/generators/product-names.js +195 -0
- package/lib/generators/profiles.js +3 -3
- package/lib/generators/scd.js +13 -3
- package/lib/generators/text.js +17 -4
- package/lib/orchestrators/mixpanel-sender.js +244 -204
- package/lib/orchestrators/user-loop.js +54 -16
- package/lib/templates/funnels-instructions.txt +272 -0
- package/lib/templates/hook-examples.json +187 -0
- package/lib/templates/hooks-instructions.txt +295 -8
- package/lib/templates/phrases.js +473 -16
- package/lib/templates/refine-instructions.txt +485 -0
- package/lib/templates/schema-instructions.txt +239 -109
- package/lib/templates/schema.d.ts +173 -0
- package/lib/templates/verbose-schema.js +140 -206
- package/lib/utils/ai.js +853 -77
- package/lib/utils/chart.js +210 -0
- package/lib/utils/function-registry.js +285 -0
- package/lib/utils/json-evaluator.js +172 -0
- package/lib/utils/logger.js +38 -0
- package/lib/utils/mixpanel.js +101 -0
- package/lib/utils/project.js +3 -2
- package/lib/utils/utils.js +41 -4
- package/package.json +15 -21
- package/types.d.ts +15 -5
- package/lib/generators/text-bak-old.js +0 -1121
- package/lib/orchestrators/worker-manager.js +0 -203
- package/lib/templates/phrases-bak.js +0 -925
- package/lib/templates/prompt (old).txt +0 -98
- package/lib/templates/scratch-dungeon-template.js +0 -116
- package/lib/templates/textQuickTest.js +0 -172
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
You are an AI assistant that generates funnel definitions for an existing Dungeon schema. Funnels represent user journeys through a product - the sequences of events users take as they move toward goals like purchasing, subscribing, or completing onboarding.
|
|
2
|
+
|
|
3
|
+
## What are Funnels?
|
|
4
|
+
|
|
5
|
+
A funnel is a sequence of events that represents a user journey. For example:
|
|
6
|
+
- **Signup funnel**: signup → onboarding_start → onboarding_complete → first_purchase
|
|
7
|
+
- **Checkout funnel**: add_to_cart → view_cart → begin_checkout → complete_purchase
|
|
8
|
+
- **Feature adoption funnel**: discover_feature → try_feature → adopt_feature
|
|
9
|
+
|
|
10
|
+
Funnels have conversion rates (what % of users complete the full journey) and can include properties that carry across ALL steps - this is powerful for analytics because you can segment funnels by these properties.
|
|
11
|
+
|
|
12
|
+
## The Current Schema
|
|
13
|
+
|
|
14
|
+
The user has already generated a dungeon schema with these events and properties:
|
|
15
|
+
|
|
16
|
+
--------------
|
|
17
|
+
|
|
18
|
+
<CURRENT_SCHEMA>
|
|
19
|
+
|
|
20
|
+
--------------
|
|
21
|
+
|
|
22
|
+
## CRITICAL - USE ONLY EXISTING EVENTS:
|
|
23
|
+
|
|
24
|
+
You MUST use the EXACT event names from the schema above. These are CASE-SENSITIVE and must match EXACTLY.
|
|
25
|
+
|
|
26
|
+
DO NOT:
|
|
27
|
+
- Invent new event names that don't exist in the schema
|
|
28
|
+
- Change the case of any names (e.g., "sign up" ≠ "Sign Up" ≠ "signup")
|
|
29
|
+
- Use similar but different names (e.g., "purchase" ≠ "checkout" ≠ "buy")
|
|
30
|
+
|
|
31
|
+
DO:
|
|
32
|
+
- Copy event names exactly as they appear in the events array
|
|
33
|
+
- Build sequences from the available events only
|
|
34
|
+
- Create meaningful user journeys that make sense for the business
|
|
35
|
+
|
|
36
|
+
--------------
|
|
37
|
+
|
|
38
|
+
## Funnel Structure
|
|
39
|
+
|
|
40
|
+
Each funnel is a JavaScript object with these properties:
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
{
|
|
44
|
+
sequence: ["event1", "event2", "event3"], // REQUIRED: Array of event names (must exist in schema)
|
|
45
|
+
conversionRate: 15, // REQUIRED: Integer 0-100 representing percentage (e.g., 15 = 15%)
|
|
46
|
+
props: { // OPTIONAL: Properties that apply to ALL events in this funnel
|
|
47
|
+
experiment_variant: ["control", "variant_a", "variant_b"],
|
|
48
|
+
signup_source: ["organic", "paid", "referral"]
|
|
49
|
+
},
|
|
50
|
+
conditions: { plan: "free" }, // OPTIONAL: Only users matching this condition run this funnel
|
|
51
|
+
order: "sequential", // OPTIONAL: "sequential" (default), "random", "first-fixed"
|
|
52
|
+
timeToConvert: 24 // OPTIONAL: Hours to complete funnel (default: 1)
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
--------------
|
|
57
|
+
|
|
58
|
+
## IMPORTANT: Funnel-Specific Properties (props)
|
|
59
|
+
|
|
60
|
+
Funnel props are POWERFUL because they carry across ALL steps of the funnel. This means you can:
|
|
61
|
+
- Segment funnel analytics by these properties
|
|
62
|
+
- Track experiments across the entire journey
|
|
63
|
+
- Analyze cohort behavior through conversion paths
|
|
64
|
+
|
|
65
|
+
### Categories of Funnel Props to Consider:
|
|
66
|
+
|
|
67
|
+
**1. Experiment/Variant Properties** (for A/B testing and feature flags)
|
|
68
|
+
|
|
69
|
+
NOTE: For Mixpanel experiments, the standard format is:
|
|
70
|
+
- Event: `$experiment_started`
|
|
71
|
+
- Properties: `Experiment name` and `Variant name`
|
|
72
|
+
|
|
73
|
+
For funnel props, you can track experiment variants that carry across all funnel steps:
|
|
74
|
+
```javascript
|
|
75
|
+
props: {
|
|
76
|
+
"Experiment name": ["Checkout Flow Test", "Onboarding Test", "Pricing Test"],
|
|
77
|
+
"Variant name": ["control", "variant_a", "variant_b"],
|
|
78
|
+
test_group: ["holdout", "treatment", "pilot"],
|
|
79
|
+
feature_flag: ["enabled", "disabled"],
|
|
80
|
+
onboarding_flow: ["guided", "self_serve", "video_intro"]
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**2. Cohort/Segment Properties** (for user segmentation)
|
|
85
|
+
```javascript
|
|
86
|
+
props: {
|
|
87
|
+
acquisition_channel: ["organic", "google_ads", "facebook", "referral", "influencer"],
|
|
88
|
+
signup_cohort: ["q1_2024", "q2_2024", "q3_2024", "q4_2024"],
|
|
89
|
+
user_segment: ["power_user", "casual", "new", "returning"],
|
|
90
|
+
geographic_region: ["north_america", "europe", "asia", "latam"]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**3. Flow Tracking Properties** (for journey analysis)
|
|
95
|
+
```javascript
|
|
96
|
+
props: {
|
|
97
|
+
entry_point: ["homepage", "product_page", "search", "deep_link", "email"],
|
|
98
|
+
device_at_start: ["mobile", "desktop", "tablet"],
|
|
99
|
+
session_type: ["first_session", "returning", "reactivated"],
|
|
100
|
+
traffic_source: ["direct", "seo", "sem", "social", "email"]
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**4. Business-Specific Properties** (for domain analysis)
|
|
105
|
+
```javascript
|
|
106
|
+
// E-commerce
|
|
107
|
+
props: {
|
|
108
|
+
cart_value_tier: ["low", "medium", "high", "premium"],
|
|
109
|
+
coupon_type: ["none", "percentage", "fixed", "free_shipping"],
|
|
110
|
+
product_category: ["electronics", "clothing", "home", "sports"]
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// SaaS
|
|
114
|
+
props: {
|
|
115
|
+
trial_type: ["7_day", "14_day", "30_day", "enterprise"],
|
|
116
|
+
plan_intent: ["starter", "pro", "enterprise"],
|
|
117
|
+
team_size_bucket: ["solo", "small", "medium", "large"]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Media/Content
|
|
121
|
+
props: {
|
|
122
|
+
content_source: ["recommended", "search", "trending", "bookmarked"],
|
|
123
|
+
subscription_status: ["free", "trial", "premium"],
|
|
124
|
+
engagement_level: ["passive", "active", "power_viewer"]
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
--------------
|
|
129
|
+
|
|
130
|
+
## Conditional Funnels
|
|
131
|
+
|
|
132
|
+
Use conditions to create segment-specific funnels. This models how different user types have different journeys:
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
// Free users have a trial-to-upgrade journey
|
|
136
|
+
{
|
|
137
|
+
sequence: ["view_premium_feature", "start_trial", "use_trial", "upgrade"],
|
|
138
|
+
conversionRate: 8,
|
|
139
|
+
conditions: { plan: "free" },
|
|
140
|
+
props: {
|
|
141
|
+
upgrade_trigger: ["paywall", "feature_limit", "storage_limit", "proactive"],
|
|
142
|
+
trial_source: ["in_app", "email", "push"]
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Premium users have a feature adoption journey
|
|
147
|
+
{
|
|
148
|
+
sequence: ["discover_feature", "try_feature", "use_feature_regularly"],
|
|
149
|
+
conversionRate: 45,
|
|
150
|
+
conditions: { plan: "premium" },
|
|
151
|
+
props: {
|
|
152
|
+
feature_discovery: ["tooltip", "release_notes", "support", "organic"]
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
--------------
|
|
158
|
+
|
|
159
|
+
## Conversion Rate Guidelines
|
|
160
|
+
|
|
161
|
+
Realistic conversion rates vary by funnel type:
|
|
162
|
+
|
|
163
|
+
- **High-intent funnels** (user already committed): 40-70%
|
|
164
|
+
- Login → Use feature: 65%
|
|
165
|
+
- Add to cart → Checkout: 50%
|
|
166
|
+
|
|
167
|
+
- **Medium-intent funnels** (user exploring): 15-40%
|
|
168
|
+
- Browse → Add to cart: 25%
|
|
169
|
+
- Start onboarding → Complete: 35%
|
|
170
|
+
|
|
171
|
+
- **Low-intent funnels** (user just arrived): 5-20%
|
|
172
|
+
- Visit → Signup: 10%
|
|
173
|
+
- Signup → First purchase: 12%
|
|
174
|
+
|
|
175
|
+
- **Long/complex funnels** (many steps): 5-15%
|
|
176
|
+
- Full e-commerce journey: 8%
|
|
177
|
+
- Multi-step onboarding: 12%
|
|
178
|
+
|
|
179
|
+
--------------
|
|
180
|
+
|
|
181
|
+
## Example Funnels
|
|
182
|
+
|
|
183
|
+
**E-commerce Purchase Journey**
|
|
184
|
+
```javascript
|
|
185
|
+
{
|
|
186
|
+
sequence: ["page view", "view item", "add to cart", "checkout"],
|
|
187
|
+
conversionRate: 12,
|
|
188
|
+
props: {
|
|
189
|
+
experiment_variant: ["control", "new_checkout", "express_checkout"],
|
|
190
|
+
traffic_source: ["organic", "paid", "referral", "email"],
|
|
191
|
+
device_type: ["mobile", "desktop"]
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**SaaS Onboarding Journey**
|
|
197
|
+
```javascript
|
|
198
|
+
{
|
|
199
|
+
sequence: ["sign up", "complete_profile", "create_first_project", "invite_team"],
|
|
200
|
+
conversionRate: 25,
|
|
201
|
+
props: {
|
|
202
|
+
onboarding_flow: ["guided_tour", "video_intro", "self_directed"],
|
|
203
|
+
signup_source: ["google", "github", "email", "sso"],
|
|
204
|
+
company_size: ["solo", "small_team", "enterprise"]
|
|
205
|
+
},
|
|
206
|
+
conditions: { plan: "free" }
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Content Engagement Journey**
|
|
211
|
+
```javascript
|
|
212
|
+
{
|
|
213
|
+
sequence: ["page view", "watch video", "save item", "share item"],
|
|
214
|
+
conversionRate: 8,
|
|
215
|
+
props: {
|
|
216
|
+
content_source: ["recommended", "search", "trending", "followed"],
|
|
217
|
+
user_segment: ["casual", "regular", "power_user"]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Feature Adoption with Experiment**
|
|
223
|
+
```javascript
|
|
224
|
+
{
|
|
225
|
+
sequence: ["view_feature", "enable_feature", "use_feature", "recommend_feature"],
|
|
226
|
+
conversionRate: 20,
|
|
227
|
+
props: {
|
|
228
|
+
experiment_variant: ["control", "prominent_cta", "video_demo", "social_proof"],
|
|
229
|
+
user_tier: ["free", "pro", "enterprise"]
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
--------------
|
|
235
|
+
|
|
236
|
+
## Output Format
|
|
237
|
+
|
|
238
|
+
Return a JavaScript object with a funnels array:
|
|
239
|
+
|
|
240
|
+
```javascript
|
|
241
|
+
{
|
|
242
|
+
funnels: [
|
|
243
|
+
{
|
|
244
|
+
sequence: ["event1", "event2", "event3"],
|
|
245
|
+
conversionRate: 15,
|
|
246
|
+
props: {
|
|
247
|
+
// Funnel-specific properties
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
sequence: ["event1", "event2"],
|
|
252
|
+
conversionRate: 30,
|
|
253
|
+
conditions: { plan: "premium" }
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
--------------
|
|
260
|
+
|
|
261
|
+
## Final Rules
|
|
262
|
+
|
|
263
|
+
1. **ONLY use event names that exist in the current schema** - check the events array carefully
|
|
264
|
+
2. Each funnel should tell a story (e.g., "signup journey", "purchase flow", "feature adoption")
|
|
265
|
+
3. Include funnel props when they add analytical value - especially for experiments and cohorts
|
|
266
|
+
4. Use conditions for segment-specific behaviors (free vs premium, new vs returning)
|
|
267
|
+
5. Conversion rates are integers 0-100 representing percentage - rarely above 50 unless high-intent
|
|
268
|
+
6. Create 3-6 funnels that represent different user journeys
|
|
269
|
+
7. Do NOT include explanations - only output the JavaScript object
|
|
270
|
+
8. Start with { and end with }
|
|
271
|
+
|
|
272
|
+
Generate funnels based on the user's description of the user journeys and conversion paths they want to track.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
{
|
|
2
|
+
"examples": [
|
|
3
|
+
{
|
|
4
|
+
"id": "time-based-search-degradation",
|
|
5
|
+
"prompt": "Search quality degraded 21 days ago. Since then, 50% of searches return zero results and 18% of users churn immediately after searching.",
|
|
6
|
+
"hookTypes": ["event"],
|
|
7
|
+
"patterns": ["time-based", "quality degradation", "churn"],
|
|
8
|
+
"response": "// Constants - Edit these values to customize the trend\nconst DAYS_AGO_SEARCH_BROKE = 21;\nconst LIKELIHOOD_ZERO_RESULTS = 50;\nconst LIKELIHOOD_CHURN_AFTER_SEARCH = 18;\n\nif (type === \"event\") {\n const NOW = dayjs();\n const TIME_WHEN_SEARCH_GOT_BAD = NOW.subtract(DAYS_AGO_SEARCH_BROKE, 'days');\n const EVENT_TIME = dayjs(record.time);\n\n // After search quality degraded\n if (EVENT_TIME.isAfter(TIME_WHEN_SEARCH_GOT_BAD)) {\n // Search returns no results more often\n if (record.event === \"search\") {\n if (chance.bool({ likelihood: LIKELIHOOD_ZERO_RESULTS })) {\n record[\"results count\"] = 0;\n }\n }\n\n // Users churn (remove event)\n if (chance.bool({ likelihood: LIKELIHOOD_CHURN_AFTER_SEARCH })) {\n return {};\n }\n }\n}\nreturn record;",
|
|
9
|
+
"useCase": "Model product quality issues and their impact on user behavior",
|
|
10
|
+
"complexity": "simple"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "ab-test-watch-time-subscription",
|
|
14
|
+
"prompt": "Users in variant A for the video recommendation experiment watch 70% longer and are 75% more likely to subscribe compared to users in variant B",
|
|
15
|
+
"hookTypes": ["everything"],
|
|
16
|
+
"patterns": ["A/B testing", "property correlation", "event injection", "conversion engineering"],
|
|
17
|
+
"response": "// Constants - Edit these to customize experiment effects\nconst DAYS_AGO_EXPERIMENT_LAUNCHED = 14;\nconst VARIANT_A_WATCH_TIME_BOOST = 1.7; // 70% increase\nconst VARIANT_A_SUBSCRIBE_LIKELIHOOD = 75;\nconst VARIANT_B_WATCH_TIME_REDUCTION = 0.5; // 50% decrease\nconst VARIANT_B_UNSUBSCRIBE_LIKELIHOOD = 75;\n\nif (type === \"everything\") {\n const NOW = dayjs();\n const TIME_WE_EXPERIMENTED = NOW.subtract(DAYS_AGO_EXPERIMENT_LAUNCHED, 'days');\n\n // Find which variant the user was in\n const hadVariantA = record.some(event =>\n event.event === \"$experiment_started\" &&\n event[\"Variant name\"] === \"A\"\n );\n\n const hadVariantB = record.some(event =>\n event.event === \"$experiment_started\" &&\n event[\"Variant name\"] === \"B\"\n );\n\n // Modify events based on variant\n record.forEach((event, idx) => {\n const EVENT_TIME = dayjs(event.time);\n\n // Only apply changes after experiment launch\n if (EVENT_TIME.isAfter(TIME_WE_EXPERIMENTED)) {\n if (hadVariantA) {\n // Variant A: Better outcomes\n if (event.event === \"watch video\" && chance.bool({ likelihood: VARIANT_A_SUBSCRIBE_LIKELIHOOD })) {\n // Increase watch time\n event[\"watch time\"] = v.round(event[\"watch time\"] * VARIANT_A_WATCH_TIME_BOOST);\n\n // Add subscribe event after watching\n const subscribeEvent = {\n event: \"subscribe\",\n time: dayjs(event.time).add(1, 'minute').toISOString(),\n user_id: event.user_id\n };\n record.splice(idx + 1, 0, subscribeEvent);\n }\n } else if (hadVariantB) {\n // Variant B: Worse outcomes\n if (event.event === \"subscribe\" && chance.bool({ likelihood: VARIANT_B_UNSUBSCRIBE_LIKELIHOOD })) {\n // Remove subscribe events\n record.splice(idx, 1);\n }\n\n if (event.event === \"watch video\") {\n // Decrease watch time\n event[\"watch time\"] = v.round(event[\"watch time\"] * VARIANT_B_WATCH_TIME_REDUCTION);\n }\n }\n }\n });\n}\nreturn record;",
|
|
18
|
+
"useCase": "Create realistic A/B test results with clear winner and loser variants",
|
|
19
|
+
"complexity": "advanced"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "revenue-boost-after-improvement",
|
|
23
|
+
"prompt": "After the improvement 15 days ago, checkout amounts increased 50% and video watch times increased 50%, but before that date, overall volume was down 33%",
|
|
24
|
+
"hookTypes": ["event"],
|
|
25
|
+
"patterns": ["time-based", "revenue engineering", "property manipulation"],
|
|
26
|
+
"response": "// Constants - Edit these to customize the trend\nconst DAYS_AGO_IMPROVEMENT = 15;\nconst REVENUE_BOOST_AFTER = 1.5; // 50% increase\nconst WATCH_TIME_BOOST_AFTER = 1.5; // 50% increase\nconst VOLUME_DROP_BEFORE = 33; // % of events to drop\n\nif (type === \"event\") {\n const NOW = dayjs();\n const IMPROVEMENT_DATE = NOW.subtract(DAYS_AGO_IMPROVEMENT, 'day');\n const EVENT_TIME = dayjs(record.time);\n\n // After improvement: Better metrics\n if (EVENT_TIME.isAfter(IMPROVEMENT_DATE)) {\n if (record.event === \"checkout\") {\n record.amount = Math.round(record.amount * REVENUE_BOOST_AFTER);\n }\n if (record.event === \"watch video\") {\n record.watchTimeSec = Math.round(record.watchTimeSec * WATCH_TIME_BOOST_AFTER);\n }\n }\n\n // Before improvement: Lower volume\n if (EVENT_TIME.isBefore(IMPROVEMENT_DATE)) {\n if (chance.bool({ likelihood: VOLUME_DROP_BEFORE })) {\n return {}; // Remove event\n }\n }\n}\nreturn record;",
|
|
27
|
+
"useCase": "Model product improvements and their impact on key metrics",
|
|
28
|
+
"complexity": "simple"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "premium-users-higher-engagement",
|
|
32
|
+
"prompt": "Users with custom theme have 3x more checkout events compared to users with light or dark themes",
|
|
33
|
+
"hookTypes": ["everything"],
|
|
34
|
+
"patterns": ["user segmentation", "property correlation", "event duplication"],
|
|
35
|
+
"response": "// Constants - Edit these to customize user segmentation\nconst PREMIUM_THEME_VALUE = \"custom\";\nconst PREMIUM_CHECKOUT_MULTIPLIER = 3;\nconst TIME_VARIANCE_HOURS = 48;\n\nif (type === \"everything\") {\n // Count events by theme\n const numCustomMode = record.filter(a => a.theme === PREMIUM_THEME_VALUE).length;\n const numLightMode = record.filter(a => a.theme === 'light').length;\n const numDarkMode = record.filter(a => a.theme === 'dark').length;\n\n // Premium theme users get more checkout events\n if (numCustomMode > numLightMode || numCustomMode > numDarkMode) {\n const checkoutEvents = record.filter(a => a.event === 'checkout');\n\n // Create additional checkouts\n const newCheckouts = checkoutEvents.map(a => {\n const randomInt = u.integer(-TIME_VARIANCE_HOURS, TIME_VARIANCE_HOURS);\n return {\n ...a,\n time: dayjs(a.time).add(randomInt, 'hour').toISOString(),\n event: \"checkout\",\n amount: a.amount * 2,\n coupon: \"50%OFF\"\n };\n });\n\n // Add new checkout events\n record.push(...newCheckouts);\n }\n}\nreturn record;",
|
|
36
|
+
"useCase": "Create correlations between user properties and behavior",
|
|
37
|
+
"complexity": "intermediate"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "low-quality-users-churn",
|
|
41
|
+
"prompt": "Users who watch low quality videos (480p, 360p, 240p) more than high quality videos have a 50% chance of churning halfway through their lifecycle",
|
|
42
|
+
"hookTypes": ["everything"],
|
|
43
|
+
"patterns": ["churn modeling", "quality correlation", "event deletion"],
|
|
44
|
+
"response": "// Constants - Edit these to customize churn behavior\nconst LOW_QUALITY_FORMATS = [\"480p\", \"360p\", \"240p\"];\nconst CHURN_LIKELIHOOD = 50;\n\nif (type === \"everything\") {\n // Count video quality\n const lowQualityWatches = record.filter(a =>\n a.event === 'watch video' &&\n LOW_QUALITY_FORMATS.includes(a.quality)\n );\n\n const highQualityWatches = record.filter(a =>\n a.event === 'watch video' &&\n !LOW_QUALITY_FORMATS.includes(a.quality)\n );\n\n // Users who watch more low quality content churn\n if (lowQualityWatches.length > highQualityWatches.length) {\n if (chance.bool({ likelihood: CHURN_LIKELIHOOD })) {\n // Remove second half of events (churn)\n const midpoint = Math.floor(record.length / 2);\n record = record.slice(0, midpoint);\n }\n }\n}\nreturn record;",
|
|
45
|
+
"useCase": "Model churn based on product quality or engagement patterns",
|
|
46
|
+
"complexity": "intermediate"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "infrastructure-outage",
|
|
50
|
+
"prompt": "AWS outage from October 19 to October 22 caused 88% of events to be dropped during that time window",
|
|
51
|
+
"hookTypes": ["event"],
|
|
52
|
+
"patterns": ["time-based", "infrastructure issues", "event deletion"],
|
|
53
|
+
"response": "// Constants - Edit these to customize the outage\nconst OUTAGE_START = \"2025-10-19\";\nconst OUTAGE_END = \"2025-10-22\";\nconst EVENT_DROP_RATE = 88;\n\nif (type === \"event\") {\n const AWS_OUTAGE_START = dayjs(OUTAGE_START);\n const AWS_OUTAGE_END = dayjs(OUTAGE_END);\n const EVENT_TIME = dayjs(record.time);\n\n // During outage, drop most events\n if (EVENT_TIME.isAfter(AWS_OUTAGE_START) && EVENT_TIME.isBefore(AWS_OUTAGE_END)) {\n if (chance.bool({ likelihood: EVENT_DROP_RATE })) {\n return {}; // Remove event\n }\n }\n}\nreturn record;",
|
|
54
|
+
"useCase": "Simulate infrastructure failures and their data impact",
|
|
55
|
+
"complexity": "simple"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "product-launch-adoption",
|
|
59
|
+
"prompt": "After the BYND stock squeeze on October 22, 10% of all trades are for that symbol",
|
|
60
|
+
"hookTypes": ["event"],
|
|
61
|
+
"patterns": ["time-based", "product launch", "property substitution"],
|
|
62
|
+
"response": "// Constants - Edit these to customize product launch\nconst LAUNCH_DATE = \"2025-10-22\";\nconst NEW_PRODUCT_NAME = \"BYND\";\nconst ADOPTION_RATE = 10;\nconst PROPERTY_NAME = \"asset_symbol\";\n\nif (type === \"event\") {\n const PRODUCT_LAUNCH = dayjs(LAUNCH_DATE);\n const EVENT_TIME = dayjs(record.time);\n\n // After launch, some users adopt new product\n if (EVENT_TIME.isAfter(PRODUCT_LAUNCH)) {\n if (record.hasOwnProperty(PROPERTY_NAME)) {\n if (chance.bool({ likelihood: ADOPTION_RATE })) {\n record[PROPERTY_NAME] = NEW_PRODUCT_NAME;\n }\n }\n }\n}\nreturn record;",
|
|
63
|
+
"useCase": "Model new product launches and adoption curves",
|
|
64
|
+
"complexity": "simple"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "email-campaign-lift",
|
|
68
|
+
"prompt": "Users who read marketing emails increase their purchase amounts by 10% per email read, up to a maximum of 50% total increase",
|
|
69
|
+
"hookTypes": ["everything"],
|
|
70
|
+
"patterns": ["marketing attribution", "cumulative effects", "property correlation"],
|
|
71
|
+
"response": "// Constants - Edit these to customize campaign effect\nconst EMAIL_UTM_MEDIUM = \"email (marketing)\";\nconst BOOST_PER_EMAIL = 0.10; // 10% per email\nconst MAX_BOOST = 0.50; // Max 50% boost\nconst PROPERTY_TO_BOOST = \"amount_usd\";\n\nif (type === \"everything\") {\n // Count email reads\n const emailReads = record.filter(e => {\n if (e.hasOwnProperty('utm_medium')) {\n if (e.utm_medium === EMAIL_UTM_MEDIUM) {\n return true;\n }\n }\n return false;\n });\n\n const numEmailReads = emailReads.length;\n\n // Apply cumulative boost based on email engagement\n if (numEmailReads > 0) {\n record.forEach(e => {\n if (e.hasOwnProperty(PROPERTY_TO_BOOST)) {\n // Calculate boost, capped at max\n const boostFactor = 1 + Math.min(numEmailReads * BOOST_PER_EMAIL, MAX_BOOST);\n e[PROPERTY_TO_BOOST] = Math.round(e[PROPERTY_TO_BOOST] * boostFactor);\n }\n });\n }\n}\nreturn record;",
|
|
72
|
+
"useCase": "Model cumulative marketing campaign effects on user behavior",
|
|
73
|
+
"complexity": "intermediate"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "loan-approval-rate-change",
|
|
77
|
+
"prompt": "Before the rate change 17 days ago, student loans were declined 60% of the time. After the change, student loans convert to auto loans 60% of the time, and auto loans get approved 60% of the time but take 1-20 minutes longer",
|
|
78
|
+
"hookTypes": ["funnel-post"],
|
|
79
|
+
"patterns": ["time-based", "funnel manipulation", "approval engineering", "timing manipulation"],
|
|
80
|
+
"response": "// Constants - Edit these to customize approval rates\nconst DAYS_AGO_RATE_CHANGE = 17;\nconst BEFORE_DECLINE_RATE = 60;\nconst AFTER_CONVERSION_RATE = 60;\nconst AFTER_APPROVAL_RATE = 60;\nconst MIN_DELAY_MINUTES = 1;\nconst MAX_DELAY_MINUTES = 20;\n\nif (type === \"funnel-post\") {\n const RATE_CHANGE_DATE = dayjs().subtract(DAYS_AGO_RATE_CHANGE, 'd');\n\n // Check if this is a loan application funnel\n if (record[0]?.event === \"loan app start\") {\n const funnelStartTime = dayjs(record[0].time);\n\n // Before rate change: Student loans declined\n if (funnelStartTime.isBefore(RATE_CHANGE_DATE)) {\n if (record[0][\"loan type\"] === \"student loan\") {\n if (chance.bool({ likelihood: BEFORE_DECLINE_RATE })) {\n record.forEach((r) => {\n r[\"application status\"] = \"declined\";\n });\n }\n }\n }\n\n // After rate change: Better outcomes\n if (funnelStartTime.isAfter(RATE_CHANGE_DATE)) {\n // Convert student loans to auto loans\n if (record[0][\"loan type\"] === \"student loan\") {\n if (chance.bool({ likelihood: AFTER_CONVERSION_RATE })) {\n record.forEach((r) => {\n r[\"loan type\"] = \"auto loan\";\n });\n }\n }\n\n // Auto loans get approved\n if (record[0][\"loan type\"] === \"auto loan\") {\n if (chance.bool({ likelihood: AFTER_APPROVAL_RATE })) {\n record.forEach((r) => {\n r[\"application status\"] = \"approved\";\n });\n }\n\n // But they take longer\n record.forEach((ev, index) => {\n if (index > 0) {\n const minutes = u.integer(MIN_DELAY_MINUTES, MAX_DELAY_MINUTES);\n ev.time = dayjs(ev.time).add(minutes, \"minute\").toISOString();\n }\n });\n }\n }\n }\n}\nreturn record;",
|
|
81
|
+
"useCase": "Engineer complex funnel behavior changes over time",
|
|
82
|
+
"complexity": "advanced"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "ai-model-product-adoption",
|
|
86
|
+
"prompt": "Users exposed to AI model Q use more products. Users exposed to model BERT use fewer products. Product count directly affects event volume: users with 3+ products have 40% more events, users with <3 products have 40% fewer events",
|
|
87
|
+
"hookTypes": ["everything"],
|
|
88
|
+
"patterns": ["AI impact", "product adoption", "event volume correlation", "retention"],
|
|
89
|
+
"response": "// Constants - Edit these to customize AI impact\nconst HIGH_PERFORMING_MODEL = \"Q\";\nconst LOW_PERFORMING_MODEL = \"BERT\";\nconst PRODUCT_THRESHOLD = 3;\nconst HIGH_PRODUCT_EVENT_BOOST_LIKELIHOOD = 40;\nconst LOW_PRODUCT_EVENT_REDUCTION_LIKELIHOOD = 40;\nconst EVENT_DUPLICATION_RATE = 20;\nconst EVENT_DELETION_RATE = 20;\nconst MIN_EVENT_DELAY_MINUTES = 1;\nconst MAX_EVENT_DELAY_MINUTES = 90;\n\nif (type === \"everything\") {\n // Count AI model exposures\n const AIModelExposure = record.map(a => a[\"AI model\"]).filter(Boolean);\n const numHighPerformingExposure = AIModelExposure.filter(a => a === HIGH_PERFORMING_MODEL).length;\n const numLowPerformingExposure = AIModelExposure.filter(a => a === LOW_PERFORMING_MODEL).length;\n\n // AI exposure affects product count\n if (chance.bool({ likelihood: 50 })) {\n const ratio = Math.floor(numHighPerformingExposure / numLowPerformingExposure) || 1;\n // Note: This assumes a listOfProducts() function exists in meta.defaults\n // Adjust based on actual schema\n }\n\n const { profile } = meta;\n\n // High product users: More events and retention\n if (profile[\"products used\"] && profile[\"products used\"].length > PRODUCT_THRESHOLD) {\n if (chance.bool({ likelihood: HIGH_PRODUCT_EVENT_BOOST_LIKELIHOOD })) {\n // Duplicate events randomly\n record.forEach((ev, index) => {\n if (index > 0) {\n if (chance.bool({ likelihood: EVENT_DUPLICATION_RATE })) {\n const clone = u.clone(ev);\n const delay = u.integer(MIN_EVENT_DELAY_MINUTES, MAX_EVENT_DELAY_MINUTES);\n clone.time = dayjs(ev.time).add(delay, \"minute\").toISOString();\n record.push(clone);\n }\n }\n });\n }\n }\n\n // Low product users: Fewer events and worse retention\n if (profile[\"products used\"] && profile[\"products used\"].length < PRODUCT_THRESHOLD) {\n if (chance.bool({ likelihood: LOW_PRODUCT_EVENT_REDUCTION_LIKELIHOOD })) {\n // Delete events randomly\n record = record.filter((ev, index) => {\n return !(index > 0 && chance.bool({ likelihood: EVENT_DELETION_RATE }));\n });\n }\n }\n}\nreturn record;",
|
|
90
|
+
"useCase": "Model AI/ML feature impact on product adoption and engagement",
|
|
91
|
+
"complexity": "advanced"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "department-role-correlation",
|
|
95
|
+
"prompt": "Users in the engineering department are admin 50% of the time, while users in sales have no access 50% of the time",
|
|
96
|
+
"hookTypes": ["scd-pre"],
|
|
97
|
+
"patterns": ["user segmentation", "role-based access", "SCD manipulation"],
|
|
98
|
+
"response": "// Constants - Edit these to customize role assignments\nconst ENGINEERING_DEPT = \"engineering\";\nconst SALES_DEPT = \"sales\";\nconst ENGINEERING_ADMIN_LIKELIHOOD = 50;\nconst SALES_NO_ACCESS_LIKELIHOOD = 50;\nconst ADMIN_ROLE = \"admin\";\nconst NO_ACCESS_ROLE = \"no access\";\n\nif (type === \"scd-pre\") {\n const { type: scdType, profile, scd } = meta;\n const prop = Object.keys(scd)[0];\n\n // Only apply to user SCDs for role property\n if (scdType === \"user\" && prop === \"role\") {\n // Engineering users are admins more often\n if (profile.department === ENGINEERING_DEPT) {\n for (const entry of record) {\n if (chance.bool({ likelihood: ENGINEERING_ADMIN_LIKELIHOOD })) {\n entry.role = ADMIN_ROLE;\n }\n }\n }\n\n // Sales users have no access more often\n if (profile.department === SALES_DEPT) {\n for (const entry of record) {\n if (chance.bool({ likelihood: SALES_NO_ACCESS_LIKELIHOOD })) {\n entry.role = NO_ACCESS_ROLE;\n }\n }\n }\n }\n}\nreturn record;",
|
|
99
|
+
"useCase": "Create realistic role-based access patterns based on user attributes",
|
|
100
|
+
"complexity": "intermediate"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"id": "nps-improvement-over-time",
|
|
104
|
+
"prompt": "Users with 3 or more preferred features see NPS scores improve by 10% month over month",
|
|
105
|
+
"hookTypes": ["scd-pre"],
|
|
106
|
+
"patterns": ["progressive improvement", "feature adoption impact", "SCD manipulation"],
|
|
107
|
+
"response": "// Constants - Edit these to customize NPS improvement\nconst FEATURE_THRESHOLD = 3;\nconst MONTHLY_NPS_IMPROVEMENT = 0.10; // 10% improvement\nconst MAX_NPS_SCORE = 10;\n\nif (type === \"scd-pre\") {\n const { type: scdType, profile, scd } = meta;\n const prop = Object.keys(scd)[0];\n\n // Only apply to user NPS property\n if (scdType === \"user\" && prop === \"NPS\") {\n // Check if user has enough preferred features\n const hasEnoughFeatures = profile[\"preferred features\"] &&\n profile[\"preferred features\"].length >= FEATURE_THRESHOLD;\n\n if (hasEnoughFeatures) {\n // Apply progressive improvement over time\n let lastNPS = record[0].NPS;\n\n for (const [index, entry] of record.entries()) {\n if (index === 0) continue; // Skip first entry\n\n // Increase NPS by improvement factor\n entry.NPS = Math.floor(lastNPS + (lastNPS * MONTHLY_NPS_IMPROVEMENT));\n\n // Cap at max score\n if (entry.NPS > MAX_NPS_SCORE) entry.NPS = MAX_NPS_SCORE;\n\n lastNPS = entry.NPS;\n }\n }\n }\n}\nreturn record;",
|
|
108
|
+
"useCase": "Model progressive satisfaction improvements based on feature adoption",
|
|
109
|
+
"complexity": "intermediate"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"id": "mrr-growth-multi-product",
|
|
113
|
+
"prompt": "Companies with 3 or more products experience 10% MRR growth every month. 20% of companies churn and their MRR drops to zero after a random month",
|
|
114
|
+
"hookTypes": ["scd-pre"],
|
|
115
|
+
"patterns": ["revenue growth", "churn modeling", "multi-product correlation", "SCD manipulation"],
|
|
116
|
+
"response": "// Constants - Edit these to customize MRR trends\nconst PRODUCT_THRESHOLD = 3;\nconst MONTHLY_GROWTH_RATE = 0.10; // 10% growth\nconst CHURN_LIKELIHOOD = 20;\n\nif (type === \"scd-pre\") {\n const { type: scdType, profile, scd } = meta;\n const prop = Object.keys(scd)[0];\n\n // Only apply to group MRR property\n if (scdType !== \"user\" && prop === \"MRR\") {\n // Multi-product companies grow MRR\n if (profile.products && profile.products.length > PRODUCT_THRESHOLD) {\n let lastMRR = record[0].MRR;\n\n for (const [index, entry] of record.entries()) {\n if (index === 0) continue; // Skip first entry\n\n // Apply monthly growth\n entry.MRR = Math.floor(lastMRR * (1 + MONTHLY_GROWTH_RATE));\n lastMRR = entry.MRR;\n }\n }\n\n // Some companies churn\n if (chance.bool({ likelihood: CHURN_LIKELIHOOD })) {\n const size = record.length;\n const churnIndex = u.integer(1, size - 1);\n\n // Set MRR to 0 after churn point\n for (const [index, entry] of record.entries()) {\n if (index > churnIndex) {\n entry.MRR = 0;\n }\n }\n }\n }\n}\nreturn record;",
|
|
117
|
+
"useCase": "Model B2B revenue growth and churn patterns",
|
|
118
|
+
"complexity": "advanced"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"id": "csm-performance-impact",
|
|
122
|
+
"prompt": "Accounts managed by CSM named AK have 50% higher MRR than other accounts",
|
|
123
|
+
"hookTypes": ["scd-pre"],
|
|
124
|
+
"patterns": ["CSM performance", "account segmentation", "SCD manipulation"],
|
|
125
|
+
"response": "// Constants - Edit these to customize CSM impact\nconst HIGH_PERFORMING_CSM = \"AK\";\nconst MRR_BOOST_FACTOR = 1.5; // 50% higher\n\nif (type === \"scd-pre\") {\n const { type: scdType, profile, scd } = meta;\n const prop = Object.keys(scd)[0];\n\n // Only apply to group MRR property\n if (scdType !== \"user\" && prop === \"MRR\") {\n // Check if account is managed by high-performing CSM\n if (profile.CSM === HIGH_PERFORMING_CSM) {\n for (const entry of record) {\n entry.MRR = Math.floor(entry.MRR * MRR_BOOST_FACTOR);\n }\n }\n }\n}\nreturn record;",
|
|
126
|
+
"useCase": "Model CSM performance impact on account metrics",
|
|
127
|
+
"complexity": "simple"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"id": "experiment-event-ordering",
|
|
131
|
+
"prompt": "Ensure experiment start events always appear first in funnel sequences to maintain proper attribution",
|
|
132
|
+
"hookTypes": ["funnel-pre"],
|
|
133
|
+
"patterns": ["experiment handling", "event ordering", "funnel manipulation"],
|
|
134
|
+
"response": "// This hook ensures experiment events are always first\nconst EXPERIMENT_EVENT_NAME = \"$experiment_started\";\n\nif (type === \"funnel-pre\") {\n const sequence = u.clone(record.sequence);\n\n // Check if experiment event exists in sequence\n if (sequence.includes(EXPERIMENT_EVENT_NAME)) {\n // Remove from current position\n const newSequence = sequence.filter((event) => event !== EXPERIMENT_EVENT_NAME);\n\n // Add to beginning\n newSequence.unshift(EXPERIMENT_EVENT_NAME);\n\n record.sequence = newSequence;\n }\n}\nreturn record;",
|
|
135
|
+
"useCase": "Maintain clean experiment attribution in funnel analysis",
|
|
136
|
+
"complexity": "simple"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"id": "progressive-conversion-improvement",
|
|
140
|
+
"prompt": "Conversion rates were 50-90% of normal before the improvement 30 days ago. After the improvement, conversion rates progressively increased by 2% per day for 30 days, reaching up to 200% of baseline",
|
|
141
|
+
"hookTypes": ["funnel-pre"],
|
|
142
|
+
"patterns": ["time-based", "progressive improvement", "conversion engineering"],
|
|
143
|
+
"response": "// Constants - Edit these to customize conversion trends\nconst DAYS_AGO_IMPROVEMENT = 30;\nconst BEFORE_MIN_FACTOR = 0.5; // 50% of normal\nconst BEFORE_MAX_FACTOR = 0.9; // 90% of normal\nconst IMPROVEMENT_DAYS = 30;\nconst MAX_IMPROVEMENT_FACTOR = 2.0; // 200% of normal\n\nif (type === \"funnel-pre\") {\n const NOW = dayjs();\n const IMPROVEMENT_DATE = NOW.subtract(DAYS_AGO_IMPROVEMENT, 'day');\n const parsedFirstEventTime = dayjs.unix(meta.firstEventTime);\n\n // Adjust for time offset\n const actualFunnelTime = parsedFirstEventTime.add(\n NOW.diff(dayjs.unix(global.FIXED_NOW), 'h'),\n 'h'\n );\n\n // Before improvement: Worse conversion\n if (actualFunnelTime.isBefore(IMPROVEMENT_DATE)) {\n record.conversionRate *= decimal(BEFORE_MIN_FACTOR, BEFORE_MAX_FACTOR, 3);\n }\n\n // After improvement: Progressive improvement\n if (actualFunnelTime.isAfter(IMPROVEMENT_DATE)) {\n // Calculate days since improvement (capped at improvement period)\n const daysSinceImprovement = Math.min(\n IMPROVEMENT_DAYS,\n actualFunnelTime.diff(IMPROVEMENT_DATE, 'day')\n );\n\n // Calculate improvement factor (0 to 100% over period)\n const improvementPercent = daysSinceImprovement / IMPROVEMENT_DAYS;\n const improvementFactor = 1.0 + (improvementPercent * (MAX_IMPROVEMENT_FACTOR - 1.0));\n\n record.conversionRate *= decimal(1.0, MAX_IMPROVEMENT_FACTOR, 4) * improvementFactor;\n }\n}\nreturn record;",
|
|
144
|
+
"useCase": "Model realistic product improvement curves in funnel performance",
|
|
145
|
+
"complexity": "advanced"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"id": "multi-type-power-user-behavior",
|
|
149
|
+
"prompt": "Power users (who do more than 10 actions per week) have 2x higher event properties, 40% better funnel conversion rates, and never experience errors. Regular users have normal metrics.",
|
|
150
|
+
"hookTypes": ["event", "funnel-pre", "everything"],
|
|
151
|
+
"patterns": ["user segmentation", "multi-type composition", "conversion engineering", "property correlation", "error suppression"],
|
|
152
|
+
"response": "// Constants - Edit these to customize power user behavior\nconst POWER_USER_THRESHOLD = 10; // events per week\nconst POWER_USER_PROPERTY_MULTIPLIER = 2.0;\nconst POWER_USER_CONVERSION_BOOST = 40; // percentage points\nconst REGULAR_USER_ERROR_RATE = 5; // percentage\n\n// Track power users across hook types\nlet isPowerUser = false;\n\n// STEP 1: Identify power users from their event volume\nif (type === \"everything\") {\n const { profile, distinct_id } = meta;\n \n // Count events in the last 7 days\n const sevenDaysAgo = dayjs().subtract(7, 'days');\n const recentEvents = record.filter(event => \n dayjs(event.time).isAfter(sevenDaysAgo)\n );\n \n // Mark as power user if above threshold\n if (recentEvents.length > POWER_USER_THRESHOLD) {\n isPowerUser = true;\n \n // Remove all error events from power users\n record = record.filter(event => \n event.event !== \"error\" && \n event.event !== \"timeout\" &&\n event.event !== \"crash\"\n );\n } else {\n // Regular users occasionally have errors\n if (chance.bool({ likelihood: REGULAR_USER_ERROR_RATE })) {\n const errorEvent = {\n event: \"error\",\n time: chance.pickone(record).time,\n error_type: \"timeout\",\n distinct_id: distinct_id\n };\n record.push(errorEvent);\n }\n }\n}\n\n// STEP 2: Boost numeric properties for power users\nif (type === \"event\" && isPowerUser) {\n // Double all numeric properties for power users\n Object.keys(record).forEach(key => {\n if (typeof record[key] === 'number' && key !== 'time') {\n record[key] = Math.round(record[key] * POWER_USER_PROPERTY_MULTIPLIER);\n }\n });\n}\n\n// STEP 3: Improve funnel conversion for power users\nif (type === \"funnel-pre\" && isPowerUser) {\n // Increase conversion rate\n if (record.conversionRate) {\n const currentRate = record.conversionRate * 100;\n const boostedRate = Math.min(95, currentRate + POWER_USER_CONVERSION_BOOST);\n record.conversionRate = boostedRate / 100;\n }\n \n // Reduce time between funnel steps\n if (record.timing === \"random\") {\n record.timing = \"tight\"; // Faster progression\n }\n}\n\nreturn record;",
|
|
153
|
+
"useCase": "Demonstrate composing multiple hook types to create sophisticated user segmentation with cross-cutting concerns",
|
|
154
|
+
"complexity": "advanced"
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"metadata": {
|
|
158
|
+
"version": "1.0.0",
|
|
159
|
+
"totalExamples": 17,
|
|
160
|
+
"hookTypesCovered": [
|
|
161
|
+
"event",
|
|
162
|
+
"everything",
|
|
163
|
+
"funnel-pre",
|
|
164
|
+
"funnel-post",
|
|
165
|
+
"scd-pre"
|
|
166
|
+
],
|
|
167
|
+
"patternsCovered": [
|
|
168
|
+
"time-based",
|
|
169
|
+
"A/B testing",
|
|
170
|
+
"conversion engineering",
|
|
171
|
+
"property correlation",
|
|
172
|
+
"user segmentation",
|
|
173
|
+
"churn modeling",
|
|
174
|
+
"revenue engineering",
|
|
175
|
+
"infrastructure issues",
|
|
176
|
+
"product launch",
|
|
177
|
+
"marketing attribution",
|
|
178
|
+
"AI impact",
|
|
179
|
+
"role-based access",
|
|
180
|
+
"progressive improvement",
|
|
181
|
+
"CSM performance",
|
|
182
|
+
"experiment handling",
|
|
183
|
+
"multi-type composition",
|
|
184
|
+
"error suppression"
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
}
|