feat(browser-next): add immediate capture delivery - #4676
Draft
dustinbyrne wants to merge 1 commit into
Draft
Conversation
Contributor
📝 No Changeset FoundThis PR doesn't include a changeset. A changeset is required to release a new version. How to add a changesetRun this command and follow the prompts: pnpm changesetRemember: Never use |
Contributor
|
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
Some callers need confirmation that Capture Analytics V1 reached a terminal persistence outcome before advancing their own work. Ordinary browser capture intentionally provides synchronous bounded queue admission, while
flush()is a lane snapshot barrier and does not report the fate of a specific event.This is a stacked follow-up to #4675 and should be reviewed against
fix/browser-next-sync-capture.Changes
PostHog.captureImmediate(...) => Promise<CaptureSummary>to the private experimental browser client.2xxresponses:okandwarningcount as persisted;drop, finalretry, and missing outcomes do not.Immediate delivery deliberately bypasses lane ordering, can overtake buffered work, and is never retained for a later flush. The root lazily loads analytics for an admitted immediate call. The core entrypoint still contains no delivery import and requires explicitly installed analytics.
Bundle impact
Compared with #4675:
Capture V1 delivery remains outside the core graph.
Validation
Release info Sub-libraries affected
Libraries affected
@posthog/browserremains private and unpublished, so this stacked PR has no release changeset.Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
The human selected a Rust-inspired immediate-delivery contract: bypass buffered delivery, share Capture V1 machinery, return a persistence summary for valid responses, and reject request-level failures. Pi's coding agent implemented and validated the change in a local session without a public transcript link. A fresh-context built-in reviewer identified consent-revival and prototype-lookup issues; both were fixed and confirmed in focused re-review.