← Planning Hub

Performance & Testing

Tracking page-load and flow-completion performance, plus an ongoing testing roadmap. Started from the 2026-05-11 finding that a new user's first login took ~50–60 seconds end-to-end.

Observed problem (2026-05-11)

Test user completed the public sign-up form (steps 1→3), clicked "Log In & View Checklist," entered phone + verification code:

  • Delay 1: ~20–30s between clicking Verify & Sign In and seeing the Profile Completion form. Button stuck on "Please wait…".
  • Delay 2: ~20–30s between clicking Complete Profile and arriving at the Checklist page. Same silent wait.

Root cause — Delay 1

onAuthStateChanged ran a 4-way decision tree with up to 7 sequential Firestore round-trips while the user waited:

  • 1× getDoc(users/<uid>) (Check A)
  • 4× sequential getDocs in findExistingProfile() — 3 phone-format variants + 1 email
  • 2× sequential getDocs in findInvite() — phone then email

On a mobile network with 500–2000ms per round-trip, this adds up.

Root cause — Delay 2

The Profile Completion handler did 8+ sequential awaits:

  • 1× getDoc (read invite)
  • 1× updateProfile (Firebase Auth displayName)
  • 1× setDoc(users/<uid>)
  • 1× updateDoc(invites/<id>) (mark accepted)
  • 1× addDoc(family_members) (self record)
  • N× addDoc(family_members) per trailman
  • M× addDoc(family_members) per other family member
  • M'× setDoc(invites/...) for downstream family invites

For a typical "1 trailman + 1 spouse with email" signup, that's ~8 sequential network calls before navigation. Plus the new page (/dashboard/checklist.html) does its own auth + Firestore queries on first load.

Fixes shipped 2026-05-11

✓
Parallelize Profile Completion writes (Delay 2 fix)
All essential Firestore writes (users doc, invite accept, family_members self + trailmen + other family) now batch into a single Promise.all. The updateProfile call for the Firebase Auth displayName joins the same batch. Drops 8+ sequential round-trips to one round-trip window.
File: login.js (profile-completion submit handler).
✓
Fire-and-forget downstream invites (Delay 2 fix)
Downstream invites for additional family members (with email) are no longer awaited before navigation. They fire in the background; if they fail, admin can re-invite from the Invites page. The user reaches the checklist immediately rather than waiting for these final writes.
File: login.js (profile-completion submit handler, end of signupData block).
✓
Parallelize decision-tree lookups (Delay 1 fix)
findExistingProfile() and findInvite() now run all candidate queries via Promise.all instead of sequentially. For a brand-new user where every lookup returns empty, this drops 6 round-trips to 1.
File: login.js.

Future improvements

1
Progress messaging during long waits
Even after the perf fixes, a slow mobile connection could push the wait to several seconds. Show "Setting up your account…" → "Creating your family records…" → "Almost there…" instead of a static "Please wait…" button so users don't think it's broken. Same treatment for Delay 1 (between Verify and Profile Completion).
2
Cloud Function warm-up trigger
sendFamilyWelcomeSms, sendInviteSms, and signupNotify all suffer cold-start penalties (5–15s) when idle. A scheduled "ping every 5 min during business hours" trigger keeps them warm. Or use onSchedule('every 5 minutes') with a tiny no-op invocation per function.
3
Background SMS queue
Instead of fetching the SMS Cloud Function directly from client code, write to a sms_queue Firestore collection that triggers a Cloud Function via Firestore-trigger. Client returns immediately; sending happens in the background. Same pattern for any other slow Cloud Function calls. Cleaner than ad-hoc fire-and-forget.
4
Server-side single-trip signup completion
Move the entire Profile Completion logic into a Cloud Function (completeProfile). Client makes one call with the form data; server does all the Firestore writes in a batch + creates downstream invites + fires SMS. Cleaner error handling + one network round-trip from the user's perspective.
5
Optimize Firestore indexes
Audit the queries used during sign-in (especially the 3 phone-format variants). Consider normalizing phone numbers at write time so we never have to query for multiple formats. Then drop the redundant queries from findExistingProfile.
6
Single-format phone storage
Right now findExistingProfile checks 3 phone formats because legacy data may have +1-prefixed or E.164 stored values. A one-off cleanup tool ("Normalize Phone Numbers" — already exists in admin-tools) should make this unnecessary. After running it, drop the +1 / E.164 checks and keep only the 10-digit lookup.
7
Dashboard checklist preloading
When the Profile Completion handler navigates to /dashboard/checklist.html, that page does its own auth check + family_members query. The browser could pre-warm the connection or pre-fetch the page during the Promise.all wait so the navigation feels instant. Service-worker territory; low priority.

Testing roadmap

Each fix needs a before/after measurement. Use the same test-account flow each time so numbers are comparable.

A
Establish baseline (post-2026-05-11 fixes)
Sign up a fresh test user via the public form (1 trailman + 1 spouse-with-email). Measure: (a) Verify→Profile Completion latency, (b) Complete Profile→Checklist latency. Repeat 3× and record. Target after the fixes: ≤5s for each transition on a typical mobile connection.
B
Test on throttled connection
Chrome DevTools → Network → "Slow 4G" preset. Re-run baseline. Measures whether the parallelization holds up under realistic mobile conditions, not just office Wi-Fi.
C
Test large family
Sign up a test user with 4 trailmen + 2 spouses + 2 grandparents. Verify the parallel batch still completes in <10s. Confirm all family_members records arrive correctly. Confirm downstream invites land for any family member with email.
D
Test cold-start scenario
Wait 30+ minutes between tests so Cloud Functions go cold. Then sign up + log in. Confirm the fire-and-forget downstream invites don't block the user even though Cloud Functions are cold.
E
Verify Path 4 (admin Convert) hasn't regressed
The admin Convert flow also creates family_members records but through invite-actions.js, not login.js. Confirm it's still sequential there (or apply the same parallelization later). Time the click→done transition.
F
Browser console error check
After every test sign-up, open DevTools console. Confirm no errors from the fire-and-forget downstream invite writes. If any pop up, admin needs to re-invite those family members manually.

Performance targets

What "good" looks like for the most user-facing flows:

FlowTargetAcceptableInvestigate if >
Verify code → Profile Completion shown≤2s≤5s10s
Complete Profile → Checklist loaded≤3s≤6s12s
Dashboard initial load (logged in)≤1.5s≤3s6s
Pay Dues click → Stripe Checkout open≤2s≤4s8s
Admin Convert click → completion≤2s≤5s10s
People page load (100+ records)≤2s≤4s8s

Captured 2026-05-11 in response to a real user-flow latency issue.