product-analytics export paginated incorrectly mid-pull: agent failed to sync half the accounts
Fixes a product-analytics export that paginates incorrectly and syncs only half the accounts by repairing cursor handling in the agent's pull loop. Use when exports silently truncate. Not for an export limited by the analytics plan's row caps.
TL;DR
Pagination bugs are silent because page one always works. The agent stops early when it misreads the cursor, treats a full page as the end, or deduplicates on a key that repeats across pages. Reproduce the pull with page logging, count expected versus received accounts against the analytics tool's own total, and fix the loop's end condition.
product-analytics export paginated incorrectly mid-pull: agent failed to sync half the accountsUse this when
- The synced account count is roughly a round fraction of the real count
- No errors appear in the sync log
- The missing accounts cluster alphabetically, by date, or by another sort order
Not for this skill when
- The analytics export genuinely contains only those accounts (filter applied in the tool)
- The missing accounts were created after the export snapshot
Steps
- Get the expected total from the analytics tool's UI or count endpoint for the same filters. Verify: the target count is known before touching the agent
- Run the pull with per-page logging: page size, cursor value, and cumulative unique accounts. Verify: the page where progress stalls or repeats is visible
- Inspect the loop's end condition and cursor update against the API's pagination contract. Verify: the exact pagination mistake is identified
- Fix it, re-run, and reconcile unique accounts pulled against the expected total. Verify: pulled count matches expected, or the residual delta is explained account by account
- Add a permanent reconciliation step: any pull short of the expected total fails the sync loudly. Verify: silent truncation cannot recur
Variant phrasings
analytics export syncs half the accounts
A related phrasing for the same underlying problem.
pagination cursor bug in agent pull
A related phrasing for the same underlying problem.
export truncated silently
A related phrasing for the same underlying problem.
Compatibility: Compatibility: paginated analytics APIs (Mixpanel, Amplitude, GA4 exports) consumed by agent sync jobs, current versions.
Why it happens
A pull that returns thousands of plausible rows gives no reason to doubt it, which is why pagination bugs survive for months. Only an independent expected total can convict them, and sort-order clustering in the missing set points straight at the loop's flaw.
Edge cases / pitfalls
- Offset pagination over changing data skips rows; cursor pagination is the fix where the API offers it.
- Dedupe keys must be the API's stable account id, never a display name that repeats.
- Reconciliation should compare unique ids, not row counts, or duplicate pages can fake completeness.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_sVcWwNiUo2huf3MjG1vfaw