Analytics overview
The Analytics page at/analytics is the central hub for performance data. It aggregates metrics across all connected platforms into a single dashboard.
Overview
Total reach, engagement, follower counts, and best-performing platform for the selected period.
Timeline
Day-by-day engagement metrics charted over 7 or 30 days, with optional platform filtering.
Growth
Follower count changes over time, broken down per platform.
Top posts
Your highest-performing posts ranked by engagement, reach, or likes.
Platform performance
Side-by-side comparison of engagement totals across all platforms.
Heatmap
A day-of-week / hour-of-day grid showing when your audience is most active.
Period filter
All analytics endpoints accept aperiod query parameter:
| Value | Description |
|---|---|
7d | Last 7 days. |
30d (default) | Last 30 days. |
start and end timestamps from this value and passes them to the repository layer for aggregation.
API endpoints
Overview
GET /api/analytics/overview
Returns aggregated stats for the period: total posts, total engagement, best platform, total and per-platform follower counts.
200 response
Timeline
GET /api/analytics/timeline
Returns daily engagement data for chart rendering. Optionally filtered by platform.
Growth
GET /api/analytics/growth
Returns follower count snapshots over time, useful for plotting a growth curve.
Top posts
GET /api/analytics/posts/top
Returns your best-performing posts. Supports limit, sortBy, and platform query parameters.
| Parameter | Default | Description |
|---|---|---|
limit | 5 | Number of posts to return. |
sortBy | totalEngagement | Metric to rank by. |
platform | — | Filter to a single platform. |
Platform performance
GET /api/analytics/platforms
Returns per-platform engagement totals and post counts for the selected period, sorted by total engagement descending. The first entry in the array is used as bestPlatform in the overview.
Heatmap
GET /api/analytics/heatmap
Returns a grid of engagement values indexed by day-of-week and hour-of-day. Use this to identify the optimal time windows for your audience.
Manual analytics refresh
You can trigger an on-demand analytics fetch for a specific post and platform:POST /api/analytics/posts/:postId/refresh?platform=<platform>
- Verifies you own the post.
- Sends a
{ type: "post", postId, platform }message to the analytics queue. - Waits approximately 5 seconds for the worker to complete.
- Returns the latest analytics snapshot.
How analytics are collected automatically
Hayon runs a background cron job that periodically enqueues analytics fetch tasks for recently published posts. TheAnalyticsWorker processes these messages and stores snapshots in MongoDB.
Cron job triggers
A scheduler enqueues
{ type: "post", postId, platform } messages for all recently published posts and { type: "account", userId, platforms } messages for follower counts.Worker picks up the message
AnalyticsWorker.processMessage() reads the message type and routes to processPostAnalytics or processAccountAnalytics.Platform API is called
The worker fetches the
platformPostId from the post’s platformStatuses, then calls the platform-specific analytics service (getAnalyticsService(platform)) to retrieve live metrics.Snapshot is saved
A new snapshot document is written to MongoDB with the following metrics:
| Metric | Description |
|---|---|
likes | Like/heart count. |
shares | Reposts, retweets, or boosts. |
comments | Reply count. |
impressions | Times the post was displayed. |
reach | Unique accounts that saw the post. |
saved | Times the post was saved/bookmarked. |
totalEngagement | likes + shares + comments (derived). |
engagementRate | totalEngagement / followerCount (derived). |
virality | shares / totalEngagement when shares > 0 (derived). |
followerCountAtSnapshot | Follower count at the time of the fetch. |
Error handling
The analytics worker handles two special error types from platform APIs:Post deleted on platform
Post deleted on platform
If the platform returns a
DELETED error, the worker marks the platformStatus as deleted and stops processing that post. No further analytics fetches are attempted.Authorization failure
Authorization failure
Transient errors
Transient errors
For other errors (network issues, temporary API failures), the worker NACKs the message without requeue, routing it to the dead-letter exchange to avoid infinite loops.
Platform support
Not all platforms expose analytics APIs. Support is implemented selectively:| Platform | Post metrics | Account metrics |
|---|---|---|
| Bluesky | Planned | Planned |
| Mastodon | Partial | Partial |
| Roadmap | Roadmap | |
| Roadmap | Roadmap | |
| Threads | Roadmap | Roadmap |
| Tumblr | Roadmap | Roadmap |
Platforms where analytics are not yet implemented are detected by the worker and silently skipped with a log message. No error is returned to the user.
