fix(browser): make shared capture synchronous - #4675
Draft
dustinbyrne wants to merge 1 commit into
Draft
Conversation
Contributor
|
Contributor
|
23 tasks
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
Browser extension clients and the private experimental
@posthog/browserclient exposedcapture()asPromise<void>, even though capture only performs synchronous queue admission. The promise implied an asynchronous completion or delivery guarantee that did not exist and added an allocation on every capture.Changes
Client.capture()contract fromPromise<void>tovoid.flush()as the asynchronous delivery barrier.undefinedreturn value.Compatibility and release impact
This intentionally changes the pre-1.0
@posthog/browser-commoncapture return type. Existingawait client.capture(...)calls continue to work, but promise chaining oncapture()is no longer supported. A minor@posthog/browser-commonchangeset records the contract change;posthog-jsreceives the matching adapter implementation and its dependency-driven patch bump. The private@posthog/browserpackage remains unpublished.The change reduces the measured browser-next bundles by approximately 36–42 minified bytes depending on the entrypoint.
Validation
pnpm turbo --filter=@posthog/browser-common buildpnpm --dir packages/browser-common lintpnpm --dir packages/browser-common test:unit— 92 testspnpm --dir packages/browser-next lintpnpm --dir packages/browser-next check-typespnpm --dir packages/browser-next test:unit— 343 tests, build/declarations, and mixed-module deliverypnpm --dir packages/browser-next test:browser— 18 tests across Chromium, Firefox, and WebKitpnpm --dir packages/browser-next bundle-sizeRelease info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
The human identified that capture admission should be synchronous and selected
capture(): voidwithflush(): Promise<void>as the explicit delivery boundary. Pi's coding agent implemented and validated the change in a local session without a public transcript link. A fresh-context built-in reviewer independently inspected the resulting diff and found no concrete issues.