Add report usage metrics helper#136
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
feat: add report usage metrics helpergetReportUsageMetrics()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.CanonicalAiCreditsMetrics,TransitionPeriodComparisonMetrics, andReportUsageMetrics.getUsageMetrics()semantics.runPipeline, App, and existing aggregators unwired so native AI Credits uploads remain unsupported for now.Testing
npm test -- --run --reporter=dotnpm run lint -- --quietnpm run buildChecklist
npm run lint)