Skip to content

fix(cli): identify terminal replay users - #2913

Merged
WcaleNieWolny merged 6 commits into
mainfrom
wolny/cli-replay-identify
Aug 7, 2026
Merged

fix(cli): identify terminal replay users#2913
WcaleNieWolny merged 6 commits into
mainfrom
wolny/cli-replay-identify

Conversation

@WcaleNieWolny

@WcaleNieWolny WcaleNieWolny commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

  • mark the first CLI replay snapshot for person identification
  • identify the authenticated PostHog person by the same UUID used by the frontend and set their email
  • keep replay delivery best-effort when email lookup or identification fails
  • remove one stale CLI type import from current main so the CLI lint gate can run

Verification

  • bun lint
  • bun lint:backend
  • bun test:unit (194 files, 1,402 tests)
  • bun run cli:check

Summary by CodeRabbit

  • Bug Fixes

    • Replay captures now continue successfully when an authenticated email address cannot be resolved.
    • Improved replay identification and snapshot metadata handling.
    • Added more reliable timeout cleanup and support for additional capture endpoint formats.
    • Corrected trial-plan totals and daily trend reporting in administrative statistics.
  • Reliability

    • Improved handling of invalid capture endpoints and follow-up replay snapshots.

@coderabbitai

coderabbitai Bot commented Aug 7, 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: 38 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: d549825d-b483-4eff-8146-f54bfb74b0ee

📥 Commits

Reviewing files that changed from the base of the PR and between a4baa91 and 3fcdb9e.

📒 Files selected for processing (2)
  • supabase/functions/_backend/utils/posthog.ts
  • tests/posthog.unit.test.ts
📝 Walkthrough

Walkthrough

Replay capture now sends optional person identification data, normalizes PostHog endpoints, applies request timeouts, and continues snapshot processing when email resolution or identification fails. Tests cover the updated flows and endpoint handling.

Changes

Replay capture flow

Layer / File(s) Summary
Capture payload and delivery handling
supabase/functions/_backend/utils/posthog.ts
Capture payloads support person properties and request timeouts. Shared URL normalization is used for event and group identification.
Initial replay identification
supabase/functions/_backend/private/replay.ts, supabase/functions/_backend/utils/posthog.ts
Initial snapshots send $identify when an email is available. Missing emails and identification failures no longer block snapshot capture.
Regression coverage and consistency updates
tests/posthog.unit.test.ts, tests/admin-stats.test.ts, cli/src/build/prescan/engine.ts
Tests cover identification, endpoint normalization, missing emails, follow-up snapshots, timeouts, and invalid hosts. Supporting assertions and imports are updated.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: codex

Suggested reviewers: riderx

🚥 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
Title check ✅ Passed The title clearly identifies the main change: identifying terminal replay users in the CLI.
Description check ✅ Passed The description explains the changes and lists verification commands, but it omits the template checklist and explicit test plan and screenshots sections.
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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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

@codspeed-hq

codspeed-hq Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing wolny/cli-replay-identify (3fcdb9e) with main (9a3d210)

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

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

Re-trigger cubic

Comment thread supabase/functions/_backend/utils/posthog.ts Outdated
Comment thread cli/src/init/replay.ts Outdated

@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 7 files

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

Re-trigger cubic

Comment thread supabase/functions/_backend/utils/posthog.ts

@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: 1

🤖 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 `@supabase/functions/_backend/utils/posthog.ts`:
- Around line 110-112: Handle malformed PostHog hosts without throwing by
updating getPostHogCaptureUrl and its callers: at posthog.ts lines 36-36 and
392-392, catch URL-resolution failures, log them, and return false to preserve
the tracking and group-identification contracts; add regression tests covering
malformed hosts through trackPosthogEvent and groupIdentifyPosthog. The affected
anchor at posthog.ts lines 110-112 requires either controlled failure from
getPostHogCaptureUrl or caller-side exception handling.
🪄 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: 3ca7d537-90ed-4006-be17-44d781c30453

📥 Commits

Reviewing files that changed from the base of the PR and between b20cd7a and a4baa91.

📒 Files selected for processing (5)
  • cli/src/build/prescan/engine.ts
  • supabase/functions/_backend/private/replay.ts
  • supabase/functions/_backend/utils/posthog.ts
  • tests/admin-stats.test.ts
  • tests/posthog.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)
  • supabase/functions/_backend/private/replay.ts

Comment thread supabase/functions/_backend/utils/posthog.ts

@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 5 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread supabase/functions/_backend/utils/posthog.ts
@sonarqubecloud

sonarqubecloud Bot commented Aug 7, 2026

Copy link
Copy Markdown

@WcaleNieWolny
WcaleNieWolny merged commit 11de018 into main Aug 7, 2026
252 of 259 checks passed
@WcaleNieWolny
WcaleNieWolny deleted the wolny/cli-replay-identify branch August 7, 2026 15:37
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