Skip to content

fix: report actual path for improved tracking accuracy#2806

Merged
HarshMN2345 merged 3 commits intomainfrom
fix-report-actual-path
Mar 16, 2026
Merged

fix: report actual path for improved tracking accuracy#2806
HarshMN2345 merged 3 commits intomainfrom
fix-report-actual-path

Conversation

@HarshMN2345
Copy link
Member

@HarshMN2345 HarshMN2345 commented Mar 16, 2026

What does this PR do?

example:
image

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Summary by CodeRabbit

  • Chores
    • Analytics payloads now include both the page path and a normalized route identifier to improve routing context sent to analytics.
    • Logging and development/preview behavior remain unchanged; no user-facing functionality was altered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

Warning

Rate limit exceeded

@HarshMN2345 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f02db558-9828-4199-844c-33ae51b0cf8e

📥 Commits

Reviewing files that changed from the base of the PR and between 965bf1f and e98163a.

📒 Files selected for processing (1)
  • src/lib/actions/analytics.ts

Walkthrough

The trackEvent function in src/lib/actions/analytics.ts was updated to derive path from page.url.pathname instead of page.route.id. It also computes a route by stripping grouped segments (parentheses) and normalizing slashes from page.route.id. For string eventArgs, the sent payload now includes route alongside path; for object eventArgs, the payload includes both path and route. Logging behavior remains gated by the same environment checks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: improving tracking accuracy by reporting the actual path instead of route identifiers, which is the core focus of the analytics.ts modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-report-actual-path
📝 Coding Plan
  • Generate coding plan for human review comments

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
Contributor

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/actions/analytics.ts`:
- Line 63: The current route normalization (const route =
page.route.id?.replace(/\(([^()]*)\)/g, '') ?? '') can produce double slashes
like "//docs"; after stripping parenthetical groups, collapse repeated slashes
and normalize the leading slash. Update the logic that creates route (the const
route variable derived from page.route.id) to first remove parenthetical groups,
then run a second replace to collapse multiple slashes (e.g. .replace(/\/{2,}/g,
'/')) and optionally ensure a single leading slash or empty string as desired so
grouped routes no longer produce malformed "//" entries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 846dc6fd-7e94-4aee-a580-f8b942a65789

📥 Commits

Reviewing files that changed from the base of the PR and between 1f85115 and fb6b95a.

📒 Files selected for processing (1)
  • src/lib/actions/analytics.ts

@HarshMN2345 HarshMN2345 merged commit 145af27 into main Mar 16, 2026
6 checks passed
@HarshMN2345 HarshMN2345 deleted the fix-report-actual-path branch March 16, 2026 07:55
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