Skip to content

fix(copilot): fix copilot stats updates#1237

Merged
Sg312 merged 1 commit intostagingfrom
fix/copilot-stats-v2
Sep 3, 2025
Merged

fix(copilot): fix copilot stats updates#1237
Sg312 merged 1 commit intostagingfrom
fix/copilot-stats-v2

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Sep 3, 2025

Summary

Fixes copilot stats

Fixes #(issue)

Type of Change

  • Bug fix

Testing

Manual

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

vercel bot commented Sep 3, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Sep 3, 2025 8:18pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 3, 2025 8:18pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR refactors the copilot statistics tracking system by consolidating and simplifying how usage metrics are collected throughout the application. The changes remove redundant stats tracking code from multiple locations and centralize the collection to only occur during meaningful user interactions.

Specifically, the PR removes comprehensive stats tracking from the copilot store that was collecting detailed metrics like agent depth, max enabled settings, diff creation status, duration, and token usage throughout the entire message lifecycle. It also eliminates early stats tracking from workflow tools (build-workflow.ts and edit-workflow.ts) that were sending premature updates before users could review changes.

The API endpoint schema has been dramatically simplified from 11 optional fields to only 3 required fields: messageId, diffCreated, and diffAccepted. This removes automatic userId injection, timestamps, and other optional analytics data. Stats are now only collected at the workflow diff store level when users actually accept or reject proposed changes, providing more meaningful usage analytics focused on actual user interactions rather than system events.

The refactoring eliminates duplicate tracking, reduces potential race conditions, and moves from a verbose frontend-driven approach to a streamlined server-side collection model. This fits well with the application's architecture by centralizing data collection and reducing the complexity of client-side stores.

PR Description Notes:

  • The template fields remain unfilled (Summary, Type of Change, Testing sections)
  • No issue number is referenced despite the "Fixes #(issue)" placeholder
  • All checklist items remain unchecked

Confidence score: 4/5

  • This PR is generally safe to merge but may impact analytics capabilities due to reduced data collection
  • Score reflects good code simplification but concerns about potential gaps in usage tracking and unfilled PR description
  • Pay close attention to the API route changes and ensure the simplified schema meets all analytics requirements

5 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

const body = parsed.data as any

// Build outgoing payload for Sim Agent; do not include id
const { messageId, diffCreated, diffAccepted } = parsed.data as any
Copy link
Contributor

Choose a reason for hiding this comment

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

style: unnecessary type assertion - parsed.data is already properly typed

Suggested change
const { messageId, diffCreated, diffAccepted } = parsed.data as any
const { messageId, diffCreated, diffAccepted } = parsed.data

Context Used: Context - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used to maintain type safety. (link)

@Sg312 Sg312 merged commit 3656d3d into staging Sep 3, 2025
5 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/copilot-stats-v2 branch September 5, 2025 05:50
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
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