Skip to content

feat(posthog): Add tracking on mothership abort#4023

Merged
TheodoreSpeaks merged 1 commit intostagingfrom
log/posthog-abort-button
Apr 7, 2026
Merged

feat(posthog): Add tracking on mothership abort#4023
TheodoreSpeaks merged 1 commit intostagingfrom
log/posthog-abort-button

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

Added posthog event for mothership and copilot aborts so we can filter session recordings by these places which commonly signal there's some issue (incorrect behavior, long running jobs, stuck processes, etc)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Manually reviewed. Impact is minimal, just added posthog event.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 7, 2026 8:08pm

Request Review

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@BugBot review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 7, 2026

PR Summary

Low Risk
Low risk instrumentation-only change: adds a new PostHog event emitted when users stop generation in mothership or copilot, without altering server logic or data flows.

Overview
Adds a new PostHog analytics event, task_generation_aborted, to track when users click Stop generation.

Home (mothership) and workflow Panel (copilot chat) now wrap stopGeneration with a handler that captures the event (including workspace_id and view) before aborting generation, and apps/sim/lib/posthog/events.ts is updated to type the new event and properties.

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

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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1468b67. Configure here.

@TheodoreSpeaks TheodoreSpeaks marked this pull request as ready for review April 7, 2026 22:13
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This PR adds PostHog analytics tracking for when users abort AI task generation in two chat interfaces: the mothership home view and the copilot panel. It introduces a new task_generation_aborted event type (with workspace_id and view properties) and wraps the raw stop-generation callbacks in thin analytics-aware handlers that capture the event before delegating to the underlying action.

  • events.ts: New task_generation_aborted event added to PostHogEventMap with workspace_id and a discriminated view union ('mothership' | 'copilot')
  • home.tsx: stopGeneration replaced with handleStopGeneration in both chat components; reuses the existing posthogRef pattern already present in the file
  • panel.tsx: New posthogRef + sync useEffect added (matching the pattern from home.tsx); copilotStopGeneration replaced with handleCopilotStopGeneration for the panel chat component

Confidence Score: 5/5

Safe to merge — minimal, well-scoped analytics addition with no logic changes

The PR only adds PostHog event tracking with no changes to core logic. The implementation correctly reuses the existing posthogRef pattern, uses optional chaining in captureEvent (no risk of throwing), and is typed end-to-end via PostHogEventMap. No issues found.

No files require special attention

Vulnerabilities

No security concerns identified.

Important Files Changed

Filename Overview
apps/sim/lib/posthog/events.ts Adds task_generation_aborted event type with workspace_id and view ('mothership'
apps/sim/app/workspace/[workspaceId]/home/home.tsx Wraps stopGeneration in handleStopGeneration to fire task_generation_aborted PostHog event before stopping generation in mothership view
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Adds posthogRef pattern and handleCopilotStopGeneration wrapper to fire task_generation_aborted before stopping copilot generation

Sequence Diagram

sequenceDiagram
    participant U as User
    participant H as handleStopGeneration / handleCopilotStopGeneration
    participant PH as PostHog (captureEvent)
    participant SG as stopGeneration / copilotStopGeneration

    U->>H: Click abort button
    H->>PH: captureEvent('task_generation_aborted', { workspace_id, view })
    PH-->>H: (fire-and-forget)
    H->>SG: Call underlying stop function
    SG-->>U: Generation stopped
Loading

Reviews (1): Last reviewed commit: "feat(posthog): Add tracking on mothershi..." | Re-trigger Greptile

@TheodoreSpeaks TheodoreSpeaks merged commit d0d3581 into staging Apr 7, 2026
12 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the log/posthog-abort-button branch April 7, 2026 22:30
TheodoreSpeaks added a commit that referenced this pull request Apr 7, 2026
* feat(posthog): Add tracking on mothership abort (#4023)

Co-authored-by: Theodore Li <[email protected]>

* fix(login): fix captcha headers for manual login  (#4025)

* fix(signup): fix turnstile key loading

* fix(login): fix captcha header passing

* Catch user already exists, remove login form captcha
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.

1 participant