fix(pinterest): keep analytics within the 90-day window#1665
Open
giladresisi wants to merge 1 commit into
Open
fix(pinterest): keep analytics within the 90-day window#1665giladresisi wants to merge 1 commit into
giladresisi wants to merge 1 commit into
Conversation
Pinterest analytics endpoints only serve the last 90 days (evaluated in UTC). `postAnalytics` requested `start_date` 2 years ago, so every pin-analytics call failed with "You can only get data from the last 90 days", surfacing in prod as: Error fetching Pinterest post analytics: ApplicationFailure: Unknown Error (the generic "Unknown Error" is BadBody's default; Pinterest's real message was in the failure details). Changes: - postAnalytics: start_date now 89 days back instead of 2 years. Pinterest does not expose pin metrics older than 90 days, so 89 is the maximum obtainable; 89 (not 90) avoids an off-by-one when the server's local date leads UTC. - analytics (account level): clamp the requested period to <= 89 days for the same reason, so a longer UI selection can't trip the same error. - handleErrors: map "only get data from the last 90 days" to a clear message instead of the generic "Unknown Error". Introduced in 5cca81e ("feat: post analytics"). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Contribution-checker quality warning Heuristics that flagged:
If this is a genuine contribution, please add detail to your PR description and tighten the diff scope before reviewers look at it. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Production logs show, for every Pinterest post:
with Pinterest's underlying message: "You can only get data from the last 90 days."
Pinterest's analytics endpoints (
/v5/pins/{pin_id}/analytics,/v5/user_account/analytics) only serve the last 90 days (evaluated in UTC). ButpostAnalytics()requestedstart_date2 years ago (dayjs().subtract(2, 'year')), so the call failed every time. The genericUnknown Erroris justBadBody's default message — Pinterest's real reason was in the failure details.Introduced in
5cca81e0("feat: post analytics").Changes
postAnalytics—start_dateis now 89 days back instead of 2 years. Pinterest doesn't expose pin metrics older than 90 days, so 89 days is the maximum obtainable. Using 89 rather than 90 avoids an off-by-one when the server's local date leads UTC.analytics(account level) — clamps the requested period toMath.min(date, 89)so a longer UI selection can't trip the same error.handleErrors— maps"only get data from the last 90 days"to a clear, user-facing message instead of the genericUnknown Error.Note / trade-off
This is a Pinterest limitation, not something we can widen: pin metrics older than ~90 days simply aren't available from their API. Posts older than that will return only the recent-window data — expected behavior. After this change the error logs stop and analytics populate for in-window posts.
🤖 Generated with Claude Code