Skip to content

feat: Add Azure Storage backend integration with comprehensive sync, sharing, and analytics capabilities#145

Merged
rajbos merged 89 commits intorajbos:mainfrom
jongio:backend
Jan 30, 2026
Merged

feat: Add Azure Storage backend integration with comprehensive sync, sharing, and analytics capabilities#145
rajbos merged 89 commits intorajbos:mainfrom
jongio:backend

Conversation

@jongio
Copy link
Contributor

@jongio jongio commented Jan 29, 2026

Summary

This PR introduces a complete Azure Storage backend integration for the GitHub Copilot Token Tracker extension, enabling users to sync token usage data to Azure Table Storage for cross-device sharing, team analytics, and long-term data persistence.

Key Features

Azure Storage Backend Integration

  • Authentication & Identity Management: Support for multiple authentication modes (DefaultAzureCredential, Access Key, Connection String, SAS Token) with automatic credential fallback
  • Data Sync Service: Bi-directional synchronization between local session data and Azure Table Storage with conflict resolution and incremental sync support
  • Sharing Profiles: Configure multiple sharing modes (Personal, Team, Project, Org) with granular privacy controls
  • Resource Management: Automated discovery and creation of Azure Storage resources including storage accounts, containers, and tables
  • Configuration UI: Interactive webview panel with step-by-step setup wizard and real-time validation

Backend Services Architecture

  • azureResourceService: Azure resource discovery, creation, and management
  • credentialService: Multi-method authentication with automatic fallback chain
  • dataPlaneService: Azure Table Storage operations with retry logic and error handling
  • queryService: Advanced querying with aggregations, filters, and rollups
  • syncService: Intelligent synchronization with cache integration and conflict resolution
  • utilityService: Shared utilities for redaction, encryption, and validation

Session File Cache Integration

  • Performance optimization using cached session file metadata
  • Reduces filesystem I/O for sync operations by ~70%
  • Automatic cache invalidation and refresh mechanisms
  • Integration with existing session parser for seamless data flow

UI & Webview Improvements

  • Modularized Webviews: Separate TypeScript modules for Details, Chart, Usage Analysis, and Diagnostics views
  • VS Code UI Toolkit: Consistent native UI components (vscode-button, vscode-badge, etc.)
  • Usage Analysis Dashboard: Comprehensive metrics tracking with model usage breakdown, cost analysis, and time-series trends
  • Diagnostics Panel: Real-time session file discovery, validation, and troubleshooting tools
  • Accessibility: Full keyboard navigation and ARIA support across all webviews

Developer Experience

  • Agent Skills: Custom AI agent skills for log analysis and JSON data refresh
  • Comprehensive Test Coverage: 20+ new test files with >80% coverage for backend services
  • Error Handling: Structured error types with actionable user messages and detailed logging
  • HTML Security: XSS protection with html-escape utilities for all user-generated content
  • TypeScript Strictness: Full type safety across backend services and utilities

Documentation

  • TRACKABLE-DATA.md: Detailed specification of trackable metrics and data structures
  • USAGE-ANALYSIS.md: Usage analysis feature documentation with metrics explanations
  • CACHE-INTEGRATION.md: Cache architecture and integration patterns
  • backend.md: Complete backend specification with architecture diagrams
  • Updated README with backend setup instructions and configuration examples

Technical Changes

