make-mp-data 3.0.4 → 3.0.5

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 (70) hide show
  1. package/README.md +46 -0
  2. package/dungeons/array-of-object-lookup-schema.json +327 -0
  3. package/dungeons/array-of-object-lookup.js +28 -8
  4. package/dungeons/capstone/capstone-ic3.js +291 -0
  5. package/dungeons/capstone/capstone-ic4.js +598 -0
  6. package/dungeons/capstone/capstone-ic5.js +668 -0
  7. package/dungeons/capstone/generate-product-lookup.js +309 -0
  8. package/dungeons/ecommerce-schema.json +462 -0
  9. package/dungeons/{copilot.js → ecommerce.js} +77 -15
  10. package/dungeons/education-schema.json +2409 -0
  11. package/dungeons/education.js +206 -442
  12. package/dungeons/fintech-schema.json +14034 -0
  13. package/dungeons/fintech.js +110 -389
  14. package/dungeons/foobar-schema.json +403 -0
  15. package/dungeons/foobar.js +27 -4
  16. package/dungeons/food-delivery-schema.json +192 -0
  17. package/dungeons/food-delivery.js +602 -0
  18. package/dungeons/food-schema.json +1152 -0
  19. package/dungeons/food.js +150 -383
  20. package/dungeons/gaming-schema.json +1270 -0
  21. package/dungeons/gaming.js +143 -3
  22. package/dungeons/insurance-application-schema.json +204 -0
  23. package/dungeons/insurance-application.js +605 -0
  24. package/dungeons/media-schema.json +906 -0
  25. package/dungeons/media.js +221 -391
  26. package/dungeons/retention-cadence-schema.json +78 -0
  27. package/dungeons/retention-cadence.js +35 -1
  28. package/dungeons/rpg-schema.json +4526 -0
  29. package/dungeons/rpg.js +130 -388
  30. package/dungeons/sanity-schema.json +255 -0
  31. package/dungeons/sanity.js +21 -10
  32. package/dungeons/sass-schema.json +1291 -0
  33. package/dungeons/sass.js +210 -337
  34. package/dungeons/scd-schema.json +919 -0
  35. package/dungeons/scd.js +38 -10
  36. package/dungeons/simple-schema.json +608 -0
  37. package/dungeons/simple.js +48 -11
  38. package/dungeons/simplest-schema.json +1418 -0
  39. package/dungeons/simplest.js +392 -0
  40. package/dungeons/social-schema.json +1118 -0
  41. package/dungeons/social.js +124 -365
  42. package/dungeons/text-generation-schema.json +3096 -0
  43. package/dungeons/text-generation.js +71 -0
  44. package/index.js +6 -3
  45. package/lib/core/config-validator.js +18 -0
  46. package/lib/core/storage.js +5 -5
  47. package/lib/generators/events.js +4 -4
  48. package/lib/orchestrators/mixpanel-sender.js +12 -7
  49. package/lib/orchestrators/user-loop.js +14 -6
  50. package/lib/templates/soup-presets.js +188 -0
  51. package/lib/utils/utils.js +52 -6
  52. package/package.json +1 -1
  53. package/types.d.ts +20 -3
  54. package/dungeons/adspend.js +0 -117
  55. package/dungeons/anon.js +0 -128
  56. package/dungeons/benchmark-heavy.js +0 -240
  57. package/dungeons/benchmark-light.js +0 -126
  58. package/dungeons/big.js +0 -226
  59. package/dungeons/business.js +0 -391
  60. package/dungeons/complex.js +0 -428
  61. package/dungeons/experiments.js +0 -137
  62. package/dungeons/funnels.js +0 -309
  63. package/dungeons/mil.js +0 -323
  64. package/dungeons/mirror.js +0 -160
  65. package/dungeons/soup-test.js +0 -52
  66. package/dungeons/streaming.js +0 -372
  67. package/dungeons/strict-event-test.js +0 -30
  68. package/dungeons/student-teacher.js +0 -438
  69. package/dungeons/too-big-events.js +0 -203
  70. package/dungeons/user-agent.js +0 -209
package/dungeons/food.js CHANGED
@@ -10,63 +10,142 @@ const chance = u.initChance(SEED);
10
10
  const num_users = 5_000;
11
11
  const days = 100;
12
12
 
13
- /** @typedef {import("../../types.js").Dungeon} Config */
13
+ /** @typedef {import("../types.d.ts").Dungeon} Config */
14
14
 
15
- /**
16
- * NEEDLE IN A HAYSTACK - FOOD DELIVERY APP DESIGN
15
+ /*
16
+ * ═══════════════════════════════════════════════════════════════════════════════
17
+ * DATASET OVERVIEW
18
+ * ═══════════════════════════════════════════════════════════════════════════════
19
+ *
20
+ * QuickBite — a food delivery platform (DoorDash/Uber Eats style).
21
+ * Users browse restaurants, build carts, place orders, track deliveries,
22
+ * and rate their experiences.
23
+ *
24
+ * Scale: 5,000 users · 600K events · 100 days · 17 event types
25
+ *
26
+ * Core loop:
27
+ * sign up → browse/search restaurants → add items to cart →
28
+ * checkout → order placed → track delivery → rate → reorder
29
+ *
30
+ * Restaurant ecosystem: 200 restaurants across 8 cuisine types,
31
+ * four price tiers ($–$$$$), modeled as group profiles.
32
+ *
33
+ * Monetization: delivery fees, QuickBite+ subscription ($9.99/mo or
34
+ * $79.99/yr for free delivery), and promotional coupons.
35
+ *
36
+ * Support & retention: support tickets (missing items, wrong orders,
37
+ * late delivery, quality, refunds) and reorder events model service
38
+ * quality and repeat behavior.
39
+ *
40
+ * Subscription tiers: Free vs QuickBite+ create a natural A/B
41
+ * comparison for monetization and retention analysis.
42
+ */
43
+
44
+ /*
45
+ * ═══════════════════════════════════════════════════════════════════════════════
46
+ * ANALYTICS HOOKS (8 architected patterns)
47
+ * ═══════════════════════════════════════════════════════════════════════════════
17
48
  *
18
- * QuickBite - A food delivery platform connecting hungry customers with local restaurants.
19
- * Think DoorDash/Uber Eats: users browse restaurants, build carts, place orders, track
20
- * deliveries in real-time, and rate their experiences afterward.
49
+ * 1. LUNCH RUSH CONVERSION (funnel-pre)
50
+ * Funnel conversion boosted during meal hours: lunch 1.4x, dinner 1.2x.
51
+ * Mixpanel:
52
+ * • Funnels → "checkout started" → "order placed" → "order delivered"
53
+ * Breakdown: "lunch_rush" → expect ~84% vs ~60% baseline
54
+ * • Same funnel, breakdown: "dinner_rush" → expect ~72% vs ~60%
21
55
  *
22
- * CORE USER LOOP:
23
- * Users sign up (email, Google, Apple, Facebook) and immediately enter a discovery flow.
24
- * They browse restaurants by cuisine, sort by distance/rating/price, search for specific
25
- * dishes, and eventually land on a restaurant page. From there, they build a cart by adding
26
- * items (entrees, appetizers, drinks, desserts, sides) with customizations. Checkout
27
- * captures payment, tip, and delivery details. After ordering, users track their delivery
28
- * through multiple statuses (confirmed, preparing, picked up, en route, delivered).
56
+ * 2. COUPON INJECTION (funnel-post)
57
+ * Free-tier users get coupon_applied spliced into funnels 30% of the time.
58
+ * Mixpanel:
59
+ * Insights "coupon applied" breakdown "coupon_injected"
60
+ * ~30% of Free-tier coupons are injected
61
+ * Insights "coupon applied" breakdown "subscription_tier"
62
+ * Free users have more coupon events
29
63
  *
30
- * RESTAURANT ECOSYSTEM:
31
- * 200 restaurants across cuisine types: American, Italian, Chinese, Japanese, Mexican,
32
- * Indian, Thai, and Mediterranean. Restaurants span four price tiers ($, $$, $$$, $$$$)
33
- * with varying delivery times and ratings. This models a realistic marketplace with
34
- * restaurant-level analytics via group profiles.
64
+ * 3. LATE NIGHT MUNCHIES (event)
65
+ * 10PM–2AM: 70% American cuisine, 1.3x item prices, late_night_order=true.
66
+ * Mixpanel:
67
+ * Insights "restaurant viewed" breakdown "cuisine_type"
68
+ * filter: late_night_order=true ~70% American vs ~12% daytime
69
+ * • Insights → "item added to cart" → avg "item_price"
70
+ * breakdown: "late_night_order" → 1.3x higher at night
71
+ *
72
+ * 4. RAINY WEEK SURGE (event + everything)
73
+ * Days 20–27: delivery fees 2x, surge_pricing=true, 40% order duplication.
74
+ * Mixpanel:
75
+ * • Insights (line) → "order placed" → daily → visible spike days 20–27
76
+ * • Insights → "order placed" → avg "delivery_fee"
77
+ * breakdown: "surge_pricing" → 2x higher
35
78
  *
36
- * DISCOVERY & SEARCH:
37
- * Two paths to finding food: browsing (filtering by cuisine, sorting by rating/distance/price)
38
- * and searching (by restaurant name, cuisine type, or specific dish). The search-to-order
39
- * funnel captures intent-driven behavior vs. casual browsing.
79
+ * 5. REFERRAL POWER USERS (everything)
80
+ * Referred users: 2x reorders, food_rating 4–5 stars, referral_user=true.
81
+ * Mixpanel:
82
+ * Insights "reorder initiated" per user
83
+ * breakdown: "referral_user" → ~2x more reorders
84
+ * • Insights → "order rated" → avg "food_rating"
85
+ * breakdown: "referral_user" → 4–5 vs ~3.5 baseline
86
+ *
87
+ * 6. TRIAL CONVERSION (everything)
88
+ * Trial subs with 3+ orders in 14 days retained; others lose 60% of events.
89
+ * Mixpanel:
90
+ * • Insights → any event → per user
91
+ * breakdown: "trial_retained" → sustained vs ~60% drop
92
+ * • Retention → "subscription started" (trial=true) → "order placed"
93
+ * → sharp drop after day 14 for non-retained
94
+ *
95
+ * 7. SUPPORT TICKET CHURN (user)
96
+ * 15% of users flagged is_high_risk=true with churn_risk_score 70–100.
97
+ * Mixpanel:
98
+ * • Insights → any event → unique users
99
+ * breakdown: user "is_high_risk" → ~15% high-risk
100
+ * • Insights → breakdown: user "churn_risk_score"
101
+ * → bimodal: 85% at 0–40, 15% at 70–100
40
102
  *
41
- * MONETIZATION MODEL:
42
- * - Delivery fees ($0-$12, waived for QuickBite+ subscribers)
43
- * - QuickBite+ subscription ($9.99/month or $79.99/year) for free delivery and perks
44
- * - Promotions and coupons drive trial and reactivation
45
- * - Restaurant-promoted listings (not modeled as user events)
103
+ * 8. FIRST ORDER BONUS (funnel-pre)
104
+ * New users get 1.4x conversion boost on checkout→order funnel.
105
+ * Mixpanel:
106
+ * Funnels "checkout started" "order placed" → "order delivered"
107
+ * breakdown: "first_order_bonus" 1.4x higher conversion
108
+ * • Insights → "order placed" → breakdown "first_order_bonus"
109
+ * → ~50% tagged (hash-based user split)
46
110
  *
47
- * CART BEHAVIOR:
48
- * Cart events (add/remove) capture the deliberation process. Removal reasons
49
- * (changed_mind, too_expensive, substitution) reveal price sensitivity and UX friction.
50
- * Customization counts show engagement depth with individual items.
111
+ * ───────────────────────────────────────────────────────────────────────────────
112
+ * ADVANCED ANALYSIS IDEAS
113
+ * ───────────────────────────────────────────────────────────────────────────────
51
114
  *
52
- * ORDER LIFECYCLE:
53
- * order placed -> order tracked (multiple status updates) -> order delivered -> order rated
54
- * This models the full post-purchase experience. On-time delivery, actual vs. estimated
55
- * delivery time, and food/delivery ratings capture service quality metrics.
115
+ * Cross-hook patterns:
116
+ * The Perfect Customer: referral (5) + trial retained (6) + lunch rush (1)
117
+ * + low churn risk (7) exceptional LTV and retention
118
+ * Rainy Night Double Whammy: late-night (3) + rainy week (4)
119
+ * → compounded surge pricing?
120
+ * • Coupon-Driven Trial: injected coupons (2) → trial starts (6)?
121
+ * • Referral + First Order: hooks 5 + 8 → highest conversion rates
122
+ * • Support and Churn: high-risk (7) + support tickets during rainy week (4)
123
+ *
124
+ * Cohort analysis:
125
+ * • Signup week (rainy week cohort behaves differently)
126
+ * • Referral vs organic lifecycle
127
+ * • Free vs QuickBite+ across all metrics
128
+ * • City-level cuisine and ordering patterns
129
+ *
130
+ * Funnel analysis:
131
+ * • Onboarding: account created → first restaurant view, by signup method
132
+ * • Order: checkout → delivery, by platform / tier / time of day
133
+ * • Discovery: search type → conversion to ordering
56
134
  *
57
- * SUPPORT & RETENTION:
58
- * Support tickets (missing items, wrong orders, late delivery, quality issues, refund
59
- * requests) model service failures. Reorder events capture repeat behavior and loyalty.
60
- * The ratio of support tickets to orders is a key service quality indicator.
135
+ * ───────────────────────────────────────────────────────────────────────────────
136
+ * EXPECTED METRICS SUMMARY
137
+ * ───────────────────────────────────────────────────────────────────────────────
61
138
  *
62
- * WHY THESE EVENTS/PROPERTIES?
63
- * - Events model the complete food delivery loop: discovery -> consideration -> purchase -> fulfillment -> retention
64
- * - Properties enable cohort analysis: cuisine preferences, price sensitivity, platform usage, subscription status
65
- * - Funnels reveal friction: where do users drop off between browsing and ordering?
66
- * - Time-based patterns (lunch rush, late night) simulate real delivery demand curves
67
- * - Subscription tier (Free vs QuickBite+) creates a natural A/B comparison for monetization analysis
68
- * - Support and rating events drive churn prediction and service quality monitoring
69
- * - The "needle in haystack" hooks simulate real product insights hidden in production data
139
+ * Hook | Metric | Baseline | Hook Effect | Ratio
140
+ * ──────────────────────|──────────────────────|──────────|─────────────|──────
141
+ * Lunch Rush | Funnel conversion | 60% | 84% | 1.4x
142
+ * Coupon Injection | Free user coupons | 0% | 30% | N/A
143
+ * Late Night Munchies | American cuisine % | ~15% | 70% | ~4.7x
144
+ * Rainy Week Surge | Order volume | 100% | 140% | 1.4x
145
+ * Referral Power Users | Reorder frequency | 1x | 2x | 2.0x
146
+ * Trial Conversion | Post-trial retention | 100% | 40% | 0.4x
147
+ * Support Ticket Churn | High-risk users | 0% | 15% | N/A
148
+ * First Order Bonus | New user conversion | 1x | 1.4x | 1.4x
70
149
  */
