From 339265e1a3c6e27759db288d2aea07f78f2b9adf Mon Sep 17 00:00:00 2001 From: 3link <34981284+3link@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:59:55 +0200 Subject: [PATCH 1/7] Make timeout for Ajax call configurable --- src/idex.ts | 2 +- src/pixel/sender.ts | 6 ++++-- src/types.ts | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) 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..db2b1320 100644 --- a/src/pixel/sender.ts +++ b/src/pixel/sender.ts @@ -4,10 +4,11 @@ import { LiveConnectConfig, EventBus } from '../types' import { StateWrapper } from './state' import { WrappedCallHandler } from '../handlers/call-handler' -const DEFAULT_AJAX_TIMEOUT = 0 +const DEFAULT_AJAX_TIMEOUT = 1000 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 From b694ed2ca859a2c58f0fcc606ea8fa691ca57d21 Mon Sep 17 00:00:00 2001 From: 3link <34981284+3link@users.noreply.github.com> Date: Thu, 31 Aug 2023 09:27:13 +0200 Subject: [PATCH 2/7] Set DEFAULT_AJAX_TIMEOUT = 0 --- src/pixel/sender.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pixel/sender.ts b/src/pixel/sender.ts index db2b1320..e317582d 100644 --- a/src/pixel/sender.ts +++ b/src/pixel/sender.ts @@ -4,7 +4,7 @@ import { LiveConnectConfig, EventBus } from '../types' import { StateWrapper } from './state' import { WrappedCallHandler } from '../handlers/call-handler' -const DEFAULT_AJAX_TIMEOUT = 1000 +const DEFAULT_AJAX_TIMEOUT = 0 export class PixelSender { url: string From 639681baf058c302b5bf3283d619a334b5a18ca6 Mon Sep 17 00:00:00 2001 From: 3link <34981284+3link@users.noreply.github.com> Date: Thu, 31 Aug 2023 14:41:35 +0200 Subject: [PATCH 3/7] Add ajaxTimeout parameter documentation --- CONFIGURATION_OPTIONS.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CONFIGURATION_OPTIONS.md b/CONFIGURATION_OPTIONS.md index 88cf9664..e1f40765 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 Ajax calls. By default, there is no timeout. + #### `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,9 @@ 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. + +Overwrites the global `ajaxTimeout`: if `identityResolutionConfig.ajaxTimeout` is configured, it is used, otherwise if `ajaxTimeout` is configured, it is used, else the default of 5000ms is used. Example: ```javascript { From 532fb0b6a779fb15ac5276fcad928789f6ca6409 Mon Sep 17 00:00:00 2001 From: 3link <34981284+3link@users.noreply.github.com> Date: Thu, 31 Aug 2023 14:44:07 +0200 Subject: [PATCH 4/7] Remove duplicate doc --- CONFIGURATION_OPTIONS.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CONFIGURATION_OPTIONS.md b/CONFIGURATION_OPTIONS.md index e1f40765..ea4e5498 100644 --- a/CONFIGURATION_OPTIONS.md +++ b/CONFIGURATION_OPTIONS.md @@ -163,7 +163,6 @@ sets the cookie expiration time to 4 hours, which means that in a given browser, 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. 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. -Overwrites the global `ajaxTimeout`: if `identityResolutionConfig.ajaxTimeout` is configured, it is used, otherwise if `ajaxTimeout` is configured, it is used, else the default of 5000ms is used. Example: ```javascript { From dfe20880911ad012916c953ece3577c179fc52de Mon Sep 17 00:00:00 2001 From: 3link <34981284+3link@users.noreply.github.com> Date: Thu, 31 Aug 2023 14:48:21 +0200 Subject: [PATCH 5/7] Improve the doc --- CONFIGURATION_OPTIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONFIGURATION_OPTIONS.md b/CONFIGURATION_OPTIONS.md index ea4e5498..d6b01942 100644 --- a/CONFIGURATION_OPTIONS.md +++ b/CONFIGURATION_OPTIONS.md @@ -128,7 +128,7 @@ Example: ``` ### `ajaxTimeout` [Optional, HasDefault] -This configuration parameter sets the maximum duration of Ajax calls. By default, there is no timeout. +This configuration parameter sets the maximum duration of calls to all endpoints. By default, there is no timeout. #### `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). From 862b52c6e717a0bda97fd8d74c1088038cb54884 Mon Sep 17 00:00:00 2001 From: 3link <34981284+3link@users.noreply.github.com> Date: Thu, 31 Aug 2023 14:50:06 +0200 Subject: [PATCH 6/7] Commit unsaved changed --- CONFIGURATION_OPTIONS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONFIGURATION_OPTIONS.md b/CONFIGURATION_OPTIONS.md index d6b01942..30e742e8 100644 --- a/CONFIGURATION_OPTIONS.md +++ b/CONFIGURATION_OPTIONS.md @@ -128,7 +128,8 @@ Example: ``` ### `ajaxTimeout` [Optional, HasDefault] -This configuration parameter sets the maximum duration of calls to all endpoints. By default, there is no timeout. +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). From d2c6b9b54a4707e63837deb018e0ee55bae5f824 Mon Sep 17 00:00:00 2001 From: 3link <34981284+3link@users.noreply.github.com> Date: Thu, 31 Aug 2023 14:51:52 +0200 Subject: [PATCH 7/7] Remove linebreak --- CONFIGURATION_OPTIONS.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CONFIGURATION_OPTIONS.md b/CONFIGURATION_OPTIONS.md index 30e742e8..725c28fa 100644 --- a/CONFIGURATION_OPTIONS.md +++ b/CONFIGURATION_OPTIONS.md @@ -128,8 +128,7 @@ 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. +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).