Skip to content

Add report usage metrics helper#136

Merged
asizikov merged 1 commit into
mainfrom
asizikov/report-usage-metrics
Jun 5, 2026
Merged

Add report usage metrics helper#136
asizikov merged 1 commit into
mainfrom
asizikov/report-usage-metrics

Conversation

@asizikov

@asizikov asizikov commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

Native AI Credits aggregation needs a canonical metrics shape before it can be wired into the live pipeline. This PR adds that preparation layer in isolation so production uploads and existing aggregators keep their current behavior.

Changes

Commit Change
feat: add report usage metrics helper Adds a format-aware getReportUsageMetrics() helper that keeps transition-period PRU comparison metrics separate from canonical AI Credits metrics, and maps native AI Credits rows from native quantity/gross/discount/net fields without PRU comparison metrics.
  • Defines CanonicalAiCreditsMetrics, TransitionPeriodComparisonMetrics, and ReportUsageMetrics.
  • Keeps transition-period reports on the existing getUsageMetrics() semantics.
  • Leaves runPipeline, App, and existing aggregators unwired so native AI Credits uploads remain unsupported for now.
  • Adds focused tests for transition-period rows, native rows, null native comparison metrics, and alias fallback consistency.

Testing

  • npm test -- --run --reporter=dot
  • npm run lint -- --quiet
  • npm run build

Checklist

  • Specs lint passes (npm run lint)
  • Tests updated if applicable
  • Documentation updated if applicable (N/A: no user-facing docs changed)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 5, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a small, format-aware helper in the pipeline layer to normalize per-row “usage metrics” into a canonical AI Credits shape, while preserving the existing transition-period PRU comparison metrics behavior. This provides a stable metrics contract for future native AI Credits pipeline wiring without changing current pipeline behavior.

Changes:

  • Introduces getReportUsageMetrics() that returns canonical AI Credits metrics for both transition-period and native AI Credits formats.
  • Keeps transition-period behavior aligned with existing getUsageMetrics() semantics (including PRU comparison metrics).
  • Adds unit tests covering transition-period rows, native rows, and alias-column fallback behavior.
Show a summary per file
File Description
src/pipeline/reportUsageMetrics.ts Adds the getReportUsageMetrics() helper and canonical/transition metrics types keyed by report format.
src/pipeline/reportUsageMetrics.test.ts Adds focused tests validating transition-period vs native AI Credits mapping and null comparison metrics for native format.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@asizikov asizikov merged commit d67740d into main Jun 5, 2026
10 checks passed
@asizikov asizikov deleted the asizikov/report-usage-metrics branch June 5, 2026 14:30
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