Skip to content

fix(facebook): use live post insight metrics and read Reels from /video_insights - #320

Open
maciejdzierzek wants to merge 1 commit into
trypostit:mainfrom
maciejdzierzek:fix/facebook-post-metrics
Open

fix(facebook): use live post insight metrics and read Reels from /video_insights#320
maciejdzierzek wants to merge 1 commit into
trypostit:mainfrom
maciejdzierzek:fix/facebook-post-metrics

Conversation

@maciejdzierzek

Copy link
Copy Markdown

Facebook posts currently return no metrics, for two independent reasons in Graph API v25. Companion to #319 (same problem class on Instagram).

1. Feed posts ask for retired metrics

post_impressions and post_impressions_unique were retired. A retired name does not get skipped — it fails the whole request, so the other metrics in the same call (post_reactions_like_total, post_clicks) never arrive either.

Current equivalents:

retired current
post_impressions post_media_view
post_impressions_unique post_total_media_view_unique

2. Facebook Reels have no /insights edge

Every Reel errored out, because Reels expose their metrics on /video_insights instead. Called without a metric parameter that edge returns a sensible default set (blue_reels_play_count, post_impressions_unique, post_video_avg_time_watched, and others), which is what this PR reads.

Reaction counts there come back as a dictionary keyed by reaction type, so those values are summed into a single number.

Labels

The raw v25 metric names do not survive ucfirst(str_replace(...))post_total_media_view_unique renders as "Post total media view unique". This maps them to the same vocabulary the other analytics services already use: Reach / Views / Likes / Clicks, plus Plays / Replays / Avg watch time for Reels.

How I verified

Probed both edges against live Business assets on v25. Calling the insights edge without a metric parameter returns the default set, and passing a retired name returns an error listing the permitted metrics — that is how the replacement names above were established rather than guessed.

Running in production since 2026-08-04. Before: every Facebook post reported an API error. After: reach and views populate for both feed posts and Reels.

…eo_insights

Two separate breakages in Graph API v25:

1. Feed posts asked for the retired `post_impressions` / `post_impressions_unique`
   pair. Including a retired metric fails the whole request, so no metrics came
   back at all. Replaced with the current names: `post_media_view` (views) and
   `post_total_media_view_unique` (reach).

2. Facebook Reels have no /insights edge at all, so every Reel returned an error.
   Their metrics live on /video_insights, which returns a sensible default set
   when called without a `metric` parameter.

Also maps raw metric names to the same readable labels the other analytics
services use (Reach / Views / Likes / Clicks), instead of ucfirst() on the raw
Graph key - the new names do not read well otherwise ("Post total media view
unique").

Reel reaction counts arrive as a dictionary keyed by reaction type, so those
values are summed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant