mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-24 08:19:51 +00:00
feat(telemetry): track API credit top-up success via audit events (#6500)
Summary - Add TelemetryEvents.API_CREDIT_TOPUP_SUCCEEDED and provider method trackApiCreditTopupSucceeded - Introduce topupTrackerStore to persist pending top-ups per user (localStorage) and reconcile against recent audit logs - Hook purchase flow to start tracking before opening Stripe checkout - Reconcile after fetching audit events (UsageLogsTable) and after fetchBalance, then emit telemetry, refresh balance, and clear pending - Minor refactor in customerEventsService to return awaited result Implementation details - Matching strategy: - Event type: credit_added - Time window: createdAt between top-up start time and +24h - Amount: if known, e.params.amount must equal expected cents - Cross-tab/user changes: synchronize via storage event and userId watcher Limitations / Follow-up - Reconciliation fetches only page 1 (limit 10) of events; in high-volume cases, a recent credit_added could fall outside the first page - The window and pagination issue will be "resolved by a followup PR to core and cloud" Files touched - src/stores/topupTrackerStore.ts (new) - src/components/dialog/content/setting/UsageLogsTable.vue - src/composables/auth/useFirebaseAuthActions.ts - src/platform/telemetry/providers/cloud/MixpanelTelemetryProvider.ts - src/platform/telemetry/types.ts - src/services/customerEventsService.ts ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6500-feat-telemetry-track-API-credit-top-up-success-via-audit-events-29e6d73d365081169941efae70cf71fe) by [Unito](https://www.unito.io) --------- Co-authored-by: Christian Byrne <chrbyrne96@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import type { ErrorRecoveryStrategy } from '@/composables/useErrorHandling'
|
||||
import { t } from '@/i18n'
|
||||
import { isCloud } from '@/platform/distribution/types'
|
||||
import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription'
|
||||
import { useTelemetry } from '@/platform/telemetry'
|
||||
import { useToastStore } from '@/platform/updates/common/toastStore'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
|
||||
@@ -99,7 +100,7 @@ export const useFirebaseAuthActions = () => {
|
||||
)
|
||||
}
|
||||
|
||||
// Go to Stripe checkout page
|
||||
useTelemetry()?.startTopupTracking()
|
||||
window.open(response.checkout_url, '_blank')
|
||||
}, reportError)
|
||||
|
||||
@@ -116,7 +117,9 @@ export const useFirebaseAuthActions = () => {
|
||||
}, reportError)
|
||||
|
||||
const fetchBalance = wrapWithErrorHandlingAsync(async () => {
|
||||
return await authStore.fetchBalance()
|
||||
const result = await authStore.fetchBalance()
|
||||
// Top-up completion tracking happens in UsageLogsTable when events are fetched
|
||||
return result
|
||||
}, reportError)
|
||||
|
||||
const signInWithGoogle = wrapWithErrorHandlingAsync(async () => {
|
||||
|
||||
Reference in New Issue
Block a user