posthog-js
Version:
Posthog-js allows you to automatically capture usage and send events to PostHog.
19 lines (18 loc) • 1.01 kB
TypeScript
import type { PostHog } from '../posthog-core';
/**
* Records a duration histogram for every HTTP or HTTPS `fetch` and
* `XMLHttpRequest` the page makes, except the SDK's own. Observation only: the
* wrappers never change the request arguments or its settlement. Fetch returns
* a derived promise so rejected requests remain observable to the caller and to
* the browser's unhandled-rejection handling.
*
* Each transport is measured to the boundary its API exposes: a `fetch` promise
* settles when the response headers arrive, and `loadend` fires after the whole
* XHR response body. Aligning them would mean reading the fetch response body,
* which an observer must not do.
*
* While `metrics.network` is off the wrappers pass every request straight
* through. The returned function removes them; if another wrapper was layered
* on top and ours cannot be spliced out, it stays in place as a pass-through.
*/
export declare const startNetworkMetrics: (instance: PostHog) => (() => void);