ewega opened a new pull request, #8965:
URL: https://github.com/apache/devlake/pull/8965

   ## Summary
   
   Resolves #8961. Adds first-class GitHub Copilot **AI credit billing 
consumption** ingestion to the `gh-copilot` plugin and surfaces 
credit-consumption KPIs on the GitHub Copilot Adoption dashboard.
   
   The change is **purely additive** — there were no existing 
premium-request-unit (PRU) references anywhere in the plugin, grafana, or 
config-ui to retire, so nothing was removed.
   
   ## What's included
   
   **Ingestion**
   - New tool-layer model `_tool_copilot_ai_credit_usage` 
(`GhCopilotAiCreditUsage`) with migration 
`20260701_add_copilot_ai_credit_usage` and `GetTablesInfo()` registration.
   - Daily collectors + extractors for the GitHub Billing Usage AI credit 
endpoints (API version `2026-03-10`):
     - Enterprise: `GET 
/enterprises/{enterprise}/settings/billing/ai_credit/usage`
     - Organization: `GET 
/organizations/{org}/settings/billing/ai_credit/usage` (note `organizations/`, 
not `orgs/`)
   - Reuses the existing stateful daily-iterator pattern (day-by-day 
`year`/`month`/`day`, 365-day clamp, `Retry-After` backoff, `ignoreNoContent`). 
Each `usageItem` (product/sku/model/unitType) is exploded into one row; 
gross/net quantity and amount stored as `float64`.
   - 4 new subtask metas wired into `register.go` / `subtasks.go` (collect + 
extract × enterprise/org).
   
   **Dashboard**
   - New collapsible **"AI Credit Consumption"** row added to both `mysql` and 
`postgresql` `github-copilot-adoption.json`:
     - Stat panels: total gross credits, net credits, net amount, gross amount
     - Time series: gross vs net credits consumed over time
     - Tables: credits by model, and by product / SKU (with amount)
   - Per-dialect SQL (MySQL backticks / `connection_id = ${connection_id}`; 
Postgres double-quoted identifiers, `connection_id::text` guard, `NULLS LAST`).
   
   **Tests & docs**
   - e2e raw + snapshot fixtures and an extended `metrics_test.go` exercising 
the org AI-credit extractor.
   - Unit tests for `splitDay` and the pure `mapAiCreditUsageReport` mapping.
   - Updated plugin `README.md` and dashboard `GithubCopilotREADME.md` (new 
subtasks, table, required billing permissions: `manage_billing:copilot` / 
`admin:enterprise` / `admin:org`, credit terminology).
   
   ## Verification
   - `go build ./plugins/gh-copilot/...` ✅
   - `go vet ./plugins/gh-copilot/...` ✅
   - `gofmt -l` clean ✅
   - `go test ./plugins/gh-copilot/tasks/...` ✅
   
   > Note: `backend/plugins/table_info_test.go` requires generated mocks (`make 
mock`) to run in a fresh checkout — a pre-existing environment dependency 
unrelated to this change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to