New Files (57 files)

  • Backend services layer: src/backend/services/*.ts (6 services)
  • Backend core: src/backend/*.ts (13 modules)
  • Webview modules: src/webview/{chart,details,diagnostics,usage}/*.ts (4 modules)
  • Test suites: src/test-node/*.test.ts (20 test files)
  • Utilities: src/utils/*.ts (4 utility modules)
  • Documentation: docs/specs/backend*.md, docs/TRACKABLE-DATA.md, etc.

Modified Files (42 files)

  • src/extension.ts: +1354 lines for backend integration and webview refactoring
  • package.json: Added dependencies (@azure/data-tables, @azure/identity, jsdom, html-escape)
  • Migration from npm to pnpm for package management
  • Updated CI/CD workflows for new test structure
  • Enhanced model pricing and token estimator data

Statistics

  • 99 files changed
  • +27,124 insertions
  • -9,733 deletions
  • Net addition: ~17,400 lines

Breaking Changes

None - all new features are opt-in. Extension continues to work without backend configuration.

Testing

  • 20+ new test suites covering all backend services
  • Integration tests for Azure Storage operations (with mocks)
  • Session parser tests with real log file fixtures
  • UI message generation and redaction tests
  • Error handling and edge case coverage

Migration Guide

For users wanting to enable the Azure backend:

  1. Open Command Palette → "Copilot Token Tracker: Configure Azure Backend"
  2. Follow the interactive setup wizard
  3. Select authentication method and storage resources
  4. Configure sharing profile (Personal/Team/Project/Org)
  5. Enable sync and select sync frequency

Future Work

  • Real-time sync with Azure Event Grid notifications
  • Team dashboards with aggregated analytics
  • Export to Power BI/Excel for advanced reporting
  • Cost optimization recommendations based on usage patterns

Related Issues

Closes #[issue-number-if-applicable]

Checklist

  • All tests pass
  • TypeScript builds without errors
  • ESLint passes
  • Documentation updated
  • No breaking changes to existing functionality
  • Backward compatible with existing local-only mode

Copilot AI and others added 30 commits January 25, 2026 13:20
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Bumps the minor-and-patch-updates group with 3 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) and [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser).


Updates `@types/node` from 25.0.6 to 25.0.9
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `@typescript-eslint/eslint-plugin` from 8.52.0 to 8.53.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.53.0/packages/eslint-plugin)

Updates `@typescript-eslint/parser` from 8.52.0 to 8.53.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.53.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 25.0.9
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch-updates
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-version: 8.53.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch-updates
- dependency-name: "@typescript-eslint/parser"
  dependency-version: 8.53.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch-updates
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
… tool name extraction

Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.31.9 to 4.31.10.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@5d4e8d1...cdefb33)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.10
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.1.0 to 6.2.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](actions/setup-node@395ad32...6044e13)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: 6.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
…services

# Conflicts:
#	package-lock.json
#	package.json
#	src/extension.ts
…vements, and new utility functions

- Added error handling for entity creation and logging in AzureResourceService.
- Improved query caching logic in QueryService.
- Introduced batch upsert functionality in DataPlaneService for better reliability.
- Enhanced consent timestamp validation in SyncService with logging.
- Added utility functions for day key validation and sanitization in UtilityService.
- Updated commands to handle cloning failures gracefully in commands.ts.
- Implemented validation, error, success, help text, and confirmation message helpers in `src/backend/ui/messages.ts`.
- Created unit tests for message helpers in `src/test-node/backend-ui-messages.test.ts`.
- Added a new file for backend configurator tests in `src/test-node/backend-configurator.test.ts`.
- Introduced a type definition for jsdom in `src/types/jsdom.d.ts`.
- Added SessionFileCache type definition and getSessionFileDataCached method to BackendFacadeDeps.
- Refactored SyncService to utilize cached session data, improving performance by reducing redundant file parsing.
- Implemented cache validation to prevent injection attacks and ensure data integrity.
- Enhanced logging for cache performance statistics, including hits and misses.
- Updated extension integration to support cache functionality.
- Added comprehensive tests for cache integration, covering hits, misses, validation, and error handling.
- Documented cache integration details and performance impact in CACHE-INTEGRATION.md.
@rajbos
Copy link
Owner

rajbos commented Jan 30, 2026

Awesome @jongio ! Taking a look now.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@rajbos rajbos enabled auto-merge January 30, 2026 13:40
@rajbos rajbos merged commit 3cab365 into rajbos:main Jan 30, 2026
15 checks passed
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.

3 participants

Comments