jacob-ai-bot / jacob

Just Another Coding Bot
https://jacb.ai
Apache License 2.0
131 stars 20 forks source link

JACoB PR for Issue Implement Server-side PostHog Tracking for Key Events #383

Closed jacob-ai-bot[bot] closed 4 days ago

jacob-ai-bot[bot] commented 4 days ago

Summary:

Description

We need to add server-side PostHog tracking to monitor key user events within our application. The specific events to track are:

Adding this tracking will help us understand user engagement and behavior, enabling us to improve the application based on data-driven insights.

Expected Outcome

Additional Information

Plan:

Step 1: Edit /src/server/github/pr.ts

Task: Add PostHog tracking to pull request creation

Instructions: In the file /src/server/github/pr.ts, within the createPR function, after a pull request is successfully created (after the octokit.pulls.create call), import posthogClient from /src/server/analytics/posthog.ts if not already imported. Then, add a PostHog event capture using posthogClient.capture. The event should be named "Pull Request Created" and include properties such as repository.full_name (repository name), result.data.number (pull request number), title (pull request title), and any other relevant data like the user ID if available.

Exit Criteria: A PostHog event named "Pull Request Created" is sent whenever a new pull request is created, including the repository name, pull request number, title, and relevant user information.

Step 2: Edit /src/server/utils/events.ts

Task: Add PostHog tracking when a new task is started

Instructions: In the file /src/server/utils/events.ts, within the emitTaskEvent function, import posthogClient from /src/server/analytics/posthog.ts if not already imported. When emitting a task event with status equal to TaskStatus.IN_PROGRESS (indicating a new task has started), add a PostHog event capture using posthogClient.capture. The event should be named "Task Started" and include properties such as the taskId, issueId, userId from baseEventData.userId, projectId from baseEventData.projectId, subType (task subtype), and any other relevant data.

Exit Criteria: A PostHog event named "Task Started" is sent whenever a new task is started, including task ID, issue ID, user ID, project ID, and task subtype.

Step 3: Edit /src/server/api/routers/todos.ts

Task: Add PostHog tracking to new todo creation

Instructions: In the file /src/server/api/routers/todos.ts, within the create mutation of the todoRouter, after a new todo item is successfully created, import posthogClient from /src/server/analytics/posthog.ts if not already imported. Add a PostHog event capture using posthogClient.capture. The event should be named "Todo Created" and include properties such as todo.id (the ID of the newly created todo), input.projectId, input.name, input.status, and any other relevant data. If the user ID is available in the context, include it as well.

Exit Criteria: A PostHog event named "Todo Created" is sent whenever a new todo is created, including the todo ID, project ID, name, status, and user ID if available.