71
150
 
72
151
  // Generate consistent IDs for lookup tables and event properties
@@ -415,7 +494,7 @@ const config = {
415
494
  // ═══════════════════════════════════════════════════════════════════
416
495
  if (type === "funnel-pre") {
417
496
  if (meta && meta.firstEventTime) {
418
- const hour = dayjs(meta.firstEventTime).hour();
497
+ const hour = dayjs.unix(meta.firstEventTime).hour();
419
498
 
420
499
  record.props = record.props || {};
421
500
 
@@ -450,7 +529,7 @@ const config = {
450
529
  const userId = meta && meta.user && (meta.user.distinct_id || String(meta.user));
451
530
  const isNewUser = userId && userId.charCodeAt(0) % 2 === 0;
452
531
  if (isNewUser) {
453
- record.conversionRate = 0.90;
532
+ record.conversionRate = Math.min(98, record.conversionRate * 1.4);
454
533
  record.props.first_order_bonus = true;
455
534
  } else {
456
535
  record.props.first_order_bonus = false;
@@ -484,6 +563,9 @@ const config = {
484
563
  event: "coupon applied",
485
564
  time: midTime,
486
565
  user_id: firstEvent.user_id,
566
+ subscription_tier: firstEvent.subscription_tier,
567
+ platform: firstEvent.platform,
568
+ city: firstEvent.city,
487
569
  coupon_code: chance.pickone(couponCodes),
488
570
  discount_type: chance.pickone(["percent", "flat", "free_delivery"]),
489
571
  discount_value: chance.integer({ min: 10, max: 30 }),
@@ -535,23 +617,7 @@ const config = {
535
617
  if (EVENT_TIME.isAfter(RAINY_WEEK_START) && EVENT_TIME.isBefore(RAINY_WEEK_END)) {
536
618
  record.delivery_fee = (record.delivery_fee || 5) * 2;
537
619
  record.surge_pricing = true;
538
-
539
- // 40% chance to duplicate the event (more orders during rain)
540
- if (chance.bool({ likelihood: 40 })) {
541
- const duplicateEvent = {
542
- event: "order placed",
543
- time: EVENT_TIME.add(chance.integer({ min: 5, max: 60 }), 'minutes').toISOString(),
544
- user_id: record.user_id,
545
- order_id: chance.pickone(orderIds),
546
- payment_method: chance.pickone(["credit_card", "apple_pay", "google_pay"]),
547
- order_total: chance.integer({ min: 15, max: 120 }),
548
- tip_amount: chance.integer({ min: 0, max: 20 }),
549
- delivery_fee: chance.integer({ min: 6, max: 24 }),
550
- surge_pricing: true,
551
- rainy_week: true,
552
- };
553
- return [record, duplicateEvent];
554
- }
620
+ record.rainy_week = true;
555
621
  } else {
556
622
  record.surge_pricing = false;
557
623
  }
@@ -645,6 +711,24 @@ const config = {
645
711
  }
646
712
  }
647
713
  }
714
+
715
+ // ═══════════════════════════════════════════════════════════════
716
+ // HOOK 4: RAINY WEEK SURGE - duplicate order events (everything)
717
+ // Events tagged surge_pricing=true in the event hook get a 40%
718
+ // chance of duplication here, creating visible demand spikes.
719
+ // ═══════════════════════════════════════════════════════════════
720
+ const rainyDuplicates = [];
721
+ userEvents.forEach((event) => {
722
+ if (event.surge_pricing === true && event.event === "order placed" && chance.bool({ likelihood: 40 })) {
723
+ const dup = JSON.parse(JSON.stringify(event));
724
+ dup.time = dayjs(event.time).add(chance.integer({ min: 5, max: 60 }), 'minutes').toISOString();
725
+ dup.rainy_week = true;
726
+ rainyDuplicates.push(dup);
727
+ }
728
+ });
729
+ if (rainyDuplicates.length > 0) {
730
+ userEvents.push(...rainyDuplicates);
731
+ }
648
732
  }
649
733
 
650
734
  // ═══════════════════════════════════════════════════════════════════
@@ -668,320 +752,3 @@ const config = {
668
752
  };
669
753
 
670
754
  export default config;
671
-
672
- /**
673
- * ═══════════════════════════════════════════════════════════════════════════════
674
- * NEEDLE IN A HAYSTACK - QUICKBITE FOOD DELIVERY ANALYTICS
675
- * ═══════════════════════════════════════════════════════════════════════════════
676
- *
677
- * A food delivery app dungeon with 8 deliberately architected analytics
678
- * insights hidden in the data. This dungeon is designed to showcase advanced
679
- * product analytics patterns and demonstrate how to find "needles" (meaningful
680
- * insights) in "haystacks" (large datasets).
681
- *
682
- * ═══════════════════════════════════════════════════════════════════════════════
683
- * DATASET OVERVIEW
684
- * ═══════════════════════════════════════════════════════════════════════════════
685
- *
686
- * - 5,000 users over 100 days
687
- * - 360K events across 17 event types
688
- * - 3 funnels (onboarding, order completion, discovery to order)
689
- * - Group analytics (restaurants)
690
- * - Lookup tables (menu items, coupon codes)
691
- * - Subscription tiers (Free, QuickBite+)
692
- *
693
- * ═══════════════════════════════════════════════════════════════════════════════
694
- * THE 8 ARCHITECTED HOOKS
695
- * ═══════════════════════════════════════════════════════════════════════════════
696
- *
697
- * Each hook creates a specific, discoverable analytics insight that simulates
698
- * real-world product behavior patterns.
699
- *
700
- * ───────────────────────────────────────────────────────────────────────────────
701
- * 1. LUNCH RUSH CONVERSION (funnel-pre)
702
- * ───────────────────────────────────────────────────────────────────────────────
703
- *
704
- * PATTERN: Funnel conversion rates are boosted during meal-time hours.
705
- * Lunch (11AM-1PM) gets a 1.4x multiplier; dinner (5PM-8PM) gets 1.2x.
706
- * Events during these windows carry lunch_rush or dinner_rush properties.
707
- *
708
- * HOW TO FIND IT:
709
- * - Break down funnel conversion by hour of day
710
- * - Compare conversion rates during 11AM-1PM vs. off-peak hours
711
- * - Filter events where lunch_rush = true or dinner_rush = true
712
- *
713
- * EXPECTED INSIGHT: Lunch hour funnels convert ~40% better than baseline.
714
- * Dinner hour funnels convert ~20% better. Clear time-of-day pattern in
715
- * the checkout-to-order-to-delivery pipeline.
716
- *
717
- * REAL-WORLD ANALOGUE: Food delivery apps see massive demand spikes during
718
- * traditional meal times. Users ordering during these windows have higher
719
- * intent and thus higher conversion rates.
720
- *
721
- * ───────────────────────────────────────────────────────────────────────────────
722
- * 2. COUPON INJECTION (funnel-post)
723
- * ───────────────────────────────────────────────────────────────────────────────
724
- *
725
- * PATTERN: Free-tier users get coupon_applied events spliced into their
726
- * funnel sequences 30% of the time. These injected coupons carry the
727
- * coupon_injected: true property to distinguish them from organic usage.
728
- *
729
- * HOW TO FIND IT:
730
- * - Segment by subscription_tier = "Free"
731
- * - Look for coupon_applied events with coupon_injected = true
732
- * - Compare funnel completion rates for Free users with/without coupons
733
- *
734
- * EXPECTED INSIGHT: ~30% of Free users receive promotional coupons mid-funnel.
735
- * These users should show different downstream conversion behavior, simulating
736
- * how promotional nudges affect the purchase funnel.
737
- *
738
- * REAL-WORLD ANALOGUE: Apps frequently inject promotional offers (push
739
- * notifications, in-app banners) to non-paying users during key funnel
740
- * moments to boost conversion.
741
- *
742
- * ───────────────────────────────────────────────────────────────────────────────
743
- * 3. LATE NIGHT MUNCHIES (event)
744
- * ───────────────────────────────────────────────────────────────────────────────
745
- *
746
- * PATTERN: Between 10PM and 2AM, restaurant views and cart additions skew
747
- * 70% toward American (fast food) cuisine. Item prices are boosted by 1.3x.
748
- * Events carry late_night_order: true.
749
- *
750
- * HOW TO FIND IT:
751
- * - Break down restaurant_viewed by hour of day and cuisine_type
752
- * - Compare cuisine distribution at 10PM-2AM vs. daytime
753
- * - Filter late_night_order = true and compare average item_price
754
- *
755
- * EXPECTED INSIGHT: Late-night orders are overwhelmingly fast food with
756
- * higher average prices. The cuisine distribution at night is dramatically
757
- * different from daytime patterns.
758
- *
759
- * REAL-WORLD ANALOGUE: Late-night food delivery is dominated by fast food
760
- * and comfort food. Many platforms charge late-night surcharges or see
761
- * naturally inflated basket sizes during these hours.
762
- *
763
- * ───────────────────────────────────────────────────────────────────────────────
764
- * 4. RAINY WEEK SURGE (event)
765
- * ───────────────────────────────────────────────────────────────────────────────
766
- *
767
- * PATTERN: During days 20-27 of the dataset, a simulated rainy week causes:
768
- * - Delivery fees double on order_placed events
769
- * - surge_pricing: true flag added
770
- * - 40% chance of duplicate order events (demand surge)
771
- *
772
- * HOW TO FIND IT:
773
- * - Chart order_placed event count by day
774
- * - Filter days 20-27 and compare delivery_fee averages
775
- * - Look for surge_pricing = true and rainy_week = true properties
776
- *
777
- * EXPECTED INSIGHT: Clear spike in order volume around days 20-27, with
778
- * doubled delivery fees and surge pricing markers. The demand surge is
779
- * visible as a ~40% increase in order_placed event volume.
780
- *
781
- * REAL-WORLD ANALOGUE: Weather events drive significant demand surges for
782
- * food delivery. Platforms respond with surge pricing on delivery fees,
783
- * and order volume increases as people avoid going out.
784
- *
785
- * ───────────────────────────────────────────────────────────────────────────────
786
- * 5. REFERRAL POWER USERS (everything)
787
- * ───────────────────────────────────────────────────────────────────────────────
788
- *
789
- * PATTERN: Users whose account_created event has referral_code = true:
790
- * - Get 2x more reorder_initiated events (higher loyalty)
791
- * - Have food_rating boosted to 4-5 (higher satisfaction)
792
- * - Carry referral_user: true on affected events
793
- *
794
- * HOW TO FIND IT:
795
- * - Segment users by: referral_code = true on account_created
796
- * - Compare: reorder_initiated event count per user
797
- * - Compare: average food_rating on order_rated events
798
- *
799
- * EXPECTED INSIGHT: Referred users reorder roughly 2x more often and rate
800
- * food 4-5 stars consistently. They represent a higher-LTV, more-satisfied
801
- * segment of the user base.
802
- *
803
- * REAL-WORLD ANALOGUE: Referral programs consistently produce higher-quality
804
- * users. Referred customers have lower acquisition costs, higher retention,
805
- * and higher satisfaction because they come with built-in social proof.
806
- *
807
- * ───────────────────────────────────────────────────────────────────────────────
808
- * 6. TRIAL CONVERSION (everything)
809
- * ───────────────────────────────────────────────────────────────────────────────
810
- *
811
- * PATTERN: Users with subscription_started where trial = true are evaluated:
812
- * - If they place 3+ orders in their first 14 days: retained (all events kept)
813
- * - If fewer than 3 orders: churned (60% of events after day 14 removed)
814
- * - Retained users carry trial_retained: true
815
- *
816
- * HOW TO FIND IT:
817
- * - Segment users by: subscription_started with trial = true
818
- * - Count order_placed events within first 14 days per user
819
- * - Compare: event volume after day 14 for 3+ orders vs. <3 orders
820
- * - Look for trial_retained = true property
821
- *
822
- * EXPECTED INSIGHT: Trial users who place 3+ early orders show sustained
823
- * engagement. Those who don't show a dramatic drop-off after day 14, with
824
- * 60% fewer events. The "magic number" for trial conversion is 3 orders.
825
- *
826
- * REAL-WORLD ANALOGUE: Subscription services often find a "magic number"
827
- * of early actions that predict long-term retention. For food delivery,
828
- * this is typically a threshold of orders during the trial period.
829
- *
830
- * ───────────────────────────────────────────────────────────────────────────────
831
- * 7. SUPPORT TICKET CHURN (user)
832
- * ───────────────────────────────────────────────────────────────────────────────
833
- *
834
- * PATTERN: 15% of users are flagged as is_high_risk = true with a
835
- * churn_risk_score between 70-100. The remaining 85% get scores of 0-40.
836
- * This creates a binary segmentation opportunity for retention teams.
837
- *
838
- * HOW TO FIND IT:
839
- * - Segment users by: is_high_risk = true
840
- * - Compare: churn_risk_score distribution
841
- * - Cross-reference: support_ticket event frequency for high-risk users
842
- * - Compare: retention and ordering behavior by risk segment
843
- *
844
- * EXPECTED INSIGHT: 15% of users have churn scores above 70, creating a
845
- * clear at-risk segment. These users likely correlate with higher support
846
- * ticket rates and lower order frequency.
847
- *
848
- * REAL-WORLD ANALOGUE: Customer health scoring is used by subscription
849
- * businesses to identify at-risk users for proactive retention outreach.
850
- * ML models in production generate similar risk scores from behavioral data.
851
- *
852
- * ───────────────────────────────────────────────────────────────────────────────
853
- * 8. FIRST ORDER BONUS (funnel-pre)
854
- * ───────────────────────────────────────────────────────────────────────────────
855
- *
856
- * PATTERN: For the Order Completion funnel (checkout started -> order placed
857
- * -> order delivered), new users (born in dataset) get their conversion rate
858
- * boosted to 90%. Events carry first_order_bonus: true.
859
- *
860
- * HOW TO FIND IT:
861
- * - Segment the Order Completion funnel by new vs. existing users
862
- * - Compare: conversion rates for new users vs. returning users
863
- * - Filter: first_order_bonus = true
864
- *
865
- * EXPECTED INSIGHT: New users convert at ~90% through the order funnel,
866
- * dramatically higher than the 60% baseline. This simulates first-order
867
- * promotions (free delivery, $10 off) that most food delivery apps offer.
868
- *
869
- * REAL-WORLD ANALOGUE: Every major food delivery app offers aggressive
870
- * first-order incentives. These dramatically boost initial conversion but
871
- * the real question is whether those users return (see Hook #6).
872
- *
873
- * ═══════════════════════════════════════════════════════════════════════════════
874
- * ADVANCED ANALYSIS IDEAS
875
- * ═══════════════════════════════════════════════════════════════════════════════
876
- *
877
- * CROSS-HOOK PATTERNS:
878
- *
879
- * 1. The Perfect Customer: Users who:
880
- * - Signed up via referral (Hook #5)
881
- * - Started a trial and placed 3+ early orders (Hook #6)
882
- * - Order during lunch rush (Hook #1)
883
- * - Have low churn risk score (Hook #7)
884
- * These users should have exceptional LTV and retention metrics.
885
- *
886
- * 2. Rainy Night Double Whammy: Do late-night orders during rainy week
887
- * (Hook #3 + Hook #4) show compounded surge pricing effects?
888
- *
889
- * 3. Coupon-Driven Trial Conversion: Do free users who receive injected
890
- * coupons (Hook #2) eventually start trials (Hook #6)?
891
- *
892
- * 4. Referral + First Order: Referred users (Hook #5) who also get the
893
- * first order bonus (Hook #8) should have the highest conversion rates.
894
- *
895
- * 5. Support Tickets and Churn Risk: Do high-risk users (Hook #7) file
896
- * more support tickets, and does this correlate with rainy week
897
- * late deliveries (Hook #4)?
898
- *
899
- * COHORT ANALYSIS:
900
- *
901
- * - Cohort by signup week: Users who started during rainy week (days 20-27)
902
- * should show different ordering patterns
903
- * - Cohort by referral source: Referred vs. organic user lifecycle comparison
904
- * - Cohort by subscription tier: Free vs. QuickBite+ across all metrics
905
- * - Cohort by city: Do different cities show different cuisine preferences
906
- * and ordering patterns?
907
- *
908
- * FUNNEL ANALYSIS:
909
- *
910
- * - Onboarding Funnel: How quickly do users go from account creation to
911
- * first restaurant view? Break down by signup method.
912
- * - Order Funnel: Compare checkout-to-delivery completion by platform,
913
- * subscription tier, and time of day.
914
- * - Discovery Funnel: How does search type (restaurant vs. cuisine vs. dish)
915
- * affect downstream conversion to ordering?
916
- *
917
- * ═══════════════════════════════════════════════════════════════════════════════
918
- * EXPECTED METRICS SUMMARY
919
- * ═══════════════════════════════════════════════════════════════════════════════
920
- *
921
- * Hook | Metric | Baseline | Hook Effect | Ratio
922
- * ──────────────────────|──────────────────────|──────────|─────────────|──────
923
- * Lunch Rush | Funnel conversion | 60% | 84% | 1.4x
924
- * Coupon Injection | Free user coupons | 0% | 30% | N/A
925
- * Late Night Munchies | American cuisine % | ~15% | 70% | ~4.7x
926
- * Rainy Week Surge | Order volume | 100% | 140% | 1.4x
927
- * Referral Power Users | Reorder frequency | 1x | 2x | 2.0x
928
- * Trial Conversion | Post-trial retention | 100% | 40% | 0.4x
929
- * Support Ticket Churn | High-risk users | 0% | 15% | N/A
930
- * First Order Bonus | New user conversion | 60% | 90% | 1.5x
931
- *
932
- * ═══════════════════════════════════════════════════════════════════════════════
933
- * HOW TO RUN THIS DUNGEON
934
- * ═══════════════════════════════════════════════════════════════════════════════
935
- *
936
- * From the dm4 root directory:
937
- *
938
- * npm start
939
- *
940
- * Or programmatically:
941
- *
942
- * import generate from './index.js';
943
- * import config from './dungeons/harness-food.js';
944
- * const results = await generate(config);
945
- *
946
- * OUTPUT FILES (with writeToDisk: false, format: "json", gzip: true):
947
- *
948
- * - needle-haystack-food__events.json.gz - All event data
949
- * - needle-haystack-food__user_profiles.json.gz - User profiles
950
- * - needle-haystack-food__group_profiles.json.gz - Restaurant profiles
951
- * - needle-haystack-food__item_id_lookup.json.gz - Menu item catalog
952
- * - needle-haystack-food__coupon_code_lookup.json.gz - Coupon catalog
953
- *
954
- * ═══════════════════════════════════════════════════════════════════════════════
955
- * TESTING YOUR ANALYTICS PLATFORM
956
- * ═══════════════════════════════════════════════════════════════════════════════
957
- *
958
- * This dungeon is perfect for testing:
959
- *
960
- * 1. Time-of-Day Analysis: Can you detect the lunch and dinner rush patterns?
961
- * 2. Promotional Impact: Can you measure the effect of injected coupons?
962
- * 3. Behavioral Shifts: Can you discover the late-night cuisine preferences?
963
- * 4. Anomaly Detection: Can you spot the rainy week demand surge?
964
- * 5. Referral Analysis: Can you quantify the referral user advantage?
965
- * 6. Trial Optimization: Can you find the "magic number" of early orders?
966
- * 7. Churn Prediction: Can you identify high-risk users before they leave?
967
- * 8. New User Funnels: Can you measure the first-order bonus impact?
968
- *
969
- * ═══════════════════════════════════════════════════════════════════════════════
970
- * WHY "NEEDLE IN A HAYSTACK"?
971
- * ═══════════════════════════════════════════════════════════════════════════════
972
- *
973
- * Each hook is a "needle" - a meaningful, actionable insight hidden in a
974
- * "haystack" of 360K events. The challenge is:
975
- *
976
- * 1. FINDING the needles (discovery)
977
- * 2. VALIDATING they're real patterns (statistical significance)
978
- * 3. UNDERSTANDING why they matter (business impact)
979
- * 4. ACTING on them (product decisions)
980
- *
981
- * This mirrors real-world product analytics: your data contains valuable insights,
982
- * but you need the right tools and skills to find them.
983
- *
984
- * Happy Hunting!
985
- *
986
- * ═══════════════════════════════════════════════════════════════════════════════
987
- */