Skip to content

Commit 9d4153a

Browse files
Type definitions
1 parent b0b5bb7 commit 9d4153a

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

ts-tests/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,10 @@ let fullBrowserSettings: SplitIO.IBrowserSettings = {
565565
sync: {
566566
splitFilters: splitFilters,
567567
impressionsMode: 'DEBUG',
568-
enabled: true
568+
enabled: true,
569+
requestOptions: {
570+
getHeaderOverrides() { return { 'header': 'value' } },
571+
}
569572
},
570573
userConsent: 'GRANTED'
571574
};
@@ -618,6 +621,7 @@ let fullNodeSettings: SplitIO.INodeSettings = {
618621
impressionsMode: 'OPTIMIZED',
619622
enabled: true,
620623
requestOptions: {
624+
getHeaderOverrides() { return { 'header': 'value' } },
621625
agent: new (require('https')).Agent(),
622626
}
623627
}
@@ -666,7 +670,7 @@ let fullAsyncSettings: SplitIO.INodeAsyncSettings = {
666670
mode: 'consumer',
667671
debug: true,
668672
sync: {
669-
splitFilters: splitFilters
673+
splitFilters: splitFilters,
670674
}
671675
};
672676

types/splitio.d.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,25 @@ declare namespace SplitIO {
11261126
* @typedef {string} userConsent
11271127
* @default 'GRANTED'
11281128
*/
1129-
userConsent?: ConsentStatus
1129+
userConsent?: ConsentStatus,
1130+
sync?: ISharedSettings['sync'] & {
1131+
/**
1132+
* Custom options object for HTTP(S) requests in the Browser.
1133+
* If provided, this object is merged with the options object passed by the SDK for EventSource and Fetch calls.
1134+
* @see {@link https://www.npmjs.com/package/node-fetch#options}
1135+
*/
1136+
requestOptions?: {
1137+
/**
1138+
* Custom function called before each request, allowing you to add or update custom headers on the SDK requests.
1139+
*
1140+
* @TODO pass context to `getHeaderOverrides`. Add `validUntil` property?
1141+
*
1142+
* @property getHeaderOverrides
1143+
* @default undefined
1144+
*/
1145+
getHeaderOverrides?: () => Record<string, string>,
1146+
},
1147+
}
11301148
}
11311149
/**
11321150
* Settings interface for SDK instances created on NodeJS.
@@ -1176,6 +1194,15 @@ declare namespace SplitIO {
11761194
* @see {@link https://www.npmjs.com/package/node-fetch#options}
11771195
*/
11781196
requestOptions?: {
1197+
/**
1198+
* Custom function called before each request, allowing you to add or update custom headers on the SDK requests.
1199+
*
1200+
* @TODO pass context to `getHeaderOverrides`. Add `validUntil` property?
1201+
*
1202+
* @property getHeaderOverrides
1203+
* @default undefined
1204+
*/
1205+
getHeaderOverrides?: () => Record<string, string>,
11791206
/**
11801207
* Custom NodeJS HTTP(S) Agent used by the SDK for HTTP(S) requests.
11811208
*

0 commit comments

Comments
 (0)