Skip to content

feat: track task creation with workspace mode and worktree file usage#2112

Merged
adboio merged 1 commit intomainfrom
posthog-code/add-task-creation-events-and-insight
May 8, 2026
Merged

feat: track task creation with workspace mode and worktree file usage#2112
adboio merged 1 commit intomainfrom
posthog-code/add-task-creation-events-and-insight

Conversation

@adboio
Copy link
Copy Markdown
Contributor

@adboio adboio commented May 8, 2026

TL;DR

Adds comprehensive analytics tracking for task creation events, capturing workspace mode (local/worktree/cloud), worktree file usage (.worktreelink/.worktreeinclude), and environment configuration details to enable insights into user preferences across different workspace modes.

Problem

We need to audit task creation events across different workspace modes (local, worktree, cloud) to understand which modes users prefer and identify feature usage patterns. The existing task creation tracking was incomplete and lacked the necessary data to build these insights.

Closes #2100

Changes

Backend (Workspace Service)

  • Added getWorktreeFileUsage() method to detect whether .worktreelink or .worktreeinclude files exist and contain non-empty, non-comment entries
  • Added hasExcludeFileEntries() helper to safely read and parse worktree exclude files
  • Added new Zod schemas getWorktreeFileUsageInput and getWorktreeFileUsageOutput for type safety

API (tRPC Router)

  • Exposed getWorktreeFileUsage as a public tRPC procedure to allow frontend queries for worktree file usage data

Frontend (Task Creation Tracking)

  • Added trackTaskCreated() function to comprehensively track task creation with:
    • Workspace mode (local/worktree/cloud)
    • Auto-run status
    • Repository provider (GitHub or none)
    • Branch information
    • Environment/sandbox environment configuration
    • Cloud run source and PR authorship mode
    • Worktree file usage (.worktreelink and .worktreeinclude)
    • Adapter type
  • Integrated tracking into task creation flow in useTaskCreation hook
  • Removed incomplete task creation tracking from useTasks hook to consolidate in one place

How did you test this?

  • Verified the new tRPC endpoint is properly typed with input/output schemas
  • Confirmed worktree file parsing correctly identifies non-empty, non-comment lines
  • Validated task creation tracking captures all required analytics properties
  • Error handling ensures failed analytics calls don't block task creation

Publish to changelog?

yes


Created with PostHog Code

… analytics

Generated-By: PostHog Code
Task-Id: f5278728-a8c6-46c7-a923-150789eee599
@adboio adboio requested a review from a team May 8, 2026 16:47
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 8, 2026

Comments Outside Diff (1)

  1. apps/code/src/renderer/features/tasks/hooks/useTasks.ts, line 94-106 (link)

    P2 The createdFrom field remains in the mutation variable type but is now entirely unused — it's no longer forwarded to the server and the onSuccess callback that consumed it was removed in this PR. Since no caller ever sets this field (confirmed: useCreateTask is only consumed for invalidateTasks), this is dead code that violates the "no superfluous parts" rule.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/code/src/renderer/features/tasks/hooks/useTasks.ts
    Line: 94-106
    
    Comment:
    The `createdFrom` field remains in the mutation variable type but is now entirely unused — it's no longer forwarded to the server and the `onSuccess` callback that consumed it was removed in this PR. Since no caller ever sets this field (confirmed: `useCreateTask` is only consumed for `invalidateTasks`), this is dead code that violates the "no superfluous parts" rule.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/renderer/features/tasks/hooks/useTasks.ts:94-106
The `createdFrom` field remains in the mutation variable type but is now entirely unused — it's no longer forwarded to the server and the `onSuccess` callback that consumed it was removed in this PR. Since no caller ever sets this field (confirmed: `useCreateTask` is only consumed for `invalidateTasks`), this is dead code that violates the "no superfluous parts" rule.

```suggestion
    (
      client,
      {
        description,
        repository,
        github_integration,
      }: {
        description: string;
        repository?: string;
        github_integration?: number;
      },
    ) =>
```

Reviews (1): Last reviewed commit: "feat: track task creation with workspace..." | Re-trigger Greptile

@adboio adboio added the Create release This will trigger a new release label May 8, 2026 — with Graphite App
@adboio adboio merged commit ae3c8b5 into main May 8, 2026
15 checks passed
Copy link
Copy Markdown
Contributor Author

adboio commented May 8, 2026

Merge activity

@adboio adboio deleted the posthog-code/add-task-creation-events-and-insight branch May 8, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants