Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OptimeraRTD Module: Expose non-ad related data to the page. (#7849) #7850

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion modules/optimeraRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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.');
}
Expand Down
15 changes: 14 additions & 1 deletion test/spec/modules/optimeraRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
});
});

Expand Down