Skip to content

feat: Integrate analytics tracking into user onboarding flow#696

Merged
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
dedukpe:feat/user-onboarding-analytics-integration
Jun 26, 2026
Merged

feat: Integrate analytics tracking into user onboarding flow#696
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
dedukpe:feat/user-onboarding-analytics-integration

Conversation

@dedukpe

@dedukpe dedukpe commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

##Closes #381

Summary

This PR integrates comprehensive analytics tracking into the user onboarding flow to track funnel completion rates and identify user drop-off points.

Changes Made

Analytics Events

  • New Event Types: Added four new event types to the analytics system:
    • onboarding_started: Fired when user initiates the onboarding process
    • onboarding_step_completed: Fired when user completes each step
    • onboarding_completed: Fired when user successfully completes onboarding
    • onboarding_abandoned: Fired when user leaves without completing

Component Updates

src/utils/analytics.ts

  • Added onboarding event types to the EventName union type
  • Implemented clearAdapters() method for test purposes to reset to default console adapter
  • All events include contextual metadata for analytics analysis

src/app/onboarding/page.tsx

  • Integrated useAnalytics hook with onboarding feature context
  • Added safeTrack() wrapper function with error handling to prevent analytics failures from blocking onboarding
  • Track onboarding_started on component mount
  • Track onboarding_step_completed when users advance through steps
  • Track onboarding_completed with metadata (role, walletConnected)
  • Track onboarding_abandoned when users navigate away (beforeunload event)
  • Added state management for tracking completion status

src/components/forms/FormWizardController.tsx

  • Added onStepComplete optional callback prop
  • Call callback after step validation and form completion
  • Mark fields as touched during validation

Testing Updates

src/app/onboarding/__tests__/onboarding.test.tsx

  • Mocked useAnalytics hook for testing
  • Added comprehensive test coverage for analytics event tracking
  • Fixed timer handling issues by using real timers for animation-heavy tests
  • Added test for analytics failure resilience (events thrown but onboarding continues)
  • All 7 tests passing ✅

Technical Details

  • Error Handling: Analytics failures are caught and logged but don't interrupt the onboarding flow
  • Performance: Event tracking is non-blocking and won't impact user experience
  • Testing: Comprehensive test suite ensures analytics events fire correctly without blocking functionality
  • Metadata: Each event includes step and completion context for detailed funnel analysis

Test Results

✓ src/app/onboarding/__tests__/onboarding.test.tsx (7 tests) 6356ms
  ✓ Onboarding Page > renders Step 1 successfully
  ✓ Onboarding Page > shows error messages when required fields are missing
  ✓ Onboarding Page > navigates to Step 2 when fields are valid
  ✓ Onboarding Page > navigates to Step 3 and displays wallet options
  ✓ Onboarding Page > simulates Starknet Argent X wallet connection in Step 3
  ✓ Onboarding Page > completes onboarding and triggers redirection to dashboard
  ✓ Onboarding Page > tracks onboarding lifecycle events and continues when analytics fails

Impact

This enables analytics teams to:

  • Track user onboarding completion rates
  • Identify drop-off points in the onboarding funnel
  • Measure the impact of onboarding changes
  • Monitor abandonment patterns
  • Understand user journey through the onboarding process

- Added new analytics event types for onboarding lifecycle tracking:
  - onboarding_started: Track when user initiates onboarding
  - onboarding_step_completed: Track completion of each step
  - onboarding_completed: Track successful onboarding completion
  - onboarding_abandoned: Track when user leaves without completing

- Integrated useAnalytics hook into OnboardingPage component
- Added safe event tracking with error handling to prevent analytics failures from blocking onboarding
- Added onStepChange and onStepComplete callbacks to FormWizardController
- Track step details (id, index, title) and completion metadata
- Added comprehensive test coverage for analytics event tracking
- Verified all 7 onboarding tests pass with proper timer handling

This enables analytics teams to track user onboarding funnel completion rates and identify drop-off points.
@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@dedukpe Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

RUKAYAT-CODER commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Great job so far

There’s just one blocker — the workflow is failing. Could you take a look and fix it so all checks pass?

Happy to review again once that’s done.
You can pull from the main first before pushing. The workflow should pass

@dedukpe

dedukpe commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Done Ma

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER RUKAYAT-CODER merged commit e245b01 into rinafcode:main Jun 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

performance User Onboarding : Analytics Integration

2 participants