Skip to content

Commit 1036717

Browse files
committed
wip
1 parent 6942d68 commit 1036717

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

.changeset/heavy-taxis-suffer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
'@segment/analytics-next': minor
33
---
4-
Add new `additionalHeaders` setting, along with `fetchPriority`.
4+
Add new `headers` setting, along with `fetchPriority`.
55

66
```ts
77
analytics.load("<YOUR_WRITE_KEY>",
@@ -11,7 +11,7 @@ analytics.load("<YOUR_WRITE_KEY>",
1111
deliveryStrategy: {
1212
strategy: "standard" // also works for 'batching'
1313
config: {
14-
additionalHeaders: { 'x-api-key': 'foo' } or () => {...}
14+
headers: { 'x-api-key': 'foo' } or () => {...}
1515
fetchPriority: 'low' | 'high', // new setting
1616
},
1717
},

packages/browser/src/plugins/segmentio/__tests__/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('Segment.io', () => {
6565
})
6666
})
6767

68-
describe('configuring additionalHeaders', () => {
68+
describe('configuring headers', () => {
6969
it('should accept additional headers', async () => {
7070
const analytics = new Analytics({ writeKey: 'foo' })
7171

@@ -74,7 +74,7 @@ describe('Segment.io', () => {
7474
apiKey: '',
7575
deliveryStrategy: {
7676
config: {
77-
additionalHeaders: {
77+
headers: {
7878
'X-My-Header': 'foo',
7979
},
8080
},
@@ -96,7 +96,7 @@ describe('Segment.io', () => {
9696
apiKey: '',
9797
deliveryStrategy: {
9898
config: {
99-
additionalHeaders: () => ({
99+
headers: () => ({
100100
'X-My-Header': 'foo',
101101
}),
102102
},
@@ -118,7 +118,7 @@ describe('Segment.io', () => {
118118
apiKey: '',
119119
deliveryStrategy: {
120120
config: {
121-
additionalHeaders: () => ({
121+
headers: () => ({
122122
'Content-Type': 'bar',
123123
}),
124124
},

packages/browser/src/plugins/segmentio/batched-dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default function batch(
7878

7979
return fetch(`https://${apiHost}/b`, {
8080
keepalive: config?.keepalive || pageUnloaded,
81-
headers: createHeaders(config?.additionalHeaders),
81+
headers: createHeaders(config?.headers),
8282
...(config?.fetchPriority ? { priority: config?.fetchPriority } : {}),
8383
method: 'post',
8484
body: JSON.stringify({

packages/browser/src/plugins/segmentio/fetch-dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function (config?: StandardDispatcherConfig): {
99
function dispatch(url: string, body: object): Promise<unknown> {
1010
return fetch(url, {
1111
keepalive: config?.keepalive,
12-
headers: createHeaders(config?.additionalHeaders),
12+
headers: createHeaders(config?.headers),
1313
method: 'post',
1414
body: JSON.stringify(body),
1515
...(config?.fetchPriority ? { priority: config?.fetchPriority } : {}),

packages/browser/src/plugins/segmentio/shared-dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ interface DispatchConfig {
3434
* If a function is provided, it will be called before each request.
3535
* @example { 'Content-Type': 'application/json' } or () => { 'Content-Type': 'application/json' }
3636
*/
37-
additionalHeaders?: AdditionalHeaders
37+
headers?: AdditionalHeaders
3838
/**
3939
* 'Fetch Priority' of the request (chrome-only).
4040
*/

0 commit comments

Comments
 (0)