From 53a06e6d7b6883ccce120a59a3335ddcaf732ac2 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:05:55 -0600 Subject: [PATCH] wip --- .../plugins/segmentio/shared-dispatcher.ts | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/browser/src/plugins/segmentio/shared-dispatcher.ts b/packages/browser/src/plugins/segmentio/shared-dispatcher.ts index 315c37728..c8fe3d8ef 100644 --- a/packages/browser/src/plugins/segmentio/shared-dispatcher.ts +++ b/packages/browser/src/plugins/segmentio/shared-dispatcher.ts @@ -18,37 +18,38 @@ export type AdditionalHeaders = | Record | (() => Record) -/** - * Priority of the request. - * chrome only - * @default 'auto' - */ export type FetchPriority = 'high' | 'low' | 'auto' -export type BatchingDispatchConfig = { - size?: number - timeout?: number - maxRetries?: number - additionalHeaders?: AdditionalHeaders - /** - * This is useful for ensuring that events are sent even if the user navigates away from the page. - * @default false IF the page is being unloaded, true otherwise - */ - keepalive?: boolean - fetchPriority?: FetchPriority -} - -export type StandardDispatcherConfig = { +interface DispatchConfig { /** * This is useful for ensuring that an event is sent even if the user navigates away from the page. * However, it may increase the likelihood of events being lost, as there is a 64kb limit for all fetch requests with keepalive (which is why it's disabled by default). * @default false */ keepalive?: boolean + /** + * Additional headers to be sent with the request. + * Default is `Content-Type: text/plain`. This can be overridden. + * If a function is provided, it will be called before each request. + * @example { 'Content-Type': 'application/json' } or () => { 'Content-Type': 'application/json' } + */ additionalHeaders?: AdditionalHeaders + /** + * Priority of the request. + * chrome only + * @default 'auto' + */ fetchPriority?: FetchPriority } +export interface BatchingDispatchConfig extends DispatchConfig { + size?: number + timeout?: number + maxRetries?: number +} + +export interface StandardDispatcherConfig extends DispatchConfig {} + export type DeliveryStrategy = | { strategy?: 'standard'