Skip to content

fix(youtube): fetch the real subscriber total independent of Analytics lag - #150

Closed
murtaja1 wants to merge 1 commit into
brightbeanxyz:mainfrom
Murtaja-Adnan:upstream/youtube-subscriber-total
Closed

fix(youtube): fetch the real subscriber total independent of Analytics lag#150
murtaja1 wants to merge 1 commit into
brightbeanxyz:mainfrom
Murtaja-Adnan:upstream/youtube-subscriber-total

Conversation

@murtaja1

Copy link
Copy Markdown

get_account_metrics only called the Analytics /reports endpoint, so a channel with no activity yet today (Analytics lags 1-2 days and returns empty rows) reported followers=0 instead of its real subscriber count -- and any /reports failure lost the total too, since the whole call had nothing else to fall back on. Hit this in production on a low-activity channel.

Fix: fetch channels.list?part=statistics first -- it's a live point-in-time count independent of date_range, so it stands on its own regardless of what /reports does. A generic Analytics failure now degrades to followers-only (recorded in extra["insight_errors"], matching the other Meta-family providers' insights convention) rather than losing everything; an auth/scope failure still propagates unchanged, since that's what the sync layer's _is_insufficient_scope check relies on to flag the account for reconnect.

Tested: 6 new unit tests covering followers-from-statistics, an empty Analytics day, a generic Analytics failure, a channel-statistics failure (followers becomes None, Analytics untouched), a scope error still raising, and the channels.list request shape. Full tests/providers/test_youtube.py passes.

…s lag

get_account_metrics only called the Analytics /reports endpoint, so a
channel with no activity yet today (Analytics lags 1-2 days and returns
empty rows) reported followers=0 instead of its real subscriber count —
and any /reports failure lost the total too, since the whole call had
nothing else to fall back on.

Fetch channels.list?part=statistics first: it's a live point-in-time
count independent of date_range, so it stands on its own regardless of
what /reports does. A generic Analytics failure now degrades to
followers-only (recorded in extra["insight_errors"], matching the other
Meta-family providers' insights convention) rather than losing
everything; an auth/scope failure still propagates unchanged, since
that's what the sync layer's _is_insufficient_scope check relies on to
flag the account for reconnect.
@murtaja1
murtaja1 requested a review from JanSchm as a code owner August 13, 2026 10:53
@Murtaja-Adnan Murtaja-Adnan closed this by deleting the head repository Aug 14, 2026
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.

2 participants