Skip to content

feat: add Vercel Analytics integration#76

Merged
ECWireless merged 3 commits into
mainfrom
feat/add-vercel-analytics
May 28, 2026
Merged

feat: add Vercel Analytics integration#76
ECWireless merged 3 commits into
mainfrom
feat/add-vercel-analytics

Conversation

@ECWireless
Copy link
Copy Markdown
Member

@ECWireless ECWireless commented May 28, 2026

This pull request introduces comprehensive integration with Vercel Analytics for both client-side and server-side event tracking. The main focus is on improving analytics for user interactions with the "Hire Us" and "Join Us" forms, as well as backend consultation submissions. It adds new utility modules for analytics events and tracking, and ensures that important user actions and errors are consistently reported for better observability.

Analytics Integration

  • Added @vercel/analytics as a dependency in package.json to support Vercel Analytics tracking.
  • Introduced src/lib/analytics.ts for client-side analytics event definitions and tracking, and src/lib/server-analytics.ts for server-side event tracking. [1] [2]
  • Added a reusable VercelAnalytics component that sets up page analytics and tracks [data-click] CTA clicks.
  • Integrated the VercelAnalytics component into the main layout (src/app/layout.tsx). [1] [2]

"Hire Us" Form Analytics

  • Tracked form view with IntersectionObserver, step completion, submission attempts, successes, and various error cases (validation, server, network) using the new analytics utilities in src/components/HireUs.tsx. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
  • Ensured existing Fathom tracking remains alongside the new Vercel Analytics events.

"Join Us" Form Analytics

  • Added analytics tracking for signup attempts, successes, and error cases (server, network) in src/components/JoinUs.tsx. [1] [2] [3]

Backend Consultation API Analytics

  • Instrumented the consultation API (src/app/api/consultations/route.ts) to track successful submissions and different failure reasons (validation, notification, exception) using server-side analytics events. [1] [2] [3] [4] [5]

These changes provide much richer analytics for key user flows, enabling better monitoring and future optimization of the forms and consultation process.

Summary by CodeRabbit

  • New Features
    • Added analytics tracking to monitor user interactions and form submissions across the platform, including form views, submission attempts, and engagement metrics.

Review Change Stack

Copilot AI review requested due to automatic review settings May 28, 2026 12:12
@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
website Ready Ready Preview, Comment May 28, 2026 12:33pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Warning

Review limit reached

@ECWireless, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 59 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d888e9f0-e3c4-4274-9101-b2bee606c4da

📥 Commits

Reviewing files that changed from the base of the PR and between ba156b7 and 8b57f8a.

📒 Files selected for processing (3)
  • src/app/api/consultations/route.ts
  • src/components/HireUs.tsx
  • src/lib/server-analytics.ts
📝 Walkthrough

Walkthrough

This PR integrates Vercel Analytics across the site by adding a dependency, creating client and server tracking libraries, wiring a VercelAnalytics component into the root layout, and instrumenting the consultation API endpoint and signup forms to capture user events and submission outcomes.

Changes

Vercel Analytics Integration

Layer / File(s) Summary
Analytics libraries and dependency
package.json, src/lib/analytics.ts, src/lib/server-analytics.ts
@vercel/analytics dependency added. Client module exports trackAnalyticsEvent with typed properties. Server module exports trackServerAnalyticsEvent with optional request headers.
VercelAnalytics component and root layout wiring
src/components/VercelAnalytics.tsx, src/app/layout.tsx
VercelAnalytics component renders Vercel's Analytics with URL redaction and document click tracking, integrated into RootLayout body.
Consultation API endpoint tracking
src/app/api/consultations/route.ts
POST handler emits consultationSubmitted and consultationSubmitFailed events for validation, notification, and exception paths.
HireUs wizard form tracking
src/components/HireUs.tsx
IntersectionObserver tracks form views; step validation, submission attempts, and results emit analytics with error classification (validation, server, network).
JoinUs form tracking
src/components/JoinUs.tsx
Form submission emits attempt (with referral status) and success/error analytics with reason classification.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • raid-guild/website#51: Both PRs instrument HireUs and JoinUs components with analytics event tracking around form submissions and step events.
  • raid-guild/website#19: Both PRs render an analytics component in the root layout body (this PR adds VercelAnalytics).

Poem

🐰 Tracks now flow from form to page,
Events logged for each new stage,
Views and clicks and submissions bright,
Analytics shining in the night! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add Vercel Analytics integration' directly and clearly summarizes the main change: adding Vercel Analytics across the application for client-side and server-side event tracking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-vercel-analytics

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Vercel Analytics to the Next.js site, instrumenting key user flows (“Hire Us”, “Join Us”, and the consultations API) for richer client- and server-side event tracking alongside existing Fathom tracking.

Changes:

  • Added client and server analytics helper modules (src/lib/analytics.ts, src/lib/server-analytics.ts) and a <VercelAnalytics /> component to initialize Vercel Analytics + track [data-click] CTAs.
  • Instrumented “Hire Us” and “Join Us” forms with analytics events for attempts, successes, and error cases.
  • Instrumented the consultations API route to emit success/failure analytics events; added @vercel/analytics dependency and lockfile updates.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/lib/server-analytics.ts Adds server-side tracking wrapper for Vercel Analytics events.
src/lib/analytics.ts Adds client-side event definitions and a tracking helper.
src/components/VercelAnalytics.tsx Initializes Vercel Analytics and tracks CTA clicks; redacts URL query/hash in beforeSend.
src/components/JoinUs.tsx Emits analytics events for signup attempt/success/error.
src/components/HireUs.tsx Emits analytics events for form view, step completion, submit attempt/success/error.
src/app/layout.tsx Mounts the Vercel Analytics component in the root layout.
src/app/api/consultations/route.ts Adds server-side analytics events for consultation submission success/failure reasons.
package.json Adds @vercel/analytics dependency.
bun.lock Lockfile update to include @vercel/analytics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/server-analytics.ts
Comment thread src/app/api/consultations/route.ts Outdated
Comment thread src/app/api/consultations/route.ts Outdated
Comment thread src/app/api/consultations/route.ts Outdated
Comment thread src/app/api/consultations/route.ts Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/HireUs.tsx (1)

480-488: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix error-reason classification for non-400 responses with details.

Line 480 currently treats any details array as validation, but your consultation API can return details on HTTP 500 too (notification failures). That mislabels server failures as server_validation and skews analytics.

Use HTTP status (or explicit error code) to classify validation, e.g. only response.status === 400 as validation.

Suggested fix
-        if (result.details && Array.isArray(result.details)) {
+        if (response.status === 400 && result.details && Array.isArray(result.details)) {
           console.error("Validation errors:", result.details);
           setValidationErrors(result.details);
           setErrorMessage("Please fix the validation errors below.");
           trackAnalyticsEvent(analyticsEvents.hireFormSubmitError, {
             reason: "server_validation",
             step: "submit",
           });
         } else {
           setErrorMessage(
             result.error || "Failed to submit consultation. Please try again."
           );
           trackAnalyticsEvent(analyticsEvents.hireFormSubmitError, {
             reason: "server_error",
             step: "submit",
           });
         }
🤖 Prompt for 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.

In `@src/components/HireUs.tsx` around lines 480 - 488, The code currently treats
any result.details array as validation errors; change the branching in the
submission handling so you only classify as validation when the HTTP status
indicates a 400 (or an explicit validation error code) instead of presence of
result.details alone: inspect the response status (e.g., response.status or
result.statusCode) and only call setValidationErrors(result.details),
setErrorMessage("Please fix the validation errors below."), and
trackAnalyticsEvent(analyticsEvents.hireFormSubmitError, { reason:
"server_validation", step: "submit" }) when status === 400; for other statuses
with result.details (e.g., 500), log them and classify the analytics reason as a
server error (e.g., reason: "server_failure") while preserving existing error
handling flow.
🤖 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 `@src/app/api/consultations/route.ts`:
- Around line 222-229: The telemetry calls (trackServerAnalyticsEvent) are
currently awaited and block API responses; change them to fire-and-forget
background calls instead (e.g., call trackServerAnalyticsEvent without awaiting
and attach a .catch to handle/log failures) for every occurrence including the
instances that reference serverAnalyticsEvents.consultationSubmitFailed and the
other events noted; this keeps the API response path non-blocking while still
capturing errors from the analytics call.

---

Outside diff comments:
In `@src/components/HireUs.tsx`:
- Around line 480-488: The code currently treats any result.details array as
validation errors; change the branching in the submission handling so you only
classify as validation when the HTTP status indicates a 400 (or an explicit
validation error code) instead of presence of result.details alone: inspect the
response status (e.g., response.status or result.statusCode) and only call
setValidationErrors(result.details), setErrorMessage("Please fix the validation
errors below."), and trackAnalyticsEvent(analyticsEvents.hireFormSubmitError, {
reason: "server_validation", step: "submit" }) when status === 400; for other
statuses with result.details (e.g., 500), log them and classify the analytics
reason as a server error (e.g., reason: "server_failure") while preserving
existing error handling flow.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2a876151-481b-493e-a38f-c47b7e0a21aa

📥 Commits

Reviewing files that changed from the base of the PR and between c4982e8 and ba156b7.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • package.json
  • src/app/api/consultations/route.ts
  • src/app/layout.tsx
  • src/components/HireUs.tsx
  • src/components/JoinUs.tsx
  • src/components/VercelAnalytics.tsx
  • src/lib/analytics.ts
  • src/lib/server-analytics.ts

Comment thread src/app/api/consultations/route.ts Outdated
@ECWireless
Copy link
Copy Markdown
Member Author

Addressed the remaining CodeRabbit outside-diff item in 8b57f8a: hire-us submission errors now classify validation only on HTTP 400, so 500 responses with details are treated as server errors. Verified with bun run lint and bun run build.

@ECWireless ECWireless merged commit 477d3e8 into main May 28, 2026
3 checks passed
@ECWireless ECWireless deleted the feat/add-vercel-analytics branch May 28, 2026 12:39
@coderabbitai coderabbitai Bot mentioned this pull request May 28, 2026
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.

2 participants