feat(analytics): track mobile-web signup as Meta Pixel Lead#2710
Conversation
Introduces analytics.trackMeta() typed to the Meta Pixel standard event union so compile-time rejects custom names. Migrates MobileWebSignupSent to use it, firing Lead with content_name for mobile-web signup surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 14 minutes and 45 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR introduces Meta Pixel standard event support to the analytics system by adding a typed list of standard event names and a new Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@js/app/packages/app/lib/analytics/analytics.ts`:
- Around line 151-156: META_STANDARD_EVENTS.has(event) is case-sensitive so
callers using wrong casing (e.g. 'lead' vs 'Lead') get routed to trackCustom;
fix by doing a case-insensitive lookup and using the canonical-cased event when
available. Create a map from META_STANDARD_EVENTS entries lowercased to their
canonical form (e.g. LOWER_TO_CANONICAL), then replace the check with a lookup:
const canonical = LOWER_TO_CANONICAL.get(event.toLowerCase()); if canonical is
present use fbq('track', canonical, enriched) else use fbq('trackCustom', event,
enriched); also add a short code comment referencing META_STANDARD_EVENTS and
trackMeta to explain why we normalize.
- Around line 74-97: Replace the parallel array+set pair by a single canonical
Set to avoid duplication: remove META_STANDARD_EVENT_NAMES and create one const
META_STANDARD_EVENTS initialized with the string literals (as const) so you can
still derive MetaStandardEvent from it (use a type derived from the set's
values), and update any call sites that check membership (e.g. .has(event)) to
cast the checked value to MetaStandardEvent where necessary (or keep `.has`
typed as Set<string> if preferred). Ensure you update references to
META_STANDARD_EVENT_NAMES to use META_STANDARD_EVENTS and adjust the
MetaStandardEvent type to read from the new constant.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: fc8361e5-da5d-49e3-8344-50d4b40ae8dc
📒 Files selected for processing (2)
js/app/packages/app/component/interactive-onboarding/MobileWebSignupSent.tsxjs/app/packages/app/lib/analytics/analytics.ts
Summary
Wire up Meta Pixel conversion tracking for the signup funnel — both the mobile-web lead-capture step and the final onboarding launch step — and add a typed API that keeps future Meta standard event calls correct by default.
MobileWebSignupSentfires Meta's standardLeadevent on mount alongside the existing PostHogmobile_web_signup_sent_viewedevent. Carriescontent_name: 'mobile_web_signup'so it can be split from futureLeadsurfaces via a Custom Conversion.launch.tsx(final onboarding step, mobile-only) firesCompleteRegistrationon mount withcontent_name: 'onboarding_launch'andcontent_category: <tier>.tieris read from the?type=URL param set by Stripe's success redirect (seechoose-plan.tsx), defaulting to'free'for users who skipped Stripe. Possible values:free | haiku | sonnet | opus.analytics.trackMeta(event, data?)— new typed method on the analytics interface.eventis constrained to theMetaStandardEventunion (Lead, Purchase, CompleteRegistration, etc.), so custom names and typos fail at compile time. Prefer this overtrack(..., ['meta-pixel'])for standard events — Meta's optimization models are pre-trained on the standard taxonomy, standard events get priority slots in iOS 14.5+ Aggregated Event Measurement, and Ads Manager surfaces them natively.track(..., ['meta-pixel'])path now routes non-standard event names throughfbq('trackCustom', ...)instead offbq('track', ...), eliminating Pixel Helper warnings for existing callers (e.g.sign_up).Meta Ads Manager follow-up
Create Custom Conversions in Events Manager:
Leadwherecontent_name equals mobile_web_signupCompleteRegistrationCompleteRegistrationwherecontent_category != freeCompleteRegistrationwherecontent_category = haiku | sonnet | opusThen point the relevant ad sets at each conversion.