Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nischithbm opened this issue Dec 4, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@nischithbm
Copy link

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

@silesky
Copy link
Contributor

silesky commented Dec 10, 2024

Thank you @nischithbm, discussing this in our quarterly planning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants