diff --git a/modules/optimeraRtdProvider.js b/modules/optimeraRtdProvider.js index b7ce3c6c6d9..024a558baca 100644 --- a/modules/optimeraRtdProvider.js +++ b/modules/optimeraRtdProvider.js @@ -173,7 +173,9 @@ export function setScoresURL() { } /** - * Set the scores for the divice if given. + * Set the scores for the device if given. + * Add any any insights to the winddow.optimeraInsights object. + * * @param {*} result * @returns {string} JSON string of Optimera Scores. */ @@ -184,6 +186,11 @@ export function setScores(result) { if (device !== 'default' && scores.device[device]) { scores = scores.device[device]; } + logInfo(scores); + if (scores.insights) { + window.optimeraInsights = window.optimeraInsights || {}; + window.optimeraInsights.data = scores.insights; + } } catch (e) { logError('Optimera score file could not be parsed.'); } diff --git a/test/spec/modules/optimeraRtdProvider_spec.js b/test/spec/modules/optimeraRtdProvider_spec.js index 8b1866d044a..7883412ab70 100644 --- a/test/spec/modules/optimeraRtdProvider_spec.js +++ b/test/spec/modules/optimeraRtdProvider_spec.js @@ -35,17 +35,30 @@ describe('Optimera RTD score file properly sets targeting values', () => { 'de': { 'div-0': ['A5', 'A6'], 'div-1': ['A7', 'A8'], + 'insights': { + 'ilv': ['div-0'], + 'miv': ['div-4'], + } }, 'mo': { 'div-0': ['A9', 'B0'], 'div-1': ['B1', 'B2'], + 'insights': { + 'ilv': ['div-1'], + 'miv': ['div-2'], + } } + }, + 'insights': { + 'ilv': ['div-5'], + 'miv': ['div-6'], } }; - it('Properly set the score file url', () => { + it('Properly set the score file url and scores', () => { optimeraRTD.setScores(JSON.stringify(scores)); expect(optimeraRTD.optimeraTargeting['div-0']).to.include.ordered.members(['A5', 'A6']); expect(optimeraRTD.optimeraTargeting['div-1']).to.include.ordered.members(['A7', 'A8']); + expect(window.optimeraInsights.data['ilv']).to.include.ordered.members(['div-0']); }); });