@repobit/dex-target 2.10.0 → 2.12.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.12.0](https://github.com/bitdefender/dex-core/compare/@repobit/dex-target@2.11.0...@repobit/dex-target@2.12.0) (2026-02-09)
7
+
8
+
9
+ ### Features
10
+
11
+ * **DEX-26312:** add json parse to propositions ([8be0046](https://github.com/bitdefender/dex-core/commit/8be004681fca7ddc38fd9b6348df305260d27759))
12
+
13
+
14
+
15
+ ## [2.11.0](https://github.com/bitdefender/dex-core/compare/@repobit/dex-target@2.10.0...@repobit/dex-target@2.11.0) (2026-02-05)
16
+
17
+
18
+ ### Features
19
+
20
+ * **DEX-25763:** enhance CDP data handling by adding visitor type support ([0d16bb3](https://github.com/bitdefender/dex-core/commit/0d16bb31f0017b9a06bfd7bb9c591e7386460b32))
21
+
22
+
23
+
6
24
  ## [2.10.0](https://github.com/bitdefender/dex-core/compare/@repobit/dex-target@2.9.0...@repobit/dex-target@2.10.0) (2026-02-03)
7
25
 
8
26
 
package/dist/src/index.js CHANGED
@@ -106,6 +106,12 @@ export default class Target {
106
106
  return acc;
107
107
  }, cdpData);
108
108
  }
109
+ if (receivedCdpData.ub) {
110
+ cdpData = receivedCdpData?.ub.reduce((acc, ubValue) => {
111
+ acc[ubValue.key] = ubValue.value;
112
+ return acc;
113
+ }, cdpData);
114
+ }
109
115
  AdobeDataLayerService.push(new CdpEvent(cdpData));
110
116
  }
111
117
  catch (e) {
@@ -144,8 +150,24 @@ export default class Target {
144
150
  }
145
151
  });
146
152
  notRequestedOffersCall.then(result => {
147
- const htmlPropositions = result.propositions.filter(proposition => proposition?.items?.some(item => item.data?.format?.includes('html') || !item.data));
148
- const jsonPropositions = result.propositions.filter(proposition => proposition?.items?.some(item => item.data?.format?.includes('json'))).map(proposition => {
153
+ const htmlPropositions = result.propositions.filter(proposition => proposition?.items?.some(item => {
154
+ try {
155
+ JSON.parse(`${item?.data?.content}`);
156
+ return false;
157
+ }
158
+ catch {
159
+ return true;
160
+ }
161
+ }));
162
+ const jsonPropositions = result.propositions.filter(proposition => proposition?.items?.some(item => {
163
+ try {
164
+ JSON.parse(`${item?.data?.content}`);
165
+ return true;
166
+ }
167
+ catch {
168
+ return false;
169
+ }
170
+ })).map(proposition => {
149
171
  const { ...propositionCopy } = proposition;
150
172
  delete propositionCopy.items;
151
173
  delete propositionCopy.renderAttempted;
@@ -176,8 +198,16 @@ export default class Target {
176
198
  }
177
199
  const mboxesPromises = mboxNames.map(mboxName => this.cachedMboxes.get(`${mboxName}_${JSON.stringify(parameters)}_${JSON.stringify(profileParameters)}`));
178
200
  const resolvedMboxes = await Promise.allSettled(mboxesPromises);
201
+ const tryParse = (content) => {
202
+ try {
203
+ return JSON.parse(`${content}`);
204
+ }
205
+ catch {
206
+ return content;
207
+ }
208
+ };
179
209
  const offersResult = mboxNames.reduce((acc, mboxName, index) => {
180
- acc[mboxName] = resolvedMboxes[index].status === 'fulfilled' ? resolvedMboxes[index].value?.items?.[0]?.data?.content : undefined;
210
+ acc[mboxName] = resolvedMboxes[index].status === 'fulfilled' ? tryParse(resolvedMboxes[index].value?.items?.[0]?.data?.content) : undefined;
181
211
  return acc;
182
212
  }, {});
183
213
  return isInitialyArray ? offersResult : offersResult[mboxNames[0]];
@@ -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,EAA6B,QAAQ,EAAE,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AA8BpJ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;IAClC,MAAM,CAAC,OAA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,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, AlloyResponsePropositions, 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<AlloyResponsePropositions | 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<AlloyResponsePropositions | undefined> = new Promise((resolve, reject) => {\n notRequestedOffersCall.then(result => {\n const mboxResult = result.propositions.find(\n (offer) => offer.scope === mbox\n );\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?.items?.[0]?.data?.content : undefined;\n return acc;\n }, {} as Record<string, object | undefined>);\n\n return isInitialyArray ? offersResult : offersResult[mboxNames[0]];\n }\n\n public async getMboxProposition<T extends object = object>(\n param: { mboxName: string, parameters?: MboxParameters, profileParameters?: MboxProfileParameters }\n ): Promise<AlloyResponsePropositions<T> | undefined> {\n return await this.cachedMboxes.get(\n `${param.mboxName}_${JSON.stringify(param.parameters)}_${JSON.stringify(param.profileParameters)}`\n ) as AlloyResponsePropositions<T> | undefined;\n }\n\n public async trackOffer(param: { id: AlloyResponsePropositions[\"id\"], scope: AlloyResponsePropositions[\"scope\"], scopeDetails: AlloyResponsePropositions[\"scopeDetails\"] }) {\n await window.alloyProxy('sendEvent', {\n type: 'decisioning.propositionInteract',\n xdm : {\n _experience: {\n decisioning: {\n propositions: [\n {\n id : param.id,\n scope : param.scope,\n scopeDetails: param.scopeDetails\n }\n ]\n }\n }\n }\n });\n }\n}\n\nwindow.BD = window.BD || {};\nwindow.BD.state = window.BD.state || {};\n"]}
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,EAA6B,QAAQ,EAAE,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AA8BpJ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;IAClC,MAAM,CAAC,OAAO,CAAC,aAAa,GAAG;QAC7B,IAAI,OAAO,EAAE,MAAM,CAAC;QACpB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAA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M,KAAK,CAAC,kBAAkB,CAC7B,KAAmG;QAEnG,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAChC,GAAG,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CACvD,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,KAAkJ;QACxK,MAAM,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,iCAAiC;YACvC,GAAG,EAAG;gBACJ,WAAW,EAAE;oBACX,WAAW,EAAE;wBACX,YAAY,EAAE;4BACZ;gCACE,EAAE,EAAY,KAAK,CAAC,EAAE;gCACtB,KAAK,EAAS,KAAK,CAAC,KAAK;gCACzB,YAAY,EAAE,KAAK,CAAC,YAAY;6BACjC;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAC;IACL,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, AlloyResponsePropositions, 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<AlloyResponsePropositions | 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 if (receivedCdpData.ub) {\n cdpData = receivedCdpData?.ub.reduce((acc, ubValue) => {\n acc[ubValue.key] = ubValue.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 => {\n try {\n JSON.parse(`${item?.data?.content}`);\n return false;\n } catch {\n return true;\n }\n }));\n\n const jsonPropositions = result.propositions.filter(\n proposition => proposition?.items?.some(item => {\n try {\n JSON.parse(`${item?.data?.content}`);\n return true;\n } catch {\n return false;\n }\n })\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<AlloyResponsePropositions | undefined> = new Promise((resolve, reject) => {\n notRequestedOffersCall.then(result => {\n const mboxResult = result.propositions.find(\n (offer) => offer.scope === mbox\n );\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 const tryParse = (content: unknown) => {\n try {\n return JSON.parse(`${content}`);\n } catch {\n return content;\n }\n };\n\n const offersResult = mboxNames.reduce((acc, mboxName, index) => {\n acc[mboxName] = resolvedMboxes[index].status === 'fulfilled' ? tryParse(resolvedMboxes[index].value?.items?.[0]?.data?.content) : undefined;\n return acc;\n }, {} as Record<string, object | undefined>);\n\n return isInitialyArray ? offersResult : offersResult[mboxNames[0]];\n }\n\n public async getMboxProposition<T extends object = object>(\n param: { mboxName: string, parameters?: MboxParameters, profileParameters?: MboxProfileParameters }\n ): Promise<AlloyResponsePropositions<T> | undefined> {\n return await this.cachedMboxes.get(\n `${param.mboxName}_${JSON.stringify(param.parameters)}_${JSON.stringify(param.profileParameters)}`\n ) as AlloyResponsePropositions<T> | undefined;\n }\n\n public async trackOffer(param: { id: AlloyResponsePropositions[\"id\"], scope: AlloyResponsePropositions[\"scope\"], scopeDetails: AlloyResponsePropositions[\"scopeDetails\"] }) {\n await window.alloyProxy('sendEvent', {\n type: 'decisioning.propositionInteract',\n xdm : {\n _experience: {\n decisioning: {\n propositions: [\n {\n id : param.id,\n scope : param.scope,\n scopeDetails: param.scopeDetails\n }\n ]\n }\n }\n }\n });\n }\n}\n\nwindow.BD = window.BD || {};\nwindow.BD.state = window.BD.state || {};\n"]}
@@ -132,6 +132,9 @@ export type CdpDataJson = {
132
132
  key: string;
133
133
  value: string;
134
134
  }[];
135
- ub: unknown[];
135
+ ub: {
136
+ key: string;
137
+ value: string;
138
+ }[];
136
139
  vid: string;
137
140
  };
@@ -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 xdm?: {\n _experience?: {\n decisioning?: {\n propositions?: object[],\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 xdm?: {\n _experience?: {\n decisioning?: {\n propositions?: object[],\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 : { key: string, value: string }[],\n vid : string\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repobit/dex-target",
3
- "version": "2.10.0",
3
+ "version": "2.12.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": "8ca0efc414789020c41463cbe11cd8ad1dc209c7"
39
+ "gitHead": "5061c92fe41ef853077b7ccdd35da03a4e6ffb54"
40
40
  }