Skip to content

incubyte/copilot-stats

Repository files navigation

🤖 Copilot Stats Dashboard

GitHub Copilot Usage Analytics Dashboard - Track and visualize AI assistance patterns across your organization's repositories.

MIT License Node.js Version TypeScript NestJS React

📊 What is Copilot Stats?

Copilot Stats is a comprehensive analytics dashboard that helps organizations understand how their teams are leveraging GitHub Copilot and AI tools across their development workflow. It provides insights into:

  • 📈 AI Usage Patterns - Track code generation, test creation, documentation, and review patterns
  • 🔍 Copilot Review Analytics - Monitor when and how Copilot reviews are being utilized
  • 📋 Repository Insights - Get detailed stats across multiple specified repositories

🛠️ Tech Stack

  • Backend: NestJS, TypeScript, Octokit (GitHub API)
  • Frontend: React, TypeScript, Vite
  • Build System: Turborepo, pnpm
  • Styling: Material UI for React

📦 Installation

Prerequisites

  • Node.js (v18+ required)
  • pnpm
  • GitHub CLI (gh) installed and authenticated
  • GitHub Personal Access Token with repository permissions

Quick Start

# Clone the repository
git clone https://github.com/incubyte/copilot-stats.git
cd copilot-stats

# Install dependencies
pnpm install

# Create .env in backend folder with your configuration
# You can use .env.example file in backend folder as reference

# Start development servers
pnpm start:dev

The application will be available at:

⚙️ Configuration

Create a .env file in the backend directory:

# GitHub Configuration
GITHUB_TOKEN=your_github_personal_access_token
GITHUB_ORG=your-organization-name
GITHUB_REPOS=repo1,repo2,repo3

# Application Configuration
PORT=3006
NODE_ENV=development

Environment Variables Explained

Variable Description
GITHUB_TOKEN GitHub Personal Access Token with repo permissions
GITHUB_ORG Your GitHub organization name
GITHUB_REPOS Comma-separated list of repository names to analyze

📝 How to Use AI Usage Tracking

Add the following comment block to your PR descriptions to track AI usage:

<!-- AI_USAGE_START -->
- [ ] AI_CODE: Used for code generation
- [ ] AI_TEST: Used for test generation  
- [ ] AI_DOCS: Used for documentation
- [ ] AI_OTHER: Other AI usage
<!-- AI_USAGE_END -->

Check the boxes that apply to indicate which types of AI assistance were used in the pull request.

🔧 Development

Project Structure

copilot-stats/
├── apps/
│   ├── backend/          # NestJS API server
│   └── frontend/         # React dashboard
├── packages/             # Shared packages
├── LICENSE              # MIT license
└── turbo.json          # Turborepo configuration

Available Scripts

# Development
pnpm start:dev           # Start both frontend and backend in dev mode

# Build
pnpm build              # Build all applications

# Clean
pnpm clean              # Clean build artifacts

📚 API Documentation

GET /github/copilot-usage-stream

Returns real-time Copilot usage statistics via Server-Sent Events.

Query Parameters:

  • days (optional): Number of days to analyze (default: 1)

Response Format:

{
  "pullRequestsReviewedByCopilot": {
    "repo-name": [
      {
        "number": 123,
        "title": "Feature implementation",
        "author": "username",
        "closed_at": "2024-01-01T00:00:00Z",
        "repo": "repo-name",
        "ai_usage": {
          "code": 1,
          "test": 0,
          "docs": 1,
          "other": 0,
          "review": 0
        },
        "copilot_review": {
          "login": "github-copilot[bot]",
          "type": "Bot",
          "body": "Review comments...",
          "url": "https://github.com/..."
        }
      }
    ]
  },
  "usageOfAI": {
    "code": 5,
    "test": 3,
    "docs": 2,
    "other": 1,
    "review": 8
  }
}

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Made with ❤️ by Incubyte

About

Get an report of Copilot usage statistics for given repos

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published