Skip to content

Commit

Permalink
Type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianoSanchez committed Aug 16, 2024
1 parent b0b5bb7 commit 9d4153a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
8 changes: 6 additions & 2 deletions ts-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,10 @@ let fullBrowserSettings: SplitIO.IBrowserSettings = {
sync: {
splitFilters: splitFilters,
impressionsMode: 'DEBUG',
enabled: true
enabled: true,
requestOptions: {
getHeaderOverrides() { return { 'header': 'value' } },
}
},
userConsent: 'GRANTED'
};
Expand Down Expand Up @@ -618,6 +621,7 @@ let fullNodeSettings: SplitIO.INodeSettings = {
impressionsMode: 'OPTIMIZED',
enabled: true,
requestOptions: {
getHeaderOverrides() { return { 'header': 'value' } },
agent: new (require('https')).Agent(),
}
}
Expand Down Expand Up @@ -666,7 +670,7 @@ let fullAsyncSettings: SplitIO.INodeAsyncSettings = {
mode: 'consumer',
debug: true,
sync: {
splitFilters: splitFilters
splitFilters: splitFilters,
}
};

Expand Down
29 changes: 28 additions & 1 deletion types/splitio.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,25 @@ declare namespace SplitIO {
* @typedef {string} userConsent
* @default 'GRANTED'
*/
userConsent?: ConsentStatus
userConsent?: ConsentStatus,
sync?: ISharedSettings['sync'] & {
/**
* Custom options object for HTTP(S) requests in the Browser.
* If provided, this object is merged with the options object passed by the SDK for EventSource and Fetch calls.
* @see {@link https://www.npmjs.com/package/node-fetch#options}
*/
requestOptions?: {
/**
* Custom function called before each request, allowing you to add or update custom headers on the SDK requests.
*
* @TODO pass context to `getHeaderOverrides`. Add `validUntil` property?
*
* @property getHeaderOverrides
* @default undefined
*/
getHeaderOverrides?: () => Record<string, string>,
},
}
}
/**
* Settings interface for SDK instances created on NodeJS.
Expand Down Expand Up @@ -1176,6 +1194,15 @@ declare namespace SplitIO {
* @see {@link https://www.npmjs.com/package/node-fetch#options}
*/
requestOptions?: {
/**
* Custom function called before each request, allowing you to add or update custom headers on the SDK requests.
*
* @TODO pass context to `getHeaderOverrides`. Add `validUntil` property?
*
* @property getHeaderOverrides
* @default undefined
*/
getHeaderOverrides?: () => Record<string, string>,
/**
* Custom NodeJS HTTP(S) Agent used by the SDK for HTTP(S) requests.
*
Expand Down

0 comments on commit 9d4153a

Please sign in to comment.