post-analytics
Sync post-level analytics from Late API into the database. Pulls performance metrics for each published post (impressions, reach, likes, comments, shares, saves, views, engagement rate) and stores per-platform breakdowns into the platform-specific stats tables.
Usage
node skills/post-analytics/scripts/post-analytics.js [options]
Options
| Flag |
Description |
Default |
--post-id |
Specific Late post ID to sync |
All recent posts |
--limit |
Max posts to sync |
20 |
--dry-run |
Show analytics without DB writes |
false |
What It Does
- Fetches all published posts from Late API (or a specific post)
- For each post, calls
GET /v1/analytics?postId= to get per-platform metrics
- Updates
platform_posts with post URLs and sync status
- Upserts per-platform stats into
instagram_posts_stats, tiktok_posts_stats, youtube_posts_stats, facebook_posts_stats, twitter_posts_stats
- Updates
user_posts with aggregate analytics in metadata
Prerequisites
LATE_API_KEY in .env
INSFORGE_CONNECTION_STRING in .env
DB Tables Written
platform_posts — post_url, raw_response updated
instagram_posts_stats — impressions, reach, likes, comments, saves, shares, video_views
tiktok_posts_stats — views, likes, comments, shares, saves
youtube_posts_stats — views, likes, comments, shares, impressions
facebook_posts_stats — impressions, reach, likes, shares, comments
twitter_posts_stats — impressions, likes, retweets (shares), replies (comments)
user_posts — metadata.analytics updated with aggregate totals
1---2name: post-analytics3description: post-analytics4---5# post-analytics67Sync post-level analytics from Late API into the database. Pulls performance metrics for each published post (impressions, reach, likes, comments, shares, saves, views, engagement rate) and stores per-platform breakdowns into the platform-specific stats tables.89## Usage1011```bash12node skills/post-analytics/scripts/post-analytics.js [options]13```1415## Options1617| Flag | Description | Default |18|------|-------------|---------|19| `--post-id` | Specific Late post ID to sync | All recent posts |20| `--limit` | Max posts to sync | 20 |21| `--dry-run` | Show analytics without DB writes | false |2223## What It Does24251. Fetches all published posts from Late API (or a specific post)262. For each post, calls `GET /v1/analytics?postId=` to get per-platform metrics273. Updates `platform_posts` with post URLs and sync status284. Upserts per-platform stats into `instagram_posts_stats`, `tiktok_posts_stats`, `youtube_posts_stats`, `facebook_posts_stats`, `twitter_posts_stats`295. Updates `user_posts` with aggregate analytics in metadata3031## Prerequisites3233- `LATE_API_KEY` in `.env`34- `INSFORGE_CONNECTION_STRING` in `.env`3536## DB Tables Written3738- `platform_posts` — post_url, raw_response updated39- `instagram_posts_stats` — impressions, reach, likes, comments, saves, shares, video_views40- `tiktok_posts_stats` — views, likes, comments, shares, saves41- `youtube_posts_stats` — views, likes, comments, shares, impressions42- `facebook_posts_stats` — impressions, reach, likes, shares, comments43- `twitter_posts_stats` — impressions, likes, retweets (shares), replies (comments)44- `user_posts` — metadata.analytics updated with aggregate totals