Skip to content

Latest commit

 

History

History
169 lines (130 loc) · 5.86 KB

File metadata and controls

169 lines (130 loc) · 5.86 KB

CYWF Analytics Dashboard Upgrade - Implementation Summary

Overview

This implementation adds comprehensive enhancements to the CYWF Analytics Dashboard, including new visualizations, interactive features, and an automated data pipeline using GitHub Actions.

Key Features Implemented

1. Automated Data Pipeline

  • GitHub Actions Workflow (.github/workflows/metrics.yml)

    • Runs every 30 minutes (at :17 and :47 past each hour)
    • Fetches data from GitHub GraphQL API
    • Generates static JSON files in public/data/
    • Commits and pushes updates automatically
  • Metrics Fetcher (scripts/fetchMetrics.mjs)

    • Fetches owned and public contributed repositories
    • Calculates activity tallies (commits, PRs, issues, reviews)
    • Generates monthly time series data
    • Approximates activity by hour distribution
    • Fetches public gists with previews
    • Fetches Quote of the Day from ZenQuotes/Quotable
    • Optionally fetches Daily Brief content

2. New Visualizations

  • Donut Chart: Shows PRs vs Issues vs Commits ratio
  • Stacked Bar Chart: Displays monthly activity trends (last 12 months)
  • Enhanced Activity by Hour: Alternating bar shades for better readability
  • Language Distribution: Color-coded by language using GitHub Linguist colors

3. Interactive Components

  • Mermaid Diagram Playground

    • Support for Flowchart, Mind Map, ER, and C4 diagrams
    • Live editing with instant rendering
    • Dark theme integration
  • Latest Gists Panel

    • Scrollable list of public gists
    • Modal preview with syntax highlighting
    • Direct links to GitHub
  • Daily Brief

    • Supports Markdown and HTML content
    • Collapsible panel
    • Sanitized rendering with DOMPurify
  • Quote of the Day

    • Displays inspirational quotes
    • Configurable source (ZenQuotes or Quotable)

4. Technical Improvements

  • TypeScript Utilities

    • lib/utils/dataClient.ts: Fetch with stale-while-revalidate caching
    • lib/utils/palette.ts: Color management with HSL utilities
  • Chart Components

    • components/charts/DonutChart.tsx
    • components/charts/StackedBarChart.tsx
    • components/charts/ActivityByHourChart.tsx
    • components/charts/LanguageDistribution.tsx
  • Data Files

    • public/data/linguist-colors.json: Language color mappings
    • public/data/.gitkeep: Ensures directory is tracked

Configuration

Set these in GitHub repository settings:

Variables

  • GH_LOGIN: Your GitHub username (e.g., "cywf")
  • DAILY_BRIEF_URL: (Optional) URL to Markdown/HTML file
  • QOTD_SOURCE: (Optional) "zenquotes" (default) or "quotable"

Secrets

  • METRICS_TOKEN: GitHub PAT with scopes:
    • read:user
    • read:gist
    • public_repo

Privacy & Security

Public Data Only: Only public repositories and contributions are displayed ✅ No Tokens in Browser: All API calls are server-side via GitHub Actions ✅ Static Files: Browser only fetches pre-generated JSON files ✅ Content Sanitization: HTML/Markdown is sanitized with DOMPurify ✅ CodeQL Clean: No security vulnerabilities detected

⚠️ CDN Libraries: Mermaid, Marked, and DOMPurify are loaded from CDN for bundle-free setup. For enhanced security in production, consider adding SRI hashes or bundling locally.

Code Quality

  • ✅ Build succeeds with no errors
  • ✅ TypeScript type checking passes
  • ✅ ESLint warnings minimized (only acceptable any types for dynamic data)
  • ✅ Code review feedback addressed:
    • Magic numbers extracted to named constants
    • Cache size limits implemented
    • Modal focus management improved
    • Clear documentation for approximations

Testing

Manual Testing Checklist

  • GitHub Actions workflow runs successfully
  • Metrics JSON files are generated correctly
  • Dashboard displays all new visualizations
  • Donut and stacked bar charts render properly
  • Language colors are applied correctly
  • Mermaid playground renders all diagram types
  • Gists panel shows previews and modal works
  • Daily Brief content renders (if configured)
  • Quote of the Day displays correctly
  • Focus management works in modals (Tab, Shift+Tab, Esc)
  • All links open correctly
  • Mobile responsive design works

Browser Compatibility

  • Chrome/Edge (Chromium-based)
  • Firefox
  • Safari
  • Mobile browsers

Known Limitations

  1. Activity by Hour: Approximated from contribution calendar since GraphQL doesn't provide commit timestamps. Real distribution would require REST API calls.

  2. Monthly Time Series: Uses typical ratios (50% commits, 30% PRs, 20% issues) to split contribution counts since calendar doesn't distinguish between types.

  3. CDN Dependencies: Mermaid, Marked, and DOMPurify are loaded from CDN at runtime. Consider bundling for production.

Future Enhancements

  • Add SRI hashes for CDN scripts
  • Implement actual commit timestamp fetching for accurate hourly distribution
  • Add more diagram types to Mermaid playground
  • Implement client-side search/filter for gists
  • Add export functionality for charts (PNG/SVG)
  • Implement dark/light theme toggle
  • Add animation preferences for reduced motion

Deployment

  1. Ensure all environment variables and secrets are configured
  2. Merge PR to main branch
  3. GitHub Actions will automatically:
    • Run the metrics workflow
    • Build the Next.js site
    • Deploy to GitHub Pages

Documentation

  • DASHBOARD_README.md: Updated with new features, configuration, and privacy notes
  • Inline code comments: Added for clarification of approximations and trade-offs
  • This summary: Comprehensive implementation overview

Metrics

  • Files Created: 19 new files
  • Files Modified: 3 existing files
  • Lines Added: ~2,500
  • Build Size: ~439 KB (main bundle)
  • No Breaking Changes: Existing features preserved

Implementation Date: November 2025 Implemented By: GitHub Copilot Tested On: Node 20.x, Next.js 14.2.15