diff --git a/CONFIGURATION_OPTIONS.md b/CONFIGURATION_OPTIONS.md index 88cf9664..725c28fa 100644 --- a/CONFIGURATION_OPTIONS.md +++ b/CONFIGURATION_OPTIONS.md @@ -127,6 +127,9 @@ Example: } ``` +### `ajaxTimeout` [Optional, HasDefault] +This configuration parameter sets the maximum duration of calls to all endpoints. By default, there is no timeout. Please refer to `identityResolutionConfig.ajaxTimeout` for the special handling of the timeout for the IdentityResolution endpoint. + #### `identityResolutionConfig` [Optional, HasDefault] LiveConnect module comes with a functionality to resolve all the identifiers set in the `identifiersToResolve`, additionally to the first party ones created by LiveConnect (in case `storageStrategy` is anything else than `none`, and an actual identifier has been stored). This configuration setting consists of the following @@ -158,7 +161,8 @@ sets the cookie expiration time to 4 hours, which means that in a given browser, ##### `identityResolutionConfig.ajaxTimeout` [Optional, HasDefault] By default, 5000 milliseconds. -This configuration parameter sets the maximum duration of a call to the IdentityResolution endpoint, after which the callback passed to the `resolve` function will be invoked. +This configuration parameter sets the maximum duration of a call to the IdentityResolution endpoint, after which the callback passed to the `resolve` function will be invoked. If `identityResolutionConfig.ajaxTimeout` is not configured and the global `ajaxTimeout` is configured, the global setting is used. If none of the two is configured, the default of 5000ms is used. + Example: ```javascript { diff --git a/src/idex.ts b/src/idex.ts index c8d883a9..46bc0f5b 100644 --- a/src/idex.ts +++ b/src/idex.ts @@ -75,7 +75,7 @@ export class IdentityResolver { this.source = this.idexConfig.source || 'unknown' this.publisherId = this.idexConfig.publisherId || 'any' this.url = this.idexConfig.url || DEFAULT_IDEX_URL - this.timeout = this.idexConfig.ajaxTimeout || DEFAULT_IDEX_AJAX_TIMEOUT + this.timeout = this.idexConfig.ajaxTimeout || config.ajaxTimeout || DEFAULT_IDEX_AJAX_TIMEOUT this.requestedAttributes = this.idexConfig.requestedAttributes || DEFAULT_REQUESTED_ATTRIBUTES this.tuples = [] diff --git a/src/pixel/sender.ts b/src/pixel/sender.ts index e47bc85b..e317582d 100644 --- a/src/pixel/sender.ts +++ b/src/pixel/sender.ts @@ -8,6 +8,7 @@ const DEFAULT_AJAX_TIMEOUT = 0 export class PixelSender { url: string + timeout: number calls: WrappedCallHandler eventBus: EventBus onload?: () => void @@ -15,6 +16,7 @@ export class PixelSender { constructor (liveConnectConfig: LiveConnectConfig, calls: WrappedCallHandler, eventBus: EventBus, onload?: () => void, presend?: () => void) { this.url = (liveConnectConfig && liveConnectConfig.collectorUrl) || 'https://rp.liadm.com' + this.timeout = (liveConnectConfig && liveConnectConfig.ajaxTimeout) || DEFAULT_AJAX_TIMEOUT this.calls = calls this.eventBus = eventBus this.onload = onload @@ -59,7 +61,7 @@ export class PixelSender { this.sendPixel(state) this.eventBus.emitError('AjaxFailed', e) }, - DEFAULT_AJAX_TIMEOUT + this.timeout ) }) } diff --git a/src/types.ts b/src/types.ts index c2825706..002e1760 100644 --- a/src/types.ts +++ b/src/types.ts @@ -28,6 +28,7 @@ export interface LiveConnectConfig { globalVarName?: string urlCollectionMode?: UrlCollectionMode queryParametersFilter?: string + ajaxTimeout?: number } export type ResolutionParams = Record