Skip to content

fix(analytics): deduplicate plans page visit tracking - #2964

Merged
WcaleNieWolny merged 7 commits into
mainfrom
wolny/fix-plans-user-visit-tracking
Aug 9, 2026
Merged

fix(analytics): deduplicate plans page visit tracking#2964
WcaleNieWolny merged 7 commits into
mainfrom
wolny/fix-plans-user-visit-tracking

Conversation

@WcaleNieWolny

@WcaleNieWolny WcaleNieWolny commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

  • preserve the existing User visit event while identifying Plans visits with page: plans
  • deduplicate Plans visits once per organization per route activation
  • remove only the redundant emitter from Usage while retaining its unrelated behavior

Test plan

  • bun lint
  • bunx vitest run tests/plans-visit-tracking.unit.test.ts
  • bun test:unit
  • bun run typecheck:frontend

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Plans-page visits now include Plans-specific metadata in analytics events.
    • Visits are tracked once per organization during each Plans-page activation.
  • Bug Fixes

    • Prevented duplicate visit events from being recorded through the Usage page.
    • Improved handling when organization details are unavailable.
  • Tests

    • Added coverage for event payloads, deduplication, organization changes, and page behavior.
  • Documentation

    • Added design and implementation documentation for Plans visit tracking.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 15 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9c5d3a97-bcdf-4218-a9e6-1f3b22bc2b50

📥 Commits

Reviewing files that changed from the base of the PR and between ba442b8 and 344f089.

📒 Files selected for processing (3)
  • src/pages/settings/organization/Plans.vue
  • src/services/plansVisitTracking.ts
  • tests/plans-visit-tracking.unit.test.ts
📝 Walkthrough

Walkthrough

Adds a tracker that emits the Plans User visit event once per organization per tracker instance, tags it with page: 'plans', integrates it into Plans.vue, removes the duplicate Usage.vue emission, and adds tests and design documentation.

Changes

Plans visit tracking

Layer / File(s) Summary
Tracking service and event contract
src/services/plansVisitTracking.ts, tests/plans-visit-tracking.unit.test.ts, docs/superpowers/specs/..., docs/superpowers/plans/...
Adds createPlansVisitTracker with organization validation, per-instance deduplication, injectable event dispatch, and Plans-page event metadata. Tests cover payloads, duplicate suppression, organization changes, new instances, and missing IDs.
Plans and Usage integration
src/pages/settings/organization/Plans.vue, src/pages/settings/organization/Usage.vue, tests/plans-visit-tracking.unit.test.ts, docs/superpowers/plans/...
Plans.vue uses the tracker for visit events. Usage.vue no longer imports or emits the duplicate event. Source-level tests verify both integrations and the documented validation steps.

Estimated code review effort: 2 (Simple) | ~15 minutes

Suggested labels: codex

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: deduplicating Plans page visit tracking.
Description check ✅ Passed The description provides a clear summary and concrete test plan; screenshots and checklist details are omitted but are non-critical for this analytics change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Risk: low. Approved — Cursor Bugbot was not present on this PR, and the change is a narrow Plans visit-tracking dedupe with focused unit tests and no applicable approval-policy blockers. No reviewers assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

@codspeed-hq

codspeed-hq Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing wolny/fix-plans-user-visit-tracking (344f089) with main (54479f3)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/pages/settings/organization/Plans.vue Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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/pages/settings/organization/Plans.vue`:
- Line 440: Update the watchEffect flow around plansVisitTracker.track(orgId) to
use an activation token and capture the organization ID being checked; only
track when both the token and captured ID still match the current page
activation and organization, preventing stale asynchronous runs from recording
visits after navigation or organization changes.

In `@src/services/plansVisitTracking.ts`:
- Line 1: Update the tracking import in plansVisitTracking.ts to use the
~/services/tracking alias instead of the relative ./tracking path.

In `@tests/plans-visit-tracking.unit.test.ts`:
- Around line 45-50: Replace the new-instance tracking test around
createPlansVisitTracker with a route-reset contract test: retain a tracker
instance, track org-1, call its reset() method, then verify tracking org-1 again
succeeds and sender is called twice. Update the related integration assertions
to require the Plans source to invoke tracker.reset(), rather than asserting
that plansVisitTracker.reset() is absent.
🪄 Autofix

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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 14ab2bd7-40ed-4c11-8539-d330b9189669

📥 Commits

Reviewing files that changed from the base of the PR and between ecfb160 and ba442b8.

📒 Files selected for processing (6)
  • docs/superpowers/plans/2026-08-09-fix-plans-user-visit-events.md
  • docs/superpowers/specs/2026-08-09-plans-user-visit-tracking-design.md
  • src/pages/settings/organization/Plans.vue
  • src/pages/settings/organization/Usage.vue
  • src/services/plansVisitTracking.ts
  • tests/plans-visit-tracking.unit.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)
💤 Files with no reviewable changes (1)
  • src/pages/settings/organization/Usage.vue

Comment thread src/pages/settings/organization/Plans.vue Outdated
Comment thread src/services/plansVisitTracking.ts Outdated
Comment thread tests/plans-visit-tracking.unit.test.ts
@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2026

Copy link
Copy Markdown

@WcaleNieWolny
WcaleNieWolny merged commit 918f7dc into main Aug 9, 2026
78 checks passed
@WcaleNieWolny
WcaleNieWolny deleted the wolny/fix-plans-user-visit-tracking branch August 9, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant