Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky committed Dec 18, 2024
1 parent 032d6a8 commit 53a06e6
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions packages/browser/src/plugins/segmentio/shared-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,38 @@ export type AdditionalHeaders =
| Record<string, string>
| (() => Record<string, string>)

/**
* 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'
Expand Down

0 comments on commit 53a06e6

Please sign in to comment.