A CLI tool to analyze GitHub pull request volume for organization members. Generates daily PR volume reports as CSV files and includes an interactive visualizer.
- Fetch PR data for specific users or all organization members
- Map email addresses to GitHub usernames via SAML/SSO
- Generate daily PR volume reports (per user, per user+repo)
- Interactive web-based visualization with Recharts
- Handles GitHub API rate limits automatically
- Supports date range filtering
- Bun v1.0+
- GitHub Personal Access Token with
repoandread:orgscopes
bun installCreate a Personal Access Token (classic) at https://github.com/settings/tokens with these scopes:
| Scope | Purpose |
|---|---|
repo |
Access PR data across private repos |
read:org |
List organization members |
For SSO-enabled organizations, authorize the token for the organization after creation.
Set the token as an environment variable (optional):
export GITHUB_TOKEN=ghp_your_token_hereUsage: gh-pr-analysis [options] [command]
GitHub PR volume analysis tool for organizations
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
fetch [options] Fetch PR volume data for GitHub organization members
map-emails [options] Map email addresses to GitHub usernames using SAML/SSO
help [command] display help for command
Usage: gh-pr-analysis fetch [options]
Fetch PR volume data for GitHub organization members
Options:
-t, --token <token> GitHub Personal Access Token (or set GITHUB_TOKEN env var)
-o, --org <organization> GitHub organization name
-e, --emails <emails> Comma-separated list of emails OR path to .txt file
-u, --usernames <usernames> Comma-separated list of usernames OR path to .txt file
-a, --all-members Fetch PRs for all organization members
-s, --start-date <date> Start date in YYYY-MM-DD format
-E, --end-date <date> End date in YYYY-MM-DD format (default: today)
-d, --days <number> Number of days to look back (default: "60")
-O, --output <directory> Output directory for CSV files (default: ".")
-v, --verbose Enable verbose logging
-h, --help display help for command
Usage: gh-pr-analysis map-emails [options]
Map email addresses to GitHub usernames using SAML/SSO
Options:
-t, --token <token> GitHub Personal Access Token (or set GITHUB_TOKEN env var)
-o, --org <organization> GitHub organization name
-e, --emails <emails> Comma-separated list of emails OR path to .txt file
-O, --output <file> Output file path for username mappings (default: stdout)
-v, --verbose Enable verbose logging
-h, --help display help for command
bun run start fetch -t $GITHUB_TOKEN -o my-org --all-membersbun run start fetch -t $GITHUB_TOKEN -o my-org -u user1,user2,user3# usernames.txt contains one username per line
bun run start fetch -t $GITHUB_TOKEN -o my-org -u usernames.txtbun run start fetch -t $GITHUB_TOKEN -o my-org --all-members \
--start-date 2025-01-01 --end-date 2025-01-31bun run start map-emails -t $GITHUB_TOKEN -o my-sso-org -e emails.txt -O mappings.csvThe fetch command generates two CSV files:
Daily PR count per user across all repos.
date,username,pr_count
2025-01-15,user1,5
2025-01-15,user2,3
2025-01-16,user1,2Daily PR count per user per repository.
date,username,repo,pr_count
2025-01-15,user1,repo-a,3
2025-01-15,user1,repo-b,2
2025-01-15,user2,repo-a,3An interactive web-based visualizer for the CSV data.
bun run visualizeThen open http://localhost:3000 in your browser.
- Drag and drop CSV files
- Line, Area, and Stacked chart types
- Toggle individual users on/off
- Interactive tooltips
- Summary statistics
src/
├── cli/
│ ├── index.ts # CLI entry point
│ └── commands/
│ ├── fetch-prs.ts # Fetch PR volume command
│ └── map-emails.ts # Email mapping command
├── lib/
│ ├── github/
│ │ ├── client.ts # GitHub API client
│ │ ├── graphql.ts # GraphQL queries (SAML)
│ │ └── rest.ts # REST API calls
│ ├── mapper/
│ │ └── email-mapper.ts # Email to username mapping
│ ├── fetcher/
│ │ └── pr-fetcher.ts # PR fetching with date windowing
│ └── output/
│ └── csv-generator.ts # CSV report generation
├── visualizer/
│ ├── index.html # Visualizer HTML
│ ├── app.tsx # React app
│ ├── styles.css # Styles
│ └── server.ts # Bun server
├── types/
│ └── index.ts # Type definitions
└── utils/
├── date.ts # Date utilities
└── logger.ts # Logging
bun testMIT