Repository navigation
Closed
Description
Background
PR #5863 added record_usage(uid, transcription_seconds=...) to sync-local-files so that basic-plan users' DG transcription time counted toward their monthly limit (BASIC_TIER_MINUTES_LIMIT_PER_MONTH).
PR #5875 reverted #5863 entirely. PR #5878 re-added the fair_use gates (soft caps, DG budget, is_hard_restricted, should_lock) but did not re-add record_usage.
Impact
has_transcription_credits(uid)atsync.py:1100checkstranscription_secondsfrom Firestorehourly_usage- But sync endpoints never call
record_usage()to increment that counter — onlytranscribe.py(streaming) writes to it - Result: sync-local-file usage is invisible to the subscription credit system
- Example: SYNC#9 user on basic plan (80-hour limit on backend-sync) used ~309 hours in April with no throttling
Task 1: Add record_usage to sync endpoints
Add record_usage(uid, transcription_seconds=int(total_speech_seconds), speech_seconds=int(total_speech_seconds)) after successful segment processing in:
- v1
sync_local_files()— after line 1225 (afterrecord_dg_usage_msblock) - v2
_sync_v2_background_worker()— equivalent location after DG usage recording
Code ref: the original call was in #5863 (f592c25b1):
from utils.analytics import record_usage
# after processing:
if total_speech_seconds > 0:
record_usage(uid, transcription_seconds=total_speech_seconds, speech_seconds=total_speech_seconds)Task 2: Deprecate/remove v1 sync-local-files
Check whether the mobile app (Flutter) and desktop (macOS) clients still use POST /v1/sync-local-files:
- Search app code for
/v1/sync-local-filesusage - Search desktop code for
/v1/sync-local-filesusage - If no clients use v1, remove the endpoint entirely
- If some clients still use v1, add deprecation logging and plan removal with a minimum app version gate
Related
- Parent issue: Pusher WS connection leak: gauge never decremented, per-connection state leaked #7071 (pusher WS connection leak / OOM)
- Fair-use PRs: Sync: fair-use tracking with lock-on-exhaustion and soft cap gates #5863 (original), Revert "Sync: fair-use tracking with lock-on-exhaustion and soft cap gates" #5875 (revert), Sync: fair-use gates with lock-on-exhaustion (v2, clean) #5878 (re-add without record_usage), Fix fair-use enforcement for free-tier users with exhausted credits #6084 (extend)
- Prod config:
BASIC_TIER_MINUTES_LIMIT_PER_MONTH=4800on backend-sync,FAIR_USE_ENABLED=true
Metadata
Metadata
Assignees
Labels
No labels
Activity
fix(sync): add missing record_usage to sync endpoints + deprecate v1 (B…