fix(analytics): report account_created from the client - #3532
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (20)
🚧 Files skipped from review as they are similar to previous changes (16)
📝 WalkthroughWalkthroughChangesAccount creation analytics
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
780432c to
a37014f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3532 +/- ##
==========================================
- Coverage 74.29% 73.37% -0.93%
==========================================
Files 1148 1060 -88
Lines 29827 27510 -2317
Branches 7459 7013 -446
==========================================
- Hits 22161 20186 -1975
+ Misses 6766 6454 -312
+ Partials 900 870 -30
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/deploy-web/src/components/onboarding-picker/OnboardingPickerPage.spec.tsx`:
- Around line 346-362: Update the deploy-handler tests in
OnboardingPickerPage.spec.tsx to capture the navigation mock and assert that
analyticsService.flush was invoked before push or link navigation. Use async act
and await the handler when flushing is asynchronous, covering both the
deployment card and custom-image link flows.
In `@apps/deploy-web/src/services/analytics/analytics.service.ts`:
- Line 151: Update the Amplitude type and AnalyticsService.flush()
implementation to preserve and return Amplitude’s awaitable flush result instead
of discarding it. Then await AnalyticsService.flush() in the onboarding and
account-created flow call sites so navigation occurs only after the event send
completes.
🪄 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: CHILL
Plan: Pro
Run ID: 13047afe-e5a2-4b52-975f-a470fc86c2bb
📒 Files selected for processing (20)
apps/api/src/core/services/analytics/analytics.service.tsapps/api/src/user/controllers/user/user.controller.tsapps/api/src/user/routes/register-user/register-user.router.tsapps/api/src/user/services/user/user.service.spec.tsapps/api/src/user/services/user/user.service.tsapps/api/swagger/openapi.jsonapps/deploy-web/src/components/analytics/AccountCreatedTracker/AccountCreatedTracker.spec.tsxapps/deploy-web/src/components/analytics/AccountCreatedTracker/AccountCreatedTracker.tsxapps/deploy-web/src/components/onboarding-picker/OnboardingPickerPage.spec.tsxapps/deploy-web/src/components/onboarding-picker/OnboardingPickerPage.tsxapps/deploy-web/src/lib/analytics/account-created-cookie.spec.tsapps/deploy-web/src/lib/analytics/account-created-cookie.tsapps/deploy-web/src/lib/nextjs/api-routes-specs/auth-email-code-verify.spec.tsapps/deploy-web/src/pages/_app.tsxapps/deploy-web/src/pages/api/auth/[...auth0].tsapps/deploy-web/src/pages/api/auth/email-code-verify.tsapps/deploy-web/src/services/analytics/analytics.service.spec.tsapps/deploy-web/src/services/analytics/analytics.service.tsapps/deploy-web/src/services/session/session.service.spec.tsapps/deploy-web/src/services/session/session.service.ts
a37014f to
ce99180
Compare
account_created was emitted server-side on user registration while every other funnel event fires from the browser, so they never shared a clock, device id, or session. In Amplitude that skew showed up as out-of-order events and inflated drop-off at the first funnel step. Move it to the client: register-user now returns isNewUser, the OAuth and passwordless auth callbacks hand that signal to the browser via a one-shot cookie, and a mounted tracker fires account_created once in the user's own session context. The server-side emission is removed. Also flush high-value click events (the onboarding deploy CTA) immediately instead of leaving them in the Amplitude batch queue, where a fast page transition could drop them.
ce99180 to
19cba3c
Compare
Why
account_createdwas the only onboarding-funnel event emitted from the backend (on user registration), whiletrial_started,onboarding_deploy_click, and the rest fire from the browser. Because the two sources never shared a clock, device id, or session, Amplitude stitched them together inconsistently — events showed up out of order and the very first funnel step (account_created → trial_started) reported inflated drop-off even though nothing was actually dropping off there.What
account_createdfrom the client.POST /v1/register-usernow returnsisNewUser(from the repository'swasInserted); the server-side emission is removed, so the event has a single source.[...auth0]) and passwordless (email-code-verify) auth callbacks set a short-lived, one-shot cookie whenisNewUseris true.AccountCreatedTrackerconsumes the cookie — on mount for full-reload landings (OAuth) and onrouteChangeCompletefor client-side ones (passwordless) — emitsaccount_createdwith the browser's device id/session, and clears the cookie.The
register-userresponse change is additive (a newisNewUserfield), so it's backward-compatible — no breaking production contract.Out of scope:
onboarding_account_created(a separate onboarding-flow event) and the password-signup path (not an active signup method) are left untouched.Summary by CodeRabbit
isNewUserboolean.