Migrate GA Syncing to GitHub Action

The goal is to move the Google Analytics (GA) syncing logic, which currently runs as an Inngest cron job, to a standalone script triggered by a GitHub Action. This will simplify the Inngest setup and provide more visible execution logs in GitHub Actions.

Proposed Changes

Scripts

[NEW] sync-ga-views.ts

A new TypeScript script that:

  • Initializes the Prisma client.
  • Fetches GA stats using the existing getDailyPageViews utility.
  • Updates the SiteStat table in the database for all sites.
  • Environment variables will be provided via the environment (e.g., GitHub Secrets in CI).

Inngest

[MODIFY] functions.ts

  • Remove the syncGAStats Inngest function.

GitHub Actions

[NEW] sync-ga-views.yml

  • A new workflow scheduled to run daily (e.g., at 2 AM).
  • Supports workflow_dispatch for manual triggering.
  • Configures necessary secrets: POSTGRES_PRISMA_URL, POSTGRES_URL_NON_POOLING, GA_PROPERTY_ID, GA_CLIENT_EMAIL, GA_PRIVATE_KEY, NEXT_PUBLIC_ROOT_DOMAIN.

Verification Plan

Automated Tests

  • Run the script locally using ts-node -r dotenv/config scripts/sync-ga-views.ts (manually triggered).
  • Check the database if SiteStat records are updated for yesterday.

Manual Verification

  • Verify the GitHub Action is correctly triggered and succeeds after deployment.