Daily cloud analytics implementation plan
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
- Write a unittest with one configured source and a missing credential, asserting
main()returns nonzero and records the problem. - Run
python3 -m unittest tests.test_analytics_pull -vand confirm the assertion fails. - Return nonzero if
problemsis nonempty, preserving the status file and diagnostic output. - 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
- 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.
- Verify the test fails, add the smallest env credential lookup, then verify it passes.
- Create
.env.analyticswith 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. - Check
.env.analyticscontains 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
- 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.
- Commit only changed
data/analytics/daily.csv,top-sources.csv,last-pull.json, and that week's Wednesday summary. Grant the jobcontents: write; serialize runs with a concurrency group. - 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
- Add a read-only deploy key to
rufuspollock/secrets; set its private half and the dedicated dotenvx key as GitHub Actions secrets onlife-itself/marketing, without printing either. - Run unit tests, a local dry run with the dedicated dotenvx file, and a workflow syntax check.
- Commit and push the two repos, trigger
workflow_dispatch, inspect its logs and resulting data commit, then unload the local launchd pull. - Update Beads and confirm both repos are clean and synced.