Skip to content

feat(telemetry): add PostHog event tracking to publish and run commands #1607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 19, 2025

Conversation

amirabbas-gh
Copy link
Collaborator

📚 Description

This PR introduces a new telemetry crate and integrates PostHog event tracking into the publish and run commands. The goal is to help Codemod better understand how these commands are being used in practice and gather insights for future improvements.

  • Created a reusable telemetry crate for sending events
  • Integrated PostHog event sending into:
    • codemod publish
    • codemod run

This lays the foundation for richer product analytics across the CLI.

🧪 Test Plan

  • Manually tested codemod publish and codemod run locally with a valid PostHog token
  • Run test units

@amirabbas-gh amirabbas-gh requested a review from mohebifar July 14, 2025 13:49
Copy link

vercel bot commented Jul 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
codemod ⬜️ Ignored (Inspect) Visit Preview Jul 19, 2025 6:58am

Copy link

pkg-pr-new bot commented Jul 14, 2025

Open in StackBlitz

npm i https://pkg.pr.new/codemod@1607

commit: 6f7b233

Copilot

This comment was marked as outdated.

Comment on lines 30 to 32
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
Copy link
Member

Choose a reason for hiding this comment

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

remove this

@amirabbas-gh amirabbas-gh requested a review from mohebifar July 18, 2025 13:04
@mohebifar mohebifar requested a review from Copilot July 19, 2025 05:32
@codemod-com codemod-com deleted a comment from Copilot AI Jul 19, 2025
Copilot

This comment was marked as outdated.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new telemetry system for the Codemod CLI that tracks usage analytics via PostHog. The implementation adds event tracking to the publish and run commands to gather insights on how these features are being used in practice.

  • Added a new codemod-telemetry crate with PostHog integration and null sender for opt-out scenarios
  • Integrated telemetry into codemod publish and codemod run commands with execution statistics
  • Added environment variable support for disabling analytics and build-time PostHog API key injection

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/telemetry/* New telemetry crate with PostHog sender and null sender implementations
crates/core/src/engine.rs Added global execution statistics tracking via OnceLock
crates/cli/src/main.rs Integrated telemetry sender initialization and dependency injection
crates/cli/src/commands/run.rs Added telemetry events for codemod execution with success/failure tracking
crates/cli/src/commands/publish.rs Added telemetry event for successful codemod publishing
Cargo.toml files Updated dependencies and workspace configuration
.github/workflows/cargo-release.yml Added PostHog API key environment variable for builds

None,
)
.await;
return Err(anyhow::anyhow!("Error executing codemod: {}", e));
Copy link
Preview

Copilot AI Jul 19, 2025

Choose a reason for hiding this comment

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

The original error information is being lost by wrapping it in a new anyhow error with just the Display representation. Consider using return Err(e) or .context() to preserve the error chain.

Copilot uses AI. Check for mistakes.

@mohebifar mohebifar merged commit fa392ff into main Jul 19, 2025
13 checks passed
@mohebifar mohebifar deleted the posthog branch July 19, 2025 07:05
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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy