diff --git a/dist/mparticle.common.js b/dist/mparticle.common.js index 8879f11a9..23929032a 100644 --- a/dist/mparticle.common.js +++ b/dist/mparticle.common.js @@ -1401,7 +1401,7 @@ ScCid:{mappedKey:"SnapchatConversions.ClickId",output:IntegrationOutputs.CUSTOM_ // } for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.applyProcessors=function(a,b,c){var d,e={};for(var f in a)if(a.hasOwnProperty(f)){var g=a[f],h=null===(d=integrationMapping[f])||void 0===d?void 0:d.processor;e[f]=h?h(g,b,c):g;}return e},a.prototype.filterMappings=function(a){var b={};for(var c in integrationMapping)integrationMapping[c].output===a&&(b[c]=integrationMapping[c]);return b},a}(); -var RoktManager=/** @class */function(){function a(){this.launcher=null,this.messageQueue=[],this.launcher=null;}return a.prototype.attachLauncher=function(a){this.setLauncher(a),this.processMessageQueue();},a.prototype.selectPlacements=function(a){if(!this.launcher)return this.queueMessage({methodName:"selectPlacements",payload:a}),Promise.resolve({});try{return this.launcher.selectPlacements(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.processMessageQueue=function(){var a=this;0All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced multiple instances. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.

diff --git a/dist/mparticle.esm.js b/dist/mparticle.esm.js index b9d0e0281..0bb1b8a5b 100644 --- a/dist/mparticle.esm.js +++ b/dist/mparticle.esm.js @@ -1401,7 +1401,7 @@ ScCid:{mappedKey:"SnapchatConversions.ClickId",output:IntegrationOutputs.CUSTOM_ // } for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.applyProcessors=function(a,b,c){var d,e={};for(var f in a)if(a.hasOwnProperty(f)){var g=a[f],h=null===(d=integrationMapping[f])||void 0===d?void 0:d.processor;e[f]=h?h(g,b,c):g;}return e},a.prototype.filterMappings=function(a){var b={};for(var c in integrationMapping)integrationMapping[c].output===a&&(b[c]=integrationMapping[c]);return b},a}(); -var RoktManager=/** @class */function(){function a(){this.launcher=null,this.messageQueue=[],this.launcher=null;}return a.prototype.attachLauncher=function(a){this.setLauncher(a),this.processMessageQueue();},a.prototype.selectPlacements=function(a){if(!this.launcher)return this.queueMessage({methodName:"selectPlacements",payload:a}),Promise.resolve({});try{return this.launcher.selectPlacements(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.processMessageQueue=function(){var a=this;0All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced multiple instances. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.

diff --git a/dist/mparticle.js b/dist/mparticle.js index 53b744f8b..f974ba6b4 100644 --- a/dist/mparticle.js +++ b/dist/mparticle.js @@ -9623,6 +9623,10 @@ var mParticle = (function () { return Promise.resolve({}); } try { + var preSelectionAttributes = this.launcher.preSelectionCallback(); + console.log('[RoktManager] preSelectionAttributes', preSelectionAttributes); + options.attributes = __assign(__assign({}, options.attributes), preSelectionAttributes); + console.log('[RoktManager] selectPlacement attributes', options.attributes); return this.launcher.selectPlacements(options); } catch (error) { return Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred')); diff --git a/src/roktManager.ts b/src/roktManager.ts index a00db28a8..917807aef 100644 --- a/src/roktManager.ts +++ b/src/roktManager.ts @@ -18,6 +18,7 @@ export interface IRoktSelection { export interface IRoktLauncher { selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise; + preSelectionCallback: () => IRoktPartnerAttributes; } export interface IRoktMessage { @@ -48,6 +49,10 @@ export default class RoktManager { } try { + const preSelectionAttributes = this.launcher.preSelectionCallback(); + console.log('[RoktManager] preSelectionAttributes', preSelectionAttributes); + options.attributes = { ...options.attributes, ...preSelectionAttributes }; + console.log('[RoktManager] selectPlacement attributes', options.attributes); return this.launcher.selectPlacements(options); } catch (error) { return Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred')); diff --git a/test/jest/roktManager.spec.ts b/test/jest/roktManager.spec.ts index 24bbb6d5d..73c6016a5 100644 --- a/test/jest/roktManager.spec.ts +++ b/test/jest/roktManager.spec.ts @@ -26,7 +26,8 @@ describe('RoktManager', () => { it('should process the message queue if a launcher is attached', () => { const launcher: IRoktLauncher = { - selectPlacements: jest.fn() + selectPlacements: jest.fn(), + preSelectionCallback: jest.fn() }; roktManager.selectPlacements({} as IRoktSelectPlacementsOptions); @@ -45,7 +46,8 @@ describe('RoktManager', () => { describe('#selectPlacements', () => { it('should call launcher.selectPlacements with empty attributes', () => { const launcher: IRoktLauncher = { - selectPlacements: jest.fn() + selectPlacements: jest.fn(), + preSelectionCallback: jest.fn() }; roktManager.attachLauncher(launcher); @@ -59,7 +61,8 @@ describe('RoktManager', () => { it('should call launcher.selectPlacements with passed in attributes', () => { const launcher: IRoktLauncher = { - selectPlacements: jest.fn() + selectPlacements: jest.fn(), + preSelectionCallback: jest.fn() }; roktManager.attachLauncher(launcher); @@ -93,7 +96,8 @@ describe('RoktManager', () => { it('should process queued selectPlacements calls once the launcher is attached', () => { const launcher: IRoktLauncher = { - selectPlacements: jest.fn() + selectPlacements: jest.fn(), + preSelectionCallback: jest.fn() }; const options = {