Skip to content

fix: improve analytics observability for retention debugging#79

Merged
aidenybai merged 3 commits into
mainfrom
fix/retention-apr-4
Apr 5, 2026
Merged

fix: improve analytics observability for retention debugging#79
aidenybai merged 3 commits into
mainfrom
fix/retention-apr-4

Conversation

@NisargIO
Copy link
Copy Markdown
Member

@NisargIO NisargIO commented Apr 5, 2026

Summary

  • Fix minified error tags: run:failed events now use Effect's _tag property instead of error.constructor.name, which gets minified in production builds. This means error types like HeadlessRunTimeoutError will appear as readable strings in PostHog instead of em, rm, etc.
  • Instrument missing cookie events: cookies:sync_choice and cookies:toggled were typed in EventMap but never emitted. Now fired from the cookie sync confirm screen and the Ctrl+K toggle in the main menu.
  • Fix misleading cookies:browser_selection: Previously fired even when zero browsers were selected. Now only emits when keys.length > 0.

Context

Retention analysis surfaced several observability gaps:

  • 251 run:failed events had opaque minified error tags, making crash diagnosis impossible
  • cookies:sync_choice showed historical data in PostHog but was no longer instrumented after a refactor
  • No way to track cookie enable/disable toggles

Test plan

  • Run pnpm typecheck — only pre-existing agent.ts errors, no new type errors
  • Trigger a run:failed in dev mode and verify error_tag contains the _tag string
  • Go through cookie sync flow and verify cookies:sync_choice, cookies:browser_selection, and cookies:toggled events fire in PostHog (or dev logger)
  • Clear cookies via Ctrl+K and verify cookies:cleared + cookies:toggled both fire

Made with Cursor


Note

Low Risk
Low risk analytics-only changes: adds/adjusts PostHog event emissions and improves run:failed tagging without altering execution flow.

Overview
Improves CLI analytics observability by emitting the previously-unused cookies:sync_choice and cookies:toggled events, and by only firing cookies:browser_selection when at least one browser is selected (cookie sync confirm + Ctrl+K clear path).

Updates run:failed analytics to prefer Effect error _tag values over error.constructor.name to avoid minified error type strings in production builds. Also adds .cursor/settings.json enabling the PostHog Cursor plugin.

Reviewed by Cursor Bugbot for commit 6e3a625. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Improves analytics for retention debugging by making error tagging robust and restoring cookie event tracking. Failed runs and cookie flows now report accurate, readable data in PostHog.

  • Bug Fixes

    • Use Effect _tag for run:failed error_tag and add safe fallback to Error name to avoid minified tags.
    • Emit cookies:browser_selection only when at least one browser is selected.
  • New Features

    • Add missing events: cookies:sync_choice and cookies:toggled (fires on enable/disable, including Ctrl+K clear).

Written for commit bdfaf7f. Summary will update on new commits.

- Use Effect error _tag instead of constructor.name for run:failed
  error_tag, fixing minified class names in production builds
- Instrument missing cookies:sync_choice and cookies:toggled events
- Only emit cookies:browser_selection when browsers are selected

Made-with: Cursor
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 5, 2026

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

Project Deployment Actions Updated (UTC)
expect Ready Ready Preview, Comment Apr 5, 2026 4:19am

@aidenybai aidenybai marked this pull request as ready for review April 5, 2026 01:33
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 5, 2026

Open in StackBlitz

npm i https://pkg.pr.new/expect-cli@79

commit: bdfaf7f

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6e3a625. Configure here.

Comment thread .cursor/settings.json
"enabled": true
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor IDE settings file accidentally committed to repository

Low Severity

The .cursor/settings.json file enables the Cursor IDE PostHog telemetry plugin. This is IDE-specific configuration unrelated to the PR's application analytics improvements. The .gitignore already covers .cursor/plans but not this file, suggesting it was unintentionally included alongside the analytics changes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6e3a625. Configure here.

Comment thread apps/cli/src/data/execution-atom.ts
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/cli/src/data/execution-atom.ts">

<violation number="1" location="apps/cli/src/data/execution-atom.ts:192">
P2: Guard `error` as a non-null object before using `"_tag" in error`; otherwise telemetry can be dropped when failures are primitives/null.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread apps/cli/src/data/execution-atom.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

Test Results

✅ Website Test: passed

13 passed, 0 failed out of 14 steps — 338s

Step Status Duration
Homepage loads — hero section and install commands visible ✅ passed 14s
View demo — navigates to /replay?demo=true and replay player loads ✅ passed 43s
Replay controls — play/pause works, speed selector present, step list visible ✅ passed 38s
Copy button — homepage install command copies to clipboard ✅ passed 27s
Theme toggle — switch to dark mode, verify background changes, switch back ✅ passed 25s
Footer links — GitHub and X with correct URLs and target="_blank" ✅ passed 11s
Legal page /terms — loads with text content ✅ passed 7s
Legal page /privacy — loads with text content ✅ passed 4s
Legal page /security — loads with text content ✅ passed 14s
Mobile viewport 375×812 — no horizontal scroll, key content visible ✅ passed 58s
Accessibility audit — WCAG violations check ⬜ not-run
Performance metrics — Web Vitals check ✅ passed 9s
Project healthcheck — pnpm check ✅ passed 35s
rrweb sandbox script-blocking — deep-dive evidence collection ✅ passed 47s

Session Recording

https://github.com/millionco/expect/releases/download/ci-pr-79/36b597dd55976825a89bac6b9e4f50f5.webm


Workflow run #303 | 📎 Download all recordings

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Comment thread .cursor/settings.json
@@ -0,0 +1,7 @@
{
Copy link
Copy Markdown
Contributor

@vercel vercel Bot Apr 5, 2026

Choose a reason for hiding this comment

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

IDE-specific settings file (.cursor/settings.json) was committed to the repository when it should only be in .gitignore

Fix on Vercel

Comment thread .cursor/settings.json
@@ -0,0 +1,7 @@
{
"plugins": {
"posthog": {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

? do u wanna comit this

Comment thread apps/cli/src/data/execution-atom.ts
- Updated error handling logic to cast errors as any before checking instance type, ensuring compatibility with various error structures.
- This change addresses potential type issues while maintaining existing functionality.
@aidenybai aidenybai merged commit 093290d into main Apr 5, 2026
12 of 13 checks passed
@NisargIO NisargIO deleted the fix/retention-apr-4 branch April 5, 2026 05:08
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