feat(billing): add usage increment API + wire hand/pipeline execution tracking
Server side: - POST /api/v1/billing/usage/increment endpoint with dimension whitelist (hand_executions, pipeline_runs, relay_requests) and count validation (1-100) - Returns updated usage quota after increment Desktop side: - New saas-billing.ts mixin with incrementUsageDimension() and reportUsageFireAndForget() (non-blocking, safe for finally blocks) - handStore.triggerHand: reports hand_executions after successful run - PipelinesPanel.handleRunComplete: reports pipeline_runs on completion - SaaSClient type declarations for new billing methods Billing pipeline now covers all three dimensions: relay_requests → relay handler (server-side, real-time) hand_executions → handStore (client-side, fire-and-forget) pipeline_runs → PipelinesPanel (client-side, fire-and-forget)
This commit is contained in:
@@ -29,6 +29,7 @@ import {
|
||||
formatInputType,
|
||||
} from '../lib/pipeline-client';
|
||||
import { useToast } from './ui/Toast';
|
||||
import { saasClient } from '../lib/saas-client';
|
||||
|
||||
// === Category Badge Component ===
|
||||
|
||||
@@ -431,6 +432,13 @@ export function PipelinesPanel() {
|
||||
if (result.status === 'completed') {
|
||||
toast('Pipeline 执行完成', 'success');
|
||||
setRunResult({ result, pipeline: selectedPipeline! });
|
||||
|
||||
// Report pipeline execution to billing (fire-and-forget)
|
||||
try {
|
||||
if (saasClient.isAuthenticated()) {
|
||||
saasClient.reportUsageFireAndForget('pipeline_runs');
|
||||
}
|
||||
} catch { /* billing reporting must never block */ }
|
||||
} else {
|
||||
toast(`Pipeline 执行失败: ${result.error}`, 'error');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user