ReviewOS

also looking at this

stacks/postline

Sync Bluesky engagement metrics into analytics

#12
Merged glennmichael123 wants to merge feat/metrics-sync into main
10 files +200 -4
9 days ago

Summary

Analytics now shows real engagement, closing the "publish counts only" gap.

  • Driver: postMetrics() fetches like/repost/reply counts via app.bsky.feed.getPosts (25 URIs per call; deleted posts skipped)
  • Service: syncMetrics() batches the ~100 most recent published Bluesky targets and stores counts in post_targets.metrics with a sync timestamp
  • Scheduling: SyncEngagementMetrics job every 30 minutes (silently no-ops when no account is connected), plus POST /postline/metrics/sync (auth) for on-demand refresh
  • Analytics: new Engagement stat card — total interactions with a likes/reposts/replies breakdown; stat grid goes 4-up. The best-window histogram switches to created_at since metric syncs bump updated_at and would have skewed it.

Verification

  • bun test — 15 pass (2 new: getPosts query/count mapping incl. deleted-post absence; empty-input short-circuit)
  • Live: seeded metrics aggregate correctly through the API (523 likes · 62 reposts · 36 replies across 3 synced targets) and render on the page while authenticated; the sync endpoint fails cleanly without Bluesky credentials
  • pickier clean, tsc --noEmit exit 0

10 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.