# Google Sheets Integration

Influtics connects to Google Sheets bidirectionally — import video URLs for tracking, and export analytics back to the sheet automatically.


# How It Works

  1. User connects their Google account via OAuth
  2. User selects a worksheet containing video URLs
  3. System imports all URLs, creates/links video records
  4. Analytics are exported back to a target sheet (same or different)
  5. Every 4 hours, a cron job resyncs all connected worksheets automatically

# Sync States

Each integration tracks its current state to prevent concurrent operations:

State Description
idle No sync in progress — import/export allowed
importing Import batches running — returns 409 if new sync attempted
exporting Export running — returns 409 if new sync attempted
sync_failed Previous sync failed — new syncs allowed

Integrations stuck in importing or exporting for > 2 hours are automatically reset to idle by the resync scheduler.


# Section Contents

  • Architecture — Full bidirectional sync flow
  • Connect — OAuth setup and token refresh
  • Import — Sheets → DB (worksheet processing)
  • Export — DB → Sheets (analytics write-back)
  • Resync — Scheduled 4-hour resync
  • Workers — All workers involved
  • Queues — Queue message shapes
  • API — All /google/sheets/* endpoints