Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/Support/Analytics/AnalyticsRateLimits.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
* documented ceiling:
* - X: GET /2/users/:id/tweets allows 10,000 requests per 15 minutes per app (~666/min); guard 600/min.
* - TikTok: 600 requests per minute per endpoint; guard 500/min.
* - YouTube: the Data API quota is 10,000 units a day per Google Cloud project, shared with publishing.
* An analytics job spends at most 2 units (playlistItems + a 50-id videos.list), so 3,000 jobs a day
* stay under 6,000 units and leave the rest for uploads.
* - YouTube has no shared guard. A metrics job reads `videos.list` in batches of 50 ids (one Data API
* unit for 50 videos) and one YouTube Analytics API report; uploads have their own quota. A
* `quotaExceeded` or 429 from Google is retried as rate_limited, and more quota is requested from
* Google when that happens.
* - Bluesky: a PDS allows 3,000 requests per 5 minutes per IP over all endpoints (600/min,
* docs.bsky.app "Rate Limits", `global-ip` in @atproto/pds rate-limits.ts), shared with publishing
* through the same host; guard 500/min per PDS host. The public AppView documents no number.
Expand Down Expand Up @@ -56,7 +57,6 @@ private static function shared(SocialAccount $account): ?Limit
return match ($account->platform) {
Platform::X => Limit::perMinute(600)->by("{$network}:app"),
Platform::TikTok => Limit::perMinute(500)->by("{$network}:app"),
Platform::YouTube => Limit::perDay(3000)->by("{$network}:project"),
Platform::Bluesky => Limit::perMinute(500)->by("{$network}:pds:".parse_url((string) data_get($account->meta, 'service', config('trypost.platforms.bluesky.default_service')), PHP_URL_HOST)),
Platform::Mastodon => Limit::perMinute(50)->by("{$network}:instance:{$account->mastodonInstance()}"),
default => null,
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Analytics/PublicationMetricsJobsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function discoveredFor(AnalyticsPublication $publication): DiscoveredPublication
'instagram is limited per token' => [Platform::Instagram, null],
'facebook is limited per page token' => [Platform::Facebook, null],
'x shares the app limit' => [Platform::X, 'x:app'],
'youtube shares the project quota' => [Platform::YouTube, 'youtube:project'],
'youtube is limited only per channel' => [Platform::YouTube, null],
'tiktok shares the app limit' => [Platform::TikTok, 'tiktok:app'],
]);

Expand Down
Loading