Daily cloud analytics implementation plan

For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.

Goal: Refresh tracked analytics data daily in GitHub and generate the existing summary weekly, without relying on Rufus's Mac.

Architecture: A scheduled GitHub Actions workflow reads a dedicated encrypted analytics env file from rufuspollock/secrets using a read-only deploy key. Only that file's dotenvx decryption key is available to this workflow. The existing Python pull reads cloud credentials from environment variables, refreshes a rolling 14-day window, and commits changed data; a summary for the most recent Wednesday is refreshed on each successful run so missed runs catch up.

Tech Stack: GitHub Actions, Python 3 stdlib, dotenvx, git.


Task 1: Make the pull fail when a source fails

Files: scripts/analytics_pull.py, tests/test_analytics_pull.py

  1. Write a unittest with one configured source and a missing credential, asserting main() returns nonzero and records the problem.
  2. Run python3 -m unittest tests.test_analytics_pull -v and confirm the assertion fails.
  3. Return nonzero if problems is nonempty, preserving the status file and diagnostic output.
  4. Re-run the unittest and confirm it passes.

Task 2: Read dedicated analytics secrets in cloud

Files: scripts/analytics_pull.py, tests/test_analytics_pull.py, rufuspollock/secrets/.env.analytics

  1. Add a test showing a Google ADC JSON environment variable, Umami key, and Twenty key can be used without local credential files; preserve local file fallback.
  2. Verify the test fails, add the smallest env credential lookup, then verify it passes.
  3. Create .env.analytics with a separate .env.analytics.keys, containing only three Google ADC JSON credentials and the Umami/Twenty keys; commit the encrypted file in the secrets repo and keep its key untracked.
  4. Check .env.analytics contains encrypted values only and a distinct public key.

Task 3: Schedule and write back data

Files: .github/workflows/analytics.yml, data/analytics/SETUP.md, data/analytics/README.md, BRIEFING.md

  1. Add a daily schedule plus manual dispatch. Check out marketing and the secrets repo using a read-only deploy key, install dotenvx, run the pull under the dedicated env file, and refresh the most recent Wednesday summary.
  2. Commit only changed data/analytics/daily.csv, top-sources.csv, last-pull.json, and that week's Wednesday summary. Grant the job contents: write; serialize runs with a concurrency group.
  3. Document credential provisioning, schedule, failure visibility, and local fallback. Retire the local launchd schedule after a successful manual cloud run.

Task 4: Provision and verify

  1. Add a read-only deploy key to rufuspollock/secrets; set its private half and the dedicated dotenvx key as GitHub Actions secrets on life-itself/marketing, without printing either.
  2. Run unit tests, a local dry run with the dedicated dotenvx file, and a workflow syntax check.
  3. Commit and push the two repos, trigger workflow_dispatch, inspect its logs and resulting data commit, then unload the local launchd pull.
  4. Update Beads and confirm both repos are clean and synced.
Built with LogoFlowershow