Add account-bound authentication for analytics requests (#45742)

## What changed

- Add `AnalyticsSession` to load local ChatGPT credentials, bind requests to the initial account and user, and reject identity changes before requests or when accepting results.
- Reload credentials and provide bounded recovery for unauthorized requests, using a backend client that disables redirects.
- Add lazy TUI analytics session initialization, account display metadata, and plan-specific credit groupings for future dashboard integration.

## Testing

Add regression tests for account and user changes, missing or API-key-only authentication, credential reloads, recovery after a `401` response, and session initialization after signing in.

GitOrigin-RevId: 2ba0d96fb44936d12d13aedffc3f2e61aedea560
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-09-15 17:38:43 +00:00
1 parent 7224096b85
commit db078158c3
7 files changed
+452 -1

No files matched your search

+13 -1
View File
@@ -1,4 +1,16 @@
//! Precise signed credit amounts and dates for analytics presentation.
//! Grouping metadata and numeric formatting for account analytics.
use super::models::AccountAnalyticsGrouping as Grouping;
pub(super) const GROUPINGS: [Grouping; 7] = [
Grouping::Surface,
Grouping::Feature,
Grouping::Model,
Grouping::TaskStart,
Grouping::Speed,
Grouping::Reasoning,
Grouping::TokenType,
];
/// Keep tiny refunds visible while avoiding noise on ordinary credit amounts.
pub(super) fn amount(value: f64) -> String {