@repobit/dex-target 2.5.20 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.7.0](https://github.com/bitdefender/dex-core/compare/@repobit/dex-target@2.6.0...@repobit/dex-target@2.7.0) (2026-01-30)
7
+
8
+
9
+ ### Features
10
+
11
+ * **DEX-25763:** refactor version message building for Slack notifications ([5d3f888](https://github.com/bitdefender/dex-core/commit/5d3f88893fce9f2bfd8abe29d43eb20b01188d03))
12
+
13
+
14
+
15
+ ## [2.6.0](https://github.com/bitdefender/dex-core/compare/@repobit/dex-target@2.5.20...@repobit/dex-target@2.6.0) (2026-01-30)
16
+
17
+
18
+ ### Features
19
+
20
+ * **DEX-25763:** added functionality to add icid params to buyLinks ([9ea3724](https://github.com/bitdefender/dex-core/commit/9ea3724f3d4fc2a4e73229297a9a123e7b5885e2))
21
+
22
+
23
+
6
24
  ## [2.5.20](https://github.com/bitdefender/dex-core/compare/@repobit/dex-target@2.5.19...@repobit/dex-target@2.5.20) (2026-01-19)
7
25
 
8
26
  **Note:** Version bump only for package @repobit/dex-target
package/README.md CHANGED
@@ -182,4 +182,4 @@ Use the sendCdpData method to send data regarding the pageLoadStarted event to t
182
182
 
183
183
  ```typescript
184
184
  await target.sendCdpData(pageLoadStartedEvent);
185
- ```
185
+ ```
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AA8BzH,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;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,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC,CACpH,CAAC;QACF,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAEhE,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;YAC7D,GAAG,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YACvG,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAwC,CAAC,CAAC;QAE7C,OAAO,eAAe,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;CACF;AAED,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;AAC5B,MAAM,CAAC,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC","sourcesContent":["import { Constants } from '@repobit/dex-constants';\nimport { AdobeDataLayerService, CdpEvent, DecisionsDisplayedEvent, PageLoadStartedEvent } from '@repobit/dex-data-layer';\nimport {\n AlloyAppendIdentityToUrlResponse,\n AlloyApplyPropositionsResponse,\n AlloyFunction,\n AlloySendEventResponse,\n AppendIdentityToUrlCall,\n ApplyPropositionsCall,\n CdpData,\n CdpDataJson,\n ConfigMbox,\n GetIdentityCall,\n GetIdentityResponse,\n MboxParameters,\n MboxProfileParameters,\n SendEventCall,\n URLParameters\n} from './typeDefinitions';\n\ndeclare global {\n interface Window {\n alloyProxy: AlloyFunction;\n BD: {\n state: {\n cdpDataPromise: Promise<CdpData>\n }\n }\n }\n}\n\nif (!window.Promise.withResolvers) {\n window.Promise.withResolvers = function<T>() {\n let resolve, reject;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { resolve, reject, promise } as unknown as PromiseWithResolvers<T>;\n }\n}\n\nexport default class Target {\n private urlParameters : URLParameters;\n private profileUrlParameters: { [key: string]: string | undefined };\n private cachedMboxes : Map<string, Promise<object | undefined>>;\n private _configMbox : Promise<ConfigMbox | undefined>;\n private controller : AbortController = new AbortController();\n private _visitorInfo : Promise<GetIdentityResponse>;\n private cdpData : Promise<CdpData>;\n\n constructor(config?: Partial<{ pageLoadStartedEvent: PageLoadStartedEvent }>) {\n this.urlParameters = this.getUrlParameters();\n this.profileUrlParameters = this.transfromIntoProfileParameters(this.urlParameters);\n this.cachedMboxes = new Map();\n\n if (!window.alloyProxy) {\n function __alloy(...args: SendEventCall): Promise<AlloySendEventResponse>;\n function __alloy(...args: AppendIdentityToUrlCall): Promise<AlloyAppendIdentityToUrlResponse>;\n function __alloy(...args: ApplyPropositionsCall): Promise<AlloyApplyPropositionsResponse>;\n function __alloy(...args: GetIdentityCall): Promise<GetIdentityResponse>;\n function __alloy(...args: SendEventCall | AppendIdentityToUrlCall | ApplyPropositionsCall | GetIdentityCall):\n Promise<AlloySendEventResponse | AlloyAppendIdentityToUrlResponse | AlloyApplyPropositionsResponse | GetIdentityResponse> {\n return new Promise((resolve, reject) => {\n window.alloyProxy.q.push([resolve, reject, args]);\n });\n }\n\n window.alloyProxy = __alloy as AlloyFunction;\n window.alloyProxy.q = [];\n }\n\n // check for dotest=1 in URL. If it exists abort all target calls\n const urlParams = new URLSearchParams(window.location.search);\n if (urlParams.get('dotest') === '1') {\n this.abort();\n }\n\n this._visitorInfo = new Promise((resolve) => {\n if (this.controller.signal?.aborted) {\n resolve({});\n }\n\n window.alloyProxy('getIdentity').then(result => resolve(result))\n .catch(() => resolve({}));\n this.controller.signal?.addEventListener('abort', () => resolve({}));\n });\n this.cdpData = config?.pageLoadStartedEvent && urlParams.get('dotest') !== '1'\n ? this.sendCdpData(config?.pageLoadStartedEvent)\n : Promise.resolve({} as CdpData);\n this._configMbox = this.getOffers({ mboxNames: 'config-mbox' });\n }\n\n /** get an object containing all the url query parameters */\n private getUrlParameters(): URLParameters {\n const urlParams = new URLSearchParams(window.location.search);\n const parameters: URLParameters = {};\n\n urlParams.forEach((value: string, key: string) => {\n parameters[key] = value;\n });\n\n return parameters;\n }\n\n public get configMbox() {\n return this._configMbox;\n }\n\n public get visitorInfo() {\n return this._visitorInfo;\n }\n\n /** add adobe_mc parameter at the end of the url */\n public appendVisitorIDsTo(url: string): Promise<string> {\n if (this.controller.signal?.aborted || url.includes('adobe_mc')) {\n return Promise.resolve(url);\n }\n\n return new Promise((resolve) => {\n window.alloyProxy('appendIdentityToUrl', { url }).then(result => resolve(result.url))\n .catch(() => resolve(url));\n this.controller.signal?.addEventListener('abort', () => resolve(url));\n });\n }\n\n /** abort all the Target calls for casese where Target does not load */\n public abort(): void {\n this.controller.abort();\n }\n\n public async sendCdpData(pageLoadStartedEvent: PageLoadStartedEvent): Promise<CdpData> {\n const cdpDataPromise = Promise.withResolvers<CdpData>();\n let cdpData: CdpData = {};\n if (window.BD.state.cdpDataPromise) {\n return await window.BD.state.cdpDataPromise;\n }\n window.BD.state.cdpDataPromise = cdpDataPromise.promise;\n\n try {\n const ecid = (await this.visitorInfo)?.identity?.ECID;\n const cdpDataCall = await fetch(\n `${Constants.PUBLIC_URL_ORIGIN}/cdp/`,\n {\n method: 'POST',\n body : JSON.stringify({\n mcvisid: ecid || '',\n ...pageLoadStartedEvent.page\n })\n }\n );\n\n /** @type {{auds: string[], mdl: {key: string, value: string}[], ub: any[] vid: string}} */\n const receivedCdpData: CdpDataJson = await cdpDataCall.json();\n cdpData = {\n auds: receivedCdpData?.auds[0] || ''\n };\n\n if (receivedCdpData.mdl) {\n cdpData = receivedCdpData?.mdl.reduce((acc, mdlValue) => {\n acc[mdlValue.key] = mdlValue.value;\n return acc;\n }, cdpData);\n }\n\n AdobeDataLayerService.push(new CdpEvent(cdpData));\n } catch (e) {\n console.warn(e);\n }\n\n cdpDataPromise.resolve(cdpData);\n return cdpData;\n }\n\n private transfromIntoProfileParameters(object: { [key: string]: string | undefined }) {\n const profileObject: { [key: string]: string | undefined } = Object.keys(object).reduce((acc, key) => {\n acc[`profile.${key}`] = object[key];\n return acc;\n }, {} as { [key: string]: string | undefined });\n\n return profileObject;\n }\n\n public async getOffers(param: {\n mboxNames : 'config-mbox',\n parameters? : MboxParameters,\n profileParameters?: MboxProfileParameters\n }): Promise<ConfigMbox | undefined>;\n public async getOffers(param: {\n mboxNames : string,\n parameters? : MboxParameters,\n profileParameters?: MboxProfileParameters\n }): Promise<object | undefined>;\n public async getOffers(param: {\n mboxNames : string[],\n parameters? : MboxParameters,\n profileParameters?: MboxProfileParameters\n }): Promise<Record<string, object | undefined>>;\n public async getOffers(param: {\n mboxNames : string[] | string,\n parameters? : MboxParameters,\n profileParameters?: MboxProfileParameters\n }) {\n let { mboxNames } = param;\n const isInitialyArray = Array.isArray(mboxNames);\n const { parameters, profileParameters } = param;\n if (!Array.isArray(mboxNames)) {\n mboxNames = [mboxNames];\n }\n\n const cdpData = await this.cdpData;\n if (this.controller.signal?.aborted) {\n return mboxNames.length > 1 ? {} : undefined;\n }\n\n const notRequestedMboxes = mboxNames.filter(\n mbox => !this.cachedMboxes.has(`${mbox}_${JSON.stringify(parameters)}`)\n );\n if (notRequestedMboxes.length) {\n const notRequestedOffersCall = window.alloyProxy('sendEvent', {\n type : 'decisioning.propositionFetch',\n decisionScopes: notRequestedMboxes,\n data : {\n '__adobe': {\n 'target': Object.assign(\n {},\n this.urlParameters,\n this.profileUrlParameters,\n parameters ? parameters : {},\n profileParameters ? profileParameters : {},\n cdpData,\n this.transfromIntoProfileParameters(cdpData)\n )\n }\n }\n });\n\n notRequestedOffersCall.then(result => {\n const htmlPropositions = result.propositions.filter(\n proposition => proposition?.items?.some(item => item.data?.format?.includes('html') || !item.data)\n );\n const jsonPropositions = result.propositions.filter(\n proposition => proposition?.items?.some(item => item.data?.format?.includes('json'))\n ).map(proposition => {\n const { ...propositionCopy } = proposition;\n delete propositionCopy.items;\n delete propositionCopy.renderAttempted;\n return propositionCopy;\n });\n\n if (htmlPropositions.length) {\n window.alloyProxy('applyPropositions', {\n 'propositions': htmlPropositions,\n 'viewName' : window.location.href\n });\n }\n\n if (jsonPropositions.length) {\n AdobeDataLayerService.push(new DecisionsDisplayedEvent(jsonPropositions));\n }\n });\n\n notRequestedMboxes.forEach(mbox => {\n const receivedMboxOfferCall: Promise<object | undefined> = new Promise((resolve, reject) => {\n notRequestedOffersCall.then(result => {\n const mboxResult = result.propositions.find(\n (offer) => offer.scope === mbox\n )?.items?.[0]?.data?.content;\n\n resolve(mboxResult);\n }).catch(e => {\n reject(e);\n });\n\n this.controller.signal?.addEventListener('abort', reject);\n });\n\n this.cachedMboxes.set(`${mbox}_${JSON.stringify(parameters)}_${JSON.stringify(profileParameters)}`, receivedMboxOfferCall);\n });\n }\n\n const mboxesPromises = mboxNames.map(\n mboxName => this.cachedMboxes.get(`${mboxName}_${JSON.stringify(parameters)}_${JSON.stringify(profileParameters)}`)\n );\n const resolvedMboxes = await Promise.allSettled(mboxesPromises);\n\n const offersResult = mboxNames.reduce((acc, mboxName, index) => {\n acc[mboxName] = resolvedMboxes[index].status === 'fulfilled' ? resolvedMboxes[index].value : undefined;\n return acc;\n }, {} as Record<string, object | undefined>);\n\n return isInitialyArray ? offersResult : offersResult[mboxNames[0]];\n }\n}\n\nwindow.BD = window.BD || {};\nwindow.BD.state = window.BD.state || {};"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AA8BzH,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;IAClC,MAAM,CAA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AS,CAAC,iBAAiB,CAAC,EAAE,CAAC,CACpH,CAAC;QACF,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAEhE,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;YAC7D,GAAG,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YACvG,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAwC,CAAC,CAAC;QAE7C,OAAO,eAAe,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;CACF;AAED,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;AAC5B,MAAM,CAAC,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC","sourcesContent":["import { Constants } from '@repobit/dex-constants';\nimport { AdobeDataLayerService, CdpEvent, DecisionsDisplayedEvent, PageLoadStartedEvent } from '@repobit/dex-data-layer';\nimport {\n AlloyAppendIdentityToUrlResponse,\n AlloyApplyPropositionsResponse,\n AlloyFunction,\n AlloySendEventResponse,\n AppendIdentityToUrlCall,\n ApplyPropositionsCall,\n CdpData,\n CdpDataJson,\n ConfigMbox,\n GetIdentityCall,\n GetIdentityResponse,\n MboxParameters,\n MboxProfileParameters,\n SendEventCall,\n URLParameters\n} from './typeDefinitions';\n\ndeclare global {\n interface Window {\n alloyProxy: AlloyFunction;\n BD: {\n state: {\n cdpDataPromise: Promise<CdpData>\n }\n }\n }\n}\n\nif (!window.Promise.withResolvers) {\n window.Promise.withResolvers = function<T>() {\n let resolve, reject;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { resolve, reject, promise } as unknown as PromiseWithResolvers<T>;\n }\n}\n\nexport default class Target {\n private urlParameters : URLParameters;\n private profileUrlParameters: { [key: string]: string | undefined };\n private cachedMboxes : Map<string, Promise<object | undefined>>;\n private _configMbox : Promise<ConfigMbox | undefined>;\n private controller : AbortController = new AbortController();\n private _visitorInfo : Promise<GetIdentityResponse>;\n private cdpData : Promise<CdpData>;\n\n constructor(config?: Partial<{ pageLoadStartedEvent: PageLoadStartedEvent }>) {\n this.urlParameters = this.getUrlParameters();\n this.profileUrlParameters = this.transfromIntoProfileParameters(this.urlParameters);\n this.cachedMboxes = new Map();\n\n if (!window.alloyProxy) {\n function __alloy(...args: SendEventCall): Promise<AlloySendEventResponse>;\n function __alloy(...args: AppendIdentityToUrlCall): Promise<AlloyAppendIdentityToUrlResponse>;\n function __alloy(...args: ApplyPropositionsCall): Promise<AlloyApplyPropositionsResponse>;\n function __alloy(...args: GetIdentityCall): Promise<GetIdentityResponse>;\n function __alloy(...args: SendEventCall | AppendIdentityToUrlCall | ApplyPropositionsCall | GetIdentityCall):\n Promise<AlloySendEventResponse | AlloyAppendIdentityToUrlResponse | AlloyApplyPropositionsResponse | GetIdentityResponse> {\n return new Promise((resolve, reject) => {\n window.alloyProxy.q.push([resolve, reject, args]);\n });\n }\n\n window.alloyProxy = __alloy as AlloyFunction;\n window.alloyProxy.q = [];\n }\n\n // check for dotest=1 in URL. If it exists abort all target calls\n const urlParams = new URLSearchParams(window.location.search);\n if (urlParams.get('dotest') === '1') {\n this.abort();\n }\n\n this._visitorInfo = new Promise((resolve) => {\n if (this.controller.signal?.aborted) {\n resolve({});\n }\n\n window.alloyProxy('getIdentity').then(result => resolve(result))\n .catch(() => resolve({}));\n this.controller.signal?.addEventListener('abort', () => resolve({}));\n });\n this.cdpData = config?.pageLoadStartedEvent && urlParams.get('dotest') !== '1'\n ? this.sendCdpData(config?.pageLoadStartedEvent)\n : Promise.resolve({} as CdpData);\n this._configMbox = this.getOffers({ mboxNames: 'config-mbox' });\n }\n\n /** get an object containing all the url query parameters */\n private getUrlParameters(): URLParameters {\n const urlParams = new URLSearchParams(window.location.search);\n const parameters: URLParameters = {};\n\n urlParams.forEach((value: string, key: string) => {\n parameters[key] = value;\n });\n\n return parameters;\n }\n\n public get configMbox() {\n return this._configMbox;\n }\n\n public get visitorInfo() {\n return this._visitorInfo;\n }\n\n /** add adobe_mc parameter at the end of the url */\n public appendVisitorIDsTo(url: string): Promise<string> {\n if (this.controller.signal?.aborted || url.includes('adobe_mc')) {\n return Promise.resolve(url);\n }\n\n return new Promise((resolve) => {\n window.alloyProxy('appendIdentityToUrl', { url }).then(result => resolve(result.url))\n .catch(() => resolve(url));\n this.controller.signal?.addEventListener('abort', () => resolve(url));\n });\n }\n\n /** abort all the Target calls for casese where Target does not load */\n public abort(): void {\n this.controller.abort();\n }\n\n public async sendCdpData(pageLoadStartedEvent: PageLoadStartedEvent): Promise<CdpData> {\n const cdpDataPromise = Promise.withResolvers<CdpData>();\n let cdpData: CdpData = {};\n if (window.BD.state.cdpDataPromise) {\n return await window.BD.state.cdpDataPromise;\n }\n window.BD.state.cdpDataPromise = cdpDataPromise.promise;\n\n try {\n const ecid = (await this.visitorInfo)?.identity?.ECID;\n const cdpDataCall = await fetch(\n `${Constants.PUBLIC_URL_ORIGIN}/cdp/`,\n {\n method: 'POST',\n body : JSON.stringify({\n mcvisid: ecid || '',\n ...pageLoadStartedEvent.page\n })\n }\n );\n\n /** @type {{auds: string[], mdl: {key: string, value: string}[], ub: any[] vid: string}} */\n const receivedCdpData: CdpDataJson = await cdpDataCall.json();\n cdpData = {\n auds: receivedCdpData?.auds[0] || ''\n };\n\n if (receivedCdpData.mdl) {\n cdpData = receivedCdpData?.mdl.reduce((acc, mdlValue) => {\n acc[mdlValue.key] = mdlValue.value;\n return acc;\n }, cdpData);\n }\n\n AdobeDataLayerService.push(new CdpEvent(cdpData));\n } catch (e) {\n console.warn(e);\n }\n\n cdpDataPromise.resolve(cdpData);\n return cdpData;\n }\n\n private transfromIntoProfileParameters(object: { [key: string]: string | undefined }) {\n const profileObject: { [key: string]: string | undefined } = Object.keys(object).reduce((acc, key) => {\n acc[`profile.${key}`] = object[key];\n return acc;\n }, {} as { [key: string]: string | undefined });\n\n return profileObject;\n }\n\n public async getOffers(param: {\n mboxNames : 'config-mbox',\n parameters? : MboxParameters,\n profileParameters?: MboxProfileParameters\n }): Promise<ConfigMbox | undefined>;\n public async getOffers(param: {\n mboxNames : string,\n parameters? : MboxParameters,\n profileParameters?: MboxProfileParameters\n }): Promise<object | undefined>;\n public async getOffers(param: {\n mboxNames : string[],\n parameters? : MboxParameters,\n profileParameters?: MboxProfileParameters\n }): Promise<Record<string, object | undefined>>;\n public async getOffers(param: {\n mboxNames : string[] | string,\n parameters? : MboxParameters,\n profileParameters?: MboxProfileParameters\n }) {\n let { mboxNames } = param;\n const isInitialyArray = Array.isArray(mboxNames);\n const { parameters, profileParameters } = param;\n if (!Array.isArray(mboxNames)) {\n mboxNames = [mboxNames];\n }\n\n const cdpData = await this.cdpData;\n if (this.controller.signal?.aborted) {\n return mboxNames.length > 1 ? {} : undefined;\n }\n\n const notRequestedMboxes = mboxNames.filter(\n mbox => !this.cachedMboxes.has(`${mbox}_${JSON.stringify(parameters)}`)\n );\n if (notRequestedMboxes.length) {\n const notRequestedOffersCall = window.alloyProxy('sendEvent', {\n type : 'decisioning.propositionFetch',\n decisionScopes: notRequestedMboxes,\n data : {\n '__adobe': {\n 'target': Object.assign(\n {},\n this.urlParameters,\n this.profileUrlParameters,\n parameters ? parameters : {},\n profileParameters ? profileParameters : {},\n cdpData,\n this.transfromIntoProfileParameters(cdpData)\n )\n }\n }\n });\n\n notRequestedOffersCall.then(result => {\n const htmlPropositions = result.propositions.filter(\n proposition => proposition?.items?.some(item => item.data?.format?.includes('html') || !item.data)\n );\n const jsonPropositions = result.propositions.filter(\n proposition => proposition?.items?.some(item => item.data?.format?.includes('json'))\n ).map(proposition => {\n const { ...propositionCopy } = proposition;\n delete propositionCopy.items;\n delete propositionCopy.renderAttempted;\n return propositionCopy;\n });\n\n if (htmlPropositions.length) {\n window.alloyProxy('applyPropositions', {\n 'propositions': htmlPropositions,\n 'viewName' : window.location.href\n });\n }\n\n if (jsonPropositions.length) {\n AdobeDataLayerService.push(new DecisionsDisplayedEvent(jsonPropositions));\n }\n });\n\n notRequestedMboxes.forEach(mbox => {\n const receivedMboxOfferCall: Promise<object | undefined> = new Promise((resolve, reject) => {\n notRequestedOffersCall.then(result => {\n const mboxResult = result.propositions.find(\n (offer) => offer.scope === mbox\n )?.items?.[0]?.data?.content;\n\n resolve(mboxResult);\n }).catch(e => {\n reject(e);\n });\n\n this.controller.signal?.addEventListener('abort', reject);\n });\n\n this.cachedMboxes.set(`${mbox}_${JSON.stringify(parameters)}_${JSON.stringify(profileParameters)}`, receivedMboxOfferCall);\n });\n }\n\n const mboxesPromises = mboxNames.map(\n mboxName => this.cachedMboxes.get(`${mboxName}_${JSON.stringify(parameters)}_${JSON.stringify(profileParameters)}`)\n );\n const resolvedMboxes = await Promise.allSettled(mboxesPromises);\n\n const offersResult = mboxNames.reduce((acc, mboxName, index) => {\n acc[mboxName] = resolvedMboxes[index].status === 'fulfilled' ? resolvedMboxes[index].value : undefined;\n return acc;\n }, {} as Record<string, object | undefined>);\n\n return isInitialyArray ? offersResult : offersResult[mboxNames[0]];\n }\n}\n\nwindow.BD = window.BD || {};\nwindow.BD.state = window.BD.state || {};\n"]}
@@ -13,7 +13,7 @@ export type SendEventCall = [
13
13
  {
14
14
  type?: string;
15
15
  decisionScopes: string[];
16
- data: {
16
+ data?: {
17
17
  '__adobe': {
18
18
  'target': {
19
19
  [key: string]: string;
@@ -1 +1 @@
1
- {"version":3,"file":"typeDefinitions.js","sourceRoot":"","sources":["../../src/typeDefinitions.ts"],"names":[],"mappings":"","sourcesContent":["import { AlloyResponseDecision, AlloyResponsePropositions } from '@repobit/dex-data-layer';\n\nexport type MboxProfileParameters = {\n [key: `profile.${string}`]: string\n};\n\nexport type MboxParameters = {\n [key: string]: string\n};\n\nexport type URLParameters = {\n [key: string]: string\n};\n\nexport type SendEventCall = [\n 'sendEvent',\n {\n type ?: string,\n decisionScopes : string[],\n data: {\n '__adobe': {\n 'target': {\n [key: string]: string\n }\n }\n },\n renderDecisions?: boolean,\n }\n];\n\nexport type DisplayPropositionsCall = [\n 'sendEvent',\n Partial<{\n type : string,\n personalization: {\n decisionScopes: string[]\n }\n \"xdm\": {\n \"_experience\": {\n \"decisioning\": {\n \"propositions\":\n {\n \"id\" : string,\n \"scope\" : string,\n \"scopeDetails\": object\n }[],\n \"propositionEventType\": {\n \"display\": number\n }\n }\n }\n }\n }>\n];\n\nexport type AppendIdentityToUrlCall = [\n 'appendIdentityToUrl',\n { url: string }\n];\n\nexport type ApplyPropositionsCall = [\n 'applyPropositions',\n {\n propositions: AlloyResponsePropositions[],\n viewName : string\n }\n];\n\nexport type GetIdentityCall = [\n 'getIdentity'\n];\n\nexport type AlloySendEventResponse = {\n decisions : AlloyResponseDecision[],\n propositions: AlloyResponsePropositions[],\n destinations: object[]\n};\n\nexport type DisplayPropositionsResponse = {\n propositions: AlloyResponsePropositions[],\n destinations: object[]\n}\n\nexport type AlloyAppendIdentityToUrlResponse = {\n url: string\n}\n\nexport type AlloyApplyPropositionsResponse = {\n propositions: AlloyResponsePropositions[]\n}\n\nexport type GetIdentityResponse = Partial<{\n edge: {\n regionId?: number\n },\n identity: {\n ECID: string\n }\n}>;\n\nexport type AlloyFunction = {\n (...args: DisplayPropositionsCall): Promise<DisplayPropositionsResponse>,\n (...args: SendEventCall): Promise<AlloySendEventResponse>,\n (...args: AppendIdentityToUrlCall): Promise<AlloyAppendIdentityToUrlResponse>,\n (...args: ApplyPropositionsCall): Promise<AlloyApplyPropositionsResponse>\n (...args: GetIdentityCall): Promise<GetIdentityResponse>\n q: Array<\n [\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n resolve: Function,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n reject: Function,\n args: SendEventCall | AppendIdentityToUrlCall | ApplyPropositionsCall | GetIdentityCall | DisplayPropositionsCall\n ]\n >;\n};\n\nexport type ConfigMbox = Partial<{\n promotion: string,\n provider : 'init' | 'vlaicu',\n products: {\n [key: string]: {\n [key: `${number}-${number}`]: Partial<{\n extraParameters: {\n key : string,\n value: string\n }[],\n price : number,\n discountedPrice: number,\n buyLink : string\n }>\n }\n },\n useGeoIpPricing: boolean\n}>;\n\nexport type CdpData = {\n auds ?: string,\n [key: string] : string | undefined\n};\n\nexport type CdpDataJson = {\n auds: string[],\n mdl : { key: string, value: string }[],\n ub : unknown[],\n vid : string\n}"]}
1
+ {"version":3,"file":"typeDefinitions.js","sourceRoot":"","sources":["../../src/typeDefinitions.ts"],"names":[],"mappings":"","sourcesContent":["import { AlloyResponseDecision, AlloyResponsePropositions } from '@repobit/dex-data-layer';\n\nexport type MboxProfileParameters = {\n [key: `profile.${string}`]: string\n};\n\nexport type MboxParameters = {\n [key: string]: string\n};\n\nexport type URLParameters = {\n [key: string]: string\n};\n\nexport type SendEventCall = [\n 'sendEvent',\n {\n type ?: string,\n decisionScopes : string[],\n data?: {\n '__adobe': {\n 'target': {\n [key: string]: string\n }\n }\n },\n renderDecisions?: boolean,\n }\n];\n\nexport type DisplayPropositionsCall = [\n 'sendEvent',\n Partial<{\n type : string,\n personalization: {\n decisionScopes: string[]\n }\n \"xdm\": {\n \"_experience\": {\n \"decisioning\": {\n \"propositions\":\n {\n \"id\" : string,\n \"scope\" : string,\n \"scopeDetails\": object\n }[],\n \"propositionEventType\": {\n \"display\": number\n }\n }\n }\n }\n }>\n];\n\nexport type AppendIdentityToUrlCall = [\n 'appendIdentityToUrl',\n { url: string }\n];\n\nexport type ApplyPropositionsCall = [\n 'applyPropositions',\n {\n propositions: AlloyResponsePropositions[],\n viewName : string\n }\n];\n\nexport type GetIdentityCall = [\n 'getIdentity'\n];\n\nexport type AlloySendEventResponse = {\n decisions : AlloyResponseDecision[],\n propositions: AlloyResponsePropositions[],\n destinations: object[]\n};\n\nexport type DisplayPropositionsResponse = {\n propositions: AlloyResponsePropositions[],\n destinations: object[]\n}\n\nexport type AlloyAppendIdentityToUrlResponse = {\n url: string\n}\n\nexport type AlloyApplyPropositionsResponse = {\n propositions: AlloyResponsePropositions[]\n}\n\nexport type GetIdentityResponse = Partial<{\n edge: {\n regionId?: number\n },\n identity: {\n ECID: string\n }\n}>;\n\nexport type AlloyFunction = {\n (...args: DisplayPropositionsCall): Promise<DisplayPropositionsResponse>,\n (...args: SendEventCall): Promise<AlloySendEventResponse>,\n (...args: AppendIdentityToUrlCall): Promise<AlloyAppendIdentityToUrlResponse>,\n (...args: ApplyPropositionsCall): Promise<AlloyApplyPropositionsResponse>\n (...args: GetIdentityCall): Promise<GetIdentityResponse>\n q: Array<\n [\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n resolve: Function,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n reject: Function,\n args: SendEventCall | AppendIdentityToUrlCall | ApplyPropositionsCall | GetIdentityCall | DisplayPropositionsCall\n ]\n >;\n};\n\nexport type ConfigMbox = Partial<{\n promotion: string,\n provider : 'init' | 'vlaicu',\n products: {\n [key: string]: {\n [key: `${number}-${number}`]: Partial<{\n extraParameters: {\n key : string,\n value: string\n }[],\n price : number,\n discountedPrice: number,\n buyLink : string\n }>\n }\n },\n useGeoIpPricing: boolean\n}>;\n\nexport type CdpData = {\n auds ?: string,\n [key: string] : string | undefined\n};\n\nexport type CdpDataJson = {\n auds: string[],\n mdl : { key: string, value: string }[],\n ub : unknown[],\n vid : string\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repobit/dex-target",
3
- "version": "2.5.20",
3
+ "version": "2.7.0",
4
4
  "description": "Client for Adobe Target",
5
5
  "author": "Constantin Ioan Mihai <iconstantin@bitdefender.com>",
6
6
  "homepage": "https://github.com/bitdefender/dex-core#readme",
@@ -36,5 +36,5 @@
36
36
  "volta": {
37
37
  "node": "22.14.0"
38
38
  },
39
- "gitHead": "6fcaf5133ff6a150fd7d2d3e8a261f9b88b35bc1"
39
+ "gitHead": "9277ae7012baa64b927c63e6569989bd79f569d3"
40
40
  }