Skip to content

Document transport option behavior in capture() API #17023

@ibratoev

Description

@ibratoev

Description of the problem this feature would solve:

The transport option for posthog.capture() is not documented in the official JavaScript SDK documentation. Specifically, it's unclear whether specifying { transport: "sendBeacon" } bypasses PostHog's normal event buffering/batching behavior.

This is critical for use cases like capturing events immediately before window.location.reload() or other page navigation, where developers need certainty that events will be sent before the page unloads.

Description of the solution you'd like:

Add documentation to the JavaScript SDK docs that clarifies:

  • Whether events captured with { transport: "sendBeacon" } are sent immediately or queued
  • The relationship between the transport option and PostHog's buffering/batching behavior
  • Best practices for ensuring events are sent before page unload/reload
  • Whether posthog.flush() is needed in addition to { transport: "sendBeacon" }

Alternative solutions you've considered:

Currently relying on source code inspection and GitHub issues to understand behavior, which is not ideal for production implementations.

Additional context:

The source code shows sendBeacon is available as a transport option, but the behavior isn't documented in the official SDK documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsImprovements or additions to product documentation, "Docs"

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions