Skip to content

feat(tables): add PostHog events for table-workflow run/stop gestures#4839

Merged
TheodoreSpeaks merged 3 commits into
stagingfrom
feat/posthog-table-workflow
Jun 1, 2026
Merged

feat(tables): add PostHog events for table-workflow run/stop gestures#4839
TheodoreSpeaks merged 3 commits into
stagingfrom
feat/posthog-table-workflow

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

  • Add two typed PostHog events to the catalog: table_workflow_run (source: row|rows|column, run_mode, group_count, row_count, has_limit) and table_workflow_stopped (scope: all|row|rows, row_count)
  • Instrument at the canonical dispatchers in table.tsx (runScope, onStopRow, onStopRows, onStopAll) so every run/stop gesture — column header menu, per-row gutter, action bar, right-click context menu — fires exactly once per real dispatch
  • Run capture lives inside runScope after its no-op guards, so short-circuited runs don't emit phantom events
  • Uses the existing usePostHog() + posthogRef pattern so memoized children (DataRow, RunStatusControl) keep stable handler identity

Type of Change

  • New feature (analytics)

Testing

Tested manually. bun run lint and bun run check:api-validation:strict both pass; tsc --noEmit clean on touched files.

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)

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 1, 2026 11:49pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Jun 1, 2026

PR Summary

Low Risk
Client-only analytics instrumentation with no changes to run/cancel API behavior or auth.

Overview
Adds typed PostHog analytics for table workflow run and stop actions from the table grid.

New catalog events table_workflow_run and table_workflow_stopped in events.ts capture gesture source (row / rows / column or stop scope), run mode, counts, and limits. In table.tsx, runs emit from the shared runScope dispatcher (after no-op guards) with a required source on all entry points; stops emit from onStopRow, onStopRows, and onStopAll. Uses the existing usePostHog + posthogRef pattern so memoized child handlers stay stable.

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 1, 2026

Greptile Summary

This PR adds PostHog analytics instrumentation for table-workflow run and stop gestures by defining two new typed events (table_workflow_run, table_workflow_stopped) and capturing them inside the canonical dispatchers in table.tsx.

  • Event definitions (events.ts): table_workflow_run records source (row/rows/column), run_mode, group_count, row_count (nullable when targeting all rows), and has_limit; table_workflow_stopped records scope (all/row/rows) and row_count (nullable for the all scope).
  • Instrumentation (table.tsx): Events are captured inside runScope (after the existing no-op guards, preventing phantom events), onStopRow, onStopRows (also guarded by the pre-existing rowIds.length === 0 early return), and onStopAll; the posthogRef pattern keeps memoized children (DataRow, RunStatusControl) stable.

Confidence Score: 5/5

Safe to merge — changes are purely additive analytics instrumentation with no effect on table data or workflow execution paths.

The two changed files make only additive changes: new type definitions in the event catalog and captureEvent calls in existing dispatcher callbacks. Every capture site is placed after its existing no-op guards, so short-circuited paths emit nothing. The posthogRef pattern is consistent with the rest of the codebase, dependency arrays are correct, and the typed event map ensures compile-time correctness. There are no changes to business logic, API calls, or state management.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/posthog/events.ts Adds two well-typed PostHog event definitions (table_workflow_run, table_workflow_stopped) to the catalog with documented nullable fields; no issues.
apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx Instruments runScope, onStopRow, onStopRows, and onStopAll with PostHog events using the posthogRef pattern; early-return guards in all four dispatchers prevent phantom events; dependency arrays are correct.

Sequence Diagram

sequenceDiagram
    participant UI as UI Gesture
    participant T as table.tsx dispatcher
    participant API as runColumnMutate / cancelRunsMutate
    participant PH as PostHog

    UI->>T: onRunColumn / onRunRows / onRunRow
    T->>T: "runScope() — guard: groupIds.length == 0?"
    alt no-op
        T-->>UI: return (no event)
    else real run
        T->>API: runColumnMutate(args)
        T->>PH: "captureEvent(table_workflow_run, {source, run_mode, group_count, row_count, has_limit})"
    end

    UI->>T: onStopRow(rowId)
    T->>API: "cancelRunsMutate({scope:row, rowId})"
    T->>PH: "captureEvent(table_workflow_stopped, {scope:row, row_count:1})"

    UI->>T: onStopRows(rowIds)
    T->>T: "guard: rowIds.length == 0?"
    alt no-op
        T-->>UI: return (no event)
    else real stop
        loop each rowId
            T->>API: "cancelRunsMutate({scope:row, rowId})"
        end
        T->>PH: "captureEvent(table_workflow_stopped, {scope:rows, row_count:N})"
    end

    UI->>T: onStopAll()
    T->>API: "cancelRunsMutate({scope:all})"
    T->>PH: "captureEvent(table_workflow_stopped, {scope:all, row_count:null})"
Loading

Reviews (1): Last reviewed commit: "feat(tables): add PostHog events for tab..." | Re-trigger Greptile

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