apps 0.0.1-beta.137 → 0.0.1-beta.138

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,8 +11,19 @@
11
11
  * events, each of which goes as an ordinary request when it does not fit. Not counted: PostHog's
12
12
  * own requests, which the dashboard sends without keepalive, except the beacons PostHog sends as
13
13
  * the page unloads (its queued requests and the last replay chunk); and any other keepalive
14
- * request or beacon on the page.
14
+ * request or beacon on the page. Those can still fill the quota; a keepalive request the browser
15
+ * refuses then goes once more as an ordinary request, and the page records that it did.
15
16
  */
17
+ /** Which of the page's telemetry senders a request belongs to: a fixed name, never an identifier. */
18
+ export type KeepaliveSender = "exports" | "error-reports" | "error-sessions" | "analytics";
19
+ /** What became of a request the browser refused and the page sent once more as an ordinary one. */
20
+ export type KeepaliveResend = "resent" | "resend-failed";
21
+ type ResendListener = (sender: KeepaliveSender, outcome: KeepaliveResend) => void;
22
+ /**
23
+ * Hear each resend of a refused keepalive request, including those before this was called. The
24
+ * page's telemetry records them; the returned function stops listening.
25
+ */
26
+ export declare const onKeepaliveResend: (listener: ResendListener) => () => void;
16
27
  /**
17
28
  * The page's own `fetch`, taken when this module first loads, before any SDK wraps it. The Sentry
18
29
  * SDK wraps `window.fetch` to record each request as a breadcrumb on later reports; the page's own
@@ -25,12 +36,18 @@ export declare const keepaliveRoom: () => number;
25
36
  * Send with keepalive, counting `keepaliveBytes`, the body's size, against the page's budget; or,
26
37
  * given `false`, as an ordinary request. The browser counts a keepalive request until its whole
27
38
  * response has arrived, not just its headers, so the bytes are counted until a copy of the
28
- * response body has been read.
39
+ * response body has been read. Only for idempotent telemetry: see `budgetedFetch`.
29
40
  */
30
- export declare const countedFetch: (send: typeof fetch, input: RequestInfo | URL, init: RequestInit, keepaliveBytes: number | false) => Promise<Response>;
41
+ export declare const countedFetch: (sender: KeepaliveSender, send: typeof fetch, input: RequestInfo | URL, init: RequestInit, keepaliveBytes: number | false) => Promise<Response>;
31
42
  /**
32
43
  * `send`, with a requested keepalive kept only when the body fits what is left of the page's
33
44
  * budget. Otherwise the request goes as an ordinary one, which the browser sends at once but may
34
45
  * cancel if the page unloads first.
46
+ *
47
+ * Only for idempotent telemetry: a keepalive request that fails with a TypeError is sent once more,
48
+ * and a TypeError cannot tell a refusal, which sent nothing, from a connection lost after the
49
+ * request was sent. A request whose repeat would do something twice, such as a write, must not
50
+ * use this.
35
51
  */
36
- export declare const budgetedFetch: (send?: typeof fetch) => typeof fetch;
52
+ export declare const budgetedFetch: (sender: KeepaliveSender, send?: typeof fetch) => typeof fetch;
53
+ export {};