Skip to content

Feature request: Add support to configure fetch priority for the network calls #1199

Closed
@nischithbm

Description

@nischithbm

The current implementation does not specify a fetch priority when the Segment API sends data to the server. Consequently, the browser defaults to selecting the priority, which in several web applications, tends to be 'high'.

Desired Behavior: We aim to assign a low priority to analytics network calls. This adjustment will allow the browser to prioritize other critical resources more effectively.

However, at present, there is no mechanism available to customize the fetch priority.

https://github.com/segmentio/analytics-next/blob/%40segment/analytics-signals%401.8.0/packages/browser/src/plugins/segmentio/fetch-dispatcher.ts#L14

fetch(url, {
      keepalive: config?.keepalive,
      headers: { 'Content-Type': 'text/plain' },
      method: 'post',
      body: JSON.stringify(body),
     // priority attribute is not sent currently, Defaults to auto, when not set
})

Reference: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit#priority

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions