From 5bdf5d4e8ddedc176286be98d6f9c72fdb0e5e60 Mon Sep 17 00:00:00 2001 From: Ariel <155993606+arielmtk@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:13:26 -0300 Subject: [PATCH 1/7] Adds prefix to ortb data --- modules/mobianRtdProvider.js | 127 ++++++++++++-------- test/spec/modules/mobianRtdProvider_spec.js | 51 +++++++- 2 files changed, 124 insertions(+), 54 deletions(-) diff --git a/modules/mobianRtdProvider.js b/modules/mobianRtdProvider.js index 02f2d1b83cf..0256118742a 100644 --- a/modules/mobianRtdProvider.js +++ b/modules/mobianRtdProvider.js @@ -37,15 +37,24 @@ import { setKeyValue } from '../libraries/gptUtils/gptUtils.js'; export const MOBIAN_URL = 'https://prebid.outcomes.net/api/prebid/v1/assessment/async'; +const AP_VALUES = 'apValues'; +const CATEGORIES = 'categories'; +const EMOTIONS = 'emotions'; +const GENRES = 'genres'; +const RISK = 'risk'; +const SENTIMENT = 'sentiment'; +const THEMES = 'themes'; +const TONES = 'tones'; + export const CONTEXT_KEYS = [ - 'apValues', - 'categories', - 'emotions', - 'genres', - 'risk', - 'sentiment', - 'themes', - 'tones' + AP_VALUES, + CATEGORIES, + EMOTIONS, + GENRES, + RISK, + SENTIMENT, + THEMES, + TONES ]; const AP_KEYS = ['a0', 'a1', 'p0', 'p1']; @@ -73,6 +82,31 @@ function makeMemoizedFetch() { export const getContextData = makeMemoizedFetch(); +/** + * @param {MobianConfig} config + * @param {MobianContextData} contextData + * @returns {Object} + */ +export function contextDataToKeyValues(config, contextData) { + const { prefix } = config; + const keyValues = CONTEXT_KEYS.reduce((acc, key) => { + const newAcc = { ...acc }; + if (key === AP_VALUES) { + AP_KEYS.forEach((apKey) => { + if (!contextData[key]?.[apKey]?.length) return; + newAcc[`${prefix}_ap_${apKey}`] = contextData[key][apKey] + }); + return newAcc; + } + + if (contextData[key]?.length) { + newAcc[`${prefix}_${key}`] = contextData[key]; + } + return newAcc; + }, {}); + return keyValues; +} + export async function fetchContextData() { const pageUrl = encodeURIComponent(window.location.href); const requestUrl = `${MOBIAN_URL}?url=${pageUrl}`; @@ -101,33 +135,21 @@ export function getConfig(config) { } /** - * @param {MobianConfigParams} parsedConfig + * @param {MobianConfig} config * @param {MobianContextData} contextData - * @returns {function} */ -export function setTargeting(parsedConfig, contextData) { - const { publisherTargeting, prefix } = parsedConfig; +export function setTargeting(config, contextData) { logMessage('context', contextData); - - CONTEXT_KEYS.forEach((key) => { - if (!publisherTargeting.includes(key)) return; - - if (key === 'apValues') { - AP_KEYS.forEach((apKey) => { - if (!contextData[key]?.[apKey]?.length) return; - logMessage(`${prefix}_ap_${apKey}`, contextData[key][apKey]); - setKeyValue(`${prefix}_ap_${apKey}`, contextData[key][apKey]); - }); - return; - } - - if (contextData[key]?.length) { - logMessage(`${prefix}_${key}`, contextData[key]); - setKeyValue(`${prefix}_${key}`, contextData[key]); - } - }); + const filteredContextData = Object.entries(contextData).filter(([key]) => config.publisherTargeting.includes(key)); + const data = Object.fromEntries(filteredContextData); + const keyValues = contextDataToKeyValues(config, data); + Object.entries(keyValues).forEach(([key, value]) => setKeyValue(key, value)); } +/** + * @param {Object|string} contextData + * @returns {MobianContextData} + */ export function makeDataFromResponse(contextData) { const data = typeof contextData === 'string' ? safeJSONParse(contextData) : contextData; const results = data.results; @@ -135,25 +157,33 @@ export function makeDataFromResponse(contextData) { return {}; } return { - apValues: results.ap || {}, - categories: results.mobianContentCategories, - emotions: results.mobianEmotions, - genres: results.mobianGenres, - risk: results.mobianRisk || 'unknown', - sentiment: results.mobianSentiment || 'unknown', - themes: results.mobianThemes, - tones: results.mobianTones, + [AP_VALUES]: results.ap || {}, + [CATEGORIES]: results.mobianContentCategories, + [EMOTIONS]: results.mobianEmotions, + [GENRES]: results.mobianGenres, + [RISK]: results.mobianRisk || 'unknown', + [SENTIMENT]: results.mobianSentiment || 'unknown', + [THEMES]: results.mobianThemes, + [TONES]: results.mobianTones, }; } -export function extendBidRequestConfig(bidReqConfig, contextData) { +/** + * @param {Object} bidReqConfig + * @param {MobianContextData} contextData + * @param {MobianConfig} config + */ +export function extendBidRequestConfig(bidReqConfig, contextData, config) { logMessage('extendBidRequestConfig', bidReqConfig, contextData); const { site: ortb2Site } = bidReqConfig.ortb2Fragments.global; + const filteredContextData = Object.entries(contextData).filter(([key]) => config.advertiserTargeting.includes(key)); + const keyValues = contextDataToKeyValues(config, filteredContextData); + ortb2Site.ext = ortb2Site.ext || {}; ortb2Site.ext.data = { ...(ortb2Site.ext.data || {}), - ...contextData + ...keyValues }; return bidReqConfig; @@ -163,22 +193,23 @@ export function extendBidRequestConfig(bidReqConfig, contextData) { * @param {MobianConfig} config * @returns {boolean} */ -function init(config) { - logMessage('init', config); +function init(rawConfig) { + logMessage('init', rawConfig); - const parsedConfig = getConfig(config); + const config = getConfig(rawConfig); - if (parsedConfig.publisherTargeting.length) { - getContextData().then((contextData) => setTargeting(parsedConfig, contextData)); + if (config.publisherTargeting.length) { + getContextData().then((contextData) => setTargeting(config, contextData)); } return true; } -function getBidRequestData(bidReqConfig, callback, config) { +function getBidRequestData(bidReqConfig, callback, rawConfig) { logMessage('getBidRequestData', bidReqConfig); - const { advertiserTargeting } = getConfig(config); + const config = getConfig(rawConfig); + const { advertiserTargeting } = config; if (!advertiserTargeting.length) { callback(); @@ -187,7 +218,7 @@ function getBidRequestData(bidReqConfig, callback, config) { getContextData() .then((contextData) => { - extendBidRequestConfig(bidReqConfig, contextData); + extendBidRequestConfig(bidReqConfig, contextData, config); }) .catch(() => {}) .finally(() => callback()); diff --git a/test/spec/modules/mobianRtdProvider_spec.js b/test/spec/modules/mobianRtdProvider_spec.js index 796a79e4e1c..9d52cd1c128 100644 --- a/test/spec/modules/mobianRtdProvider_spec.js +++ b/test/spec/modules/mobianRtdProvider_spec.js @@ -4,6 +4,7 @@ import * as ajax from 'src/ajax.js'; import * as gptUtils from 'libraries/gptUtils/gptUtils.js'; import { CONTEXT_KEYS, + contextDataToKeyValues, extendBidRequestConfig, fetchContextData, getConfig, @@ -45,6 +46,21 @@ describe('Mobian RTD Submodule', function () { tones: [], } + const mockKeyValues = { + 'mobian_ap_a1': [2313, 12], + 'mobian_ap_p0': [1231231, 212], + 'mobian_ap_p1': [231, 419], + 'mobian_emotions': ['affection'], + 'mobian_risk': 'low', + 'mobian_sentiment': 'positive', + } + + const mockConfig = { + prefix: 'mobian', + publisherTargeting: ['apValues', 'emotions', 'risk', 'sentiment', 'themes', 'tones', 'genres'], + advertiserTargeting: ['apValues', 'emotions', 'risk', 'sentiment', 'themes', 'tones', 'genres'], + } + beforeEach(function () { bidReqConfig = { ortb2Fragments: { @@ -155,8 +171,8 @@ describe('Mobian RTD Submodule', function () { describe('extendBidRequestConfig', function () { it('should extend bid request config with context data', function () { - const extendedConfig = extendBidRequestConfig(bidReqConfig, mockContextData); - expect(extendedConfig.ortb2Fragments.global.site.ext.data).to.deep.equal(mockContextData); + const extendedConfig = extendBidRequestConfig(bidReqConfig, mockContextData, mockConfig); + expect(extendedConfig.ortb2Fragments.global.site.ext.data).to.deep.equal(mockKeyValues); }); it('should not override existing data', function () { @@ -164,17 +180,17 @@ describe('Mobian RTD Submodule', function () { existing: 'data' }; - const extendedConfig = extendBidRequestConfig(bidReqConfig, mockContextData); + const extendedConfig = extendBidRequestConfig(bidReqConfig, mockContextData, mockConfig); expect(extendedConfig.ortb2Fragments.global.site.ext.data).to.deep.equal({ existing: 'data', - ...mockContextData + ...mockKeyValues }); }); it('should create data object if missing', function () { delete bidReqConfig.ortb2Fragments.global.site.ext.data; - const extendedConfig = extendBidRequestConfig(bidReqConfig, mockContextData); - expect(extendedConfig.ortb2Fragments.global.site.ext.data).to.deep.equal(mockContextData); + const extendedConfig = extendBidRequestConfig(bidReqConfig, mockContextData, mockConfig); + expect(extendedConfig.ortb2Fragments.global.site.ext.data).to.deep.equal(mockKeyValues); }); }); @@ -242,4 +258,27 @@ describe('Mobian RTD Submodule', function () { }); }); }); + + describe('contextDataToKeyValues', function () { + it('should format context data to key-value pairs', function () { + const config = getConfig({ + name: 'mobianBrandSafety', + params: { + prefix: 'mobiantest', + publisherTargeting: true, + advertiserTargeting: true, + } + }); + const mockKeyValues = { + 'mobiantest_ap_a1': [2313, 12], + 'mobiantest_ap_p0': [1231231, 212], + 'mobiantest_ap_p1': [231, 419], + 'mobiantest_emotions': ['affection'], + 'mobiantest_risk': 'low', + 'mobiantest_sentiment': 'positive', + }; + const keyValues = contextDataToKeyValues(config, mockContextData); + expect(keyValues).to.deep.equal(mockKeyValues); + }); + }); }); From 4eee43b4f74d160ae9ce13a27085d132075ba140 Mon Sep 17 00:00:00 2001 From: Ariel <155993606+arielmtk@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:11:36 -0300 Subject: [PATCH 2/7] Updates --- modules/mobianRtdProvider.js | 37 ++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/modules/mobianRtdProvider.js b/modules/mobianRtdProvider.js index 0256118742a..1b16f6ea6ca 100644 --- a/modules/mobianRtdProvider.js +++ b/modules/mobianRtdProvider.js @@ -82,6 +82,8 @@ function makeMemoizedFetch() { export const getContextData = makeMemoizedFetch(); +const entriesToObjectReducer = (acc, [key, value]) => ({ ...acc, [key]: value }); + /** * @param {MobianConfig} config * @param {MobianContextData} contextData @@ -107,6 +109,22 @@ export function contextDataToKeyValues(config, contextData) { return keyValues; } +function makeContextDataToKeyValuesReducer(config) { + const { prefix } = config; + return function contextDataToKeyValuesReducer(keyValues, [key, value]) { + if (key === AP_VALUES) { + AP_KEYS.forEach((apKey) => { + if (!value?.[apKey]?.length) return; + keyValues.push([`${prefix}_ap_${apKey}`, value[apKey]]); + }); + } + if (value?.length) { + keyValues.push([`${prefix}_${key}`, value]); + } + return keyValues; + } +} + export async function fetchContextData() { const pageUrl = encodeURIComponent(window.location.href); const requestUrl = `${MOBIAN_URL}?url=${pageUrl}`; @@ -140,10 +158,11 @@ export function getConfig(config) { */ export function setTargeting(config, contextData) { logMessage('context', contextData); - const filteredContextData = Object.entries(contextData).filter(([key]) => config.publisherTargeting.includes(key)); - const data = Object.fromEntries(filteredContextData); - const keyValues = contextDataToKeyValues(config, data); - Object.entries(keyValues).forEach(([key, value]) => setKeyValue(key, value)); + const keyValues = Object.entries(contextData) + .filter(([key]) => config.publisherTargeting.includes(key)) + .reduce(makeContextDataToKeyValuesReducer(config), []) + + keyValues.forEach(([key, value]) => setKeyValue(key, value)); } /** @@ -176,9 +195,10 @@ export function makeDataFromResponse(contextData) { export function extendBidRequestConfig(bidReqConfig, contextData, config) { logMessage('extendBidRequestConfig', bidReqConfig, contextData); const { site: ortb2Site } = bidReqConfig.ortb2Fragments.global; - - const filteredContextData = Object.entries(contextData).filter(([key]) => config.advertiserTargeting.includes(key)); - const keyValues = contextDataToKeyValues(config, filteredContextData); + const keyValues = Object.entries(contextData) + .filter(([key]) => config.advertiserTargeting.includes(key)) + .reduce(makeContextDataToKeyValuesReducer(config), []) + .reduce(entriesToObjectReducer, {}); ortb2Site.ext = ortb2Site.ext || {}; ortb2Site.ext.data = { @@ -195,13 +215,10 @@ export function extendBidRequestConfig(bidReqConfig, contextData, config) { */ function init(rawConfig) { logMessage('init', rawConfig); - const config = getConfig(rawConfig); - if (config.publisherTargeting.length) { getContextData().then((contextData) => setTargeting(config, contextData)); } - return true; } From e64baaed743eca169e1b2c3036528466a7a3409f Mon Sep 17 00:00:00 2001 From: Ariel <155993606+arielmtk@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:20:14 -0300 Subject: [PATCH 3/7] Fixes tests --- modules/mobianRtdProvider.js | 27 +-------------------- test/spec/modules/mobianRtdProvider_spec.js | 19 +++++---------- 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/modules/mobianRtdProvider.js b/modules/mobianRtdProvider.js index 1b16f6ea6ca..e5772d489e2 100644 --- a/modules/mobianRtdProvider.js +++ b/modules/mobianRtdProvider.js @@ -84,32 +84,7 @@ export const getContextData = makeMemoizedFetch(); const entriesToObjectReducer = (acc, [key, value]) => ({ ...acc, [key]: value }); -/** - * @param {MobianConfig} config - * @param {MobianContextData} contextData - * @returns {Object} - */ -export function contextDataToKeyValues(config, contextData) { - const { prefix } = config; - const keyValues = CONTEXT_KEYS.reduce((acc, key) => { - const newAcc = { ...acc }; - if (key === AP_VALUES) { - AP_KEYS.forEach((apKey) => { - if (!contextData[key]?.[apKey]?.length) return; - newAcc[`${prefix}_ap_${apKey}`] = contextData[key][apKey] - }); - return newAcc; - } - - if (contextData[key]?.length) { - newAcc[`${prefix}_${key}`] = contextData[key]; - } - return newAcc; - }, {}); - return keyValues; -} - -function makeContextDataToKeyValuesReducer(config) { +export function makeContextDataToKeyValuesReducer(config) { const { prefix } = config; return function contextDataToKeyValuesReducer(keyValues, [key, value]) { if (key === AP_VALUES) { diff --git a/test/spec/modules/mobianRtdProvider_spec.js b/test/spec/modules/mobianRtdProvider_spec.js index 9d52cd1c128..5e45d427c7a 100644 --- a/test/spec/modules/mobianRtdProvider_spec.js +++ b/test/spec/modules/mobianRtdProvider_spec.js @@ -4,11 +4,11 @@ import * as ajax from 'src/ajax.js'; import * as gptUtils from 'libraries/gptUtils/gptUtils.js'; import { CONTEXT_KEYS, - contextDataToKeyValues, extendBidRequestConfig, fetchContextData, getConfig, getContextData, + makeContextDataToKeyValuesReducer, makeDataFromResponse, setTargeting, } from 'modules/mobianRtdProvider.js'; @@ -259,26 +259,19 @@ describe('Mobian RTD Submodule', function () { }); }); - describe('contextDataToKeyValues', function () { + describe('makeContextDataToKeyValuesReducer', function () { it('should format context data to key-value pairs', function () { const config = getConfig({ name: 'mobianBrandSafety', params: { - prefix: 'mobiantest', + prefix: 'mobian', publisherTargeting: true, advertiserTargeting: true, } }); - const mockKeyValues = { - 'mobiantest_ap_a1': [2313, 12], - 'mobiantest_ap_p0': [1231231, 212], - 'mobiantest_ap_p1': [231, 419], - 'mobiantest_emotions': ['affection'], - 'mobiantest_risk': 'low', - 'mobiantest_sentiment': 'positive', - }; - const keyValues = contextDataToKeyValues(config, mockContextData); - expect(keyValues).to.deep.equal(mockKeyValues); + const keyValues = Object.entries(mockContextData).reduce(makeContextDataToKeyValuesReducer(config), []); + const keyValuesObject = Object.fromEntries(keyValues); + expect(keyValuesObject).to.deep.equal(mockKeyValues); }); }); }); From 6e9417a95e8a6565370ab76e5a30518b02e14413 Mon Sep 17 00:00:00 2001 From: Ariel <155993606+arielmtk@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:34:27 -0300 Subject: [PATCH 4/7] Updates --- test/spec/modules/mobianRtdProvider_spec.js | 40 +++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/test/spec/modules/mobianRtdProvider_spec.js b/test/spec/modules/mobianRtdProvider_spec.js index 5e45d427c7a..abe58f3e40f 100644 --- a/test/spec/modules/mobianRtdProvider_spec.js +++ b/test/spec/modules/mobianRtdProvider_spec.js @@ -13,6 +13,8 @@ import { setTargeting, } from 'modules/mobianRtdProvider.js'; +const { AP_VALUES, CATEGORIES, EMOTIONS, GENRES, RISK, SENTIMENT, THEMES, TONES } = CONTEXT_KEYS; + describe('Mobian RTD Submodule', function () { let ajaxStub; let bidReqConfig; @@ -36,14 +38,14 @@ describe('Mobian RTD Submodule', function () { }); const mockContextData = { - apValues: { a0: [], a1: [2313, 12], p0: [1231231, 212], p1: [231, 419] }, - categories: [], - emotions: ['affection'], - genres: [], - risk: 'low', - sentiment: 'positive', - themes: [], - tones: [], + [AP_VALUES]: { a0: [], a1: [2313, 12], p0: [1231231, 212], p1: [231, 419] }, + [CATEGORIES]: [], + [EMOTIONS]: ['affection'], + [GENRES]: [], + [RISK]: 'low', + [SENTIMENT]: 'positive', + [THEMES]: [], + [TONES]: [], } const mockKeyValues = { @@ -57,8 +59,8 @@ describe('Mobian RTD Submodule', function () { const mockConfig = { prefix: 'mobian', - publisherTargeting: ['apValues', 'emotions', 'risk', 'sentiment', 'themes', 'tones', 'genres'], - advertiserTargeting: ['apValues', 'emotions', 'risk', 'sentiment', 'themes', 'tones', 'genres'], + publisherTargeting: [AP_VALUES, EMOTIONS, RISK, SENTIMENT, THEMES, TONES, GENRES], + advertiserTargeting: [AP_VALUES, EMOTIONS, RISK, SENTIMENT, THEMES, TONES, GENRES], } beforeEach(function () { @@ -119,7 +121,7 @@ describe('Mobian RTD Submodule', function () { it('should set targeting key-value pairs as per config', function () { const parsedConfig = { prefix: 'mobian', - publisherTargeting: ['apValues', 'emotions', 'risk', 'sentiment', 'themes', 'tones', 'genres'], + publisherTargeting: [AP_VALUES, EMOTIONS, RISK, SENTIMENT, THEMES, TONES, GENRES], }; setTargeting(parsedConfig, mockContextData); @@ -140,7 +142,7 @@ describe('Mobian RTD Submodule', function () { it('should not set key-value pairs if context data is empty', function () { const parsedConfig = { prefix: 'mobian', - publisherTargeting: ['apValues', 'emotions', 'risk', 'sentiment', 'themes', 'tones', 'genres'], + publisherTargeting: [AP_VALUES, EMOTIONS, RISK, SENTIMENT, THEMES, TONES, GENRES], }; setTargeting(parsedConfig, {}); @@ -150,7 +152,7 @@ describe('Mobian RTD Submodule', function () { it('should only set key-value pairs for the keys specified in config', function () { const parsedConfig = { prefix: 'mobian', - publisherTargeting: ['emotions', 'risk'], + publisherTargeting: [EMOTIONS, RISK], }; setTargeting(parsedConfig, mockContextData); @@ -200,14 +202,14 @@ describe('Mobian RTD Submodule', function () { name: 'mobianBrandSafety', params: { prefix: 'mobiantest', - publisherTargeting: ['apValues'], - advertiserTargeting: ['emotions'], + publisherTargeting: [AP_VALUES], + advertiserTargeting: [EMOTIONS], } }); expect(config).to.deep.equal({ prefix: 'mobiantest', - publisherTargeting: ['apValues'], - advertiserTargeting: ['emotions'], + publisherTargeting: [AP_VALUES], + advertiserTargeting: [EMOTIONS], }); }); @@ -215,12 +217,12 @@ describe('Mobian RTD Submodule', function () { const config = getConfig({ name: 'mobianBrandSafety', params: { - publisherTargeting: ['apValues'], + publisherTargeting: [AP_VALUES], } }); expect(config).to.deep.equal({ prefix: 'mobian', - publisherTargeting: ['apValues'], + publisherTargeting: [AP_VALUES], advertiserTargeting: [], }); }); From c7fca27f04012f77fd45b548f4c1d4d07a987e0c Mon Sep 17 00:00:00 2001 From: Ariel <155993606+arielmtk@users.noreply.github.com> Date: Thu, 26 Dec 2024 18:37:11 -0300 Subject: [PATCH 5/7] Fixes AP values not setting in GAM --- modules/mobianRtdProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mobianRtdProvider.js b/modules/mobianRtdProvider.js index e5772d489e2..3be45e8cf52 100644 --- a/modules/mobianRtdProvider.js +++ b/modules/mobianRtdProvider.js @@ -90,7 +90,7 @@ export function makeContextDataToKeyValuesReducer(config) { if (key === AP_VALUES) { AP_KEYS.forEach((apKey) => { if (!value?.[apKey]?.length) return; - keyValues.push([`${prefix}_ap_${apKey}`, value[apKey]]); + keyValues.push([`${prefix}_ap_${apKey}`, value[apKey].map((v) => String(v))]); }); } if (value?.length) { From a0c66ccf6f1c028fdd64116de26de2ab5d796f8a Mon Sep 17 00:00:00 2001 From: Ariel <155993606+arielmtk@users.noreply.github.com> Date: Mon, 30 Dec 2024 13:07:51 -0300 Subject: [PATCH 6/7] Fixes tests --- modules/mobianRtdProvider.js | 16 ++++++------- test/spec/modules/mobianRtdProvider_spec.js | 26 +++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/modules/mobianRtdProvider.js b/modules/mobianRtdProvider.js index 3be45e8cf52..92e5cfa2aee 100644 --- a/modules/mobianRtdProvider.js +++ b/modules/mobianRtdProvider.js @@ -37,14 +37,14 @@ import { setKeyValue } from '../libraries/gptUtils/gptUtils.js'; export const MOBIAN_URL = 'https://prebid.outcomes.net/api/prebid/v1/assessment/async'; -const AP_VALUES = 'apValues'; -const CATEGORIES = 'categories'; -const EMOTIONS = 'emotions'; -const GENRES = 'genres'; -const RISK = 'risk'; -const SENTIMENT = 'sentiment'; -const THEMES = 'themes'; -const TONES = 'tones'; +export const AP_VALUES = 'apValues'; +export const CATEGORIES = 'categories'; +export const EMOTIONS = 'emotions'; +export const GENRES = 'genres'; +export const RISK = 'risk'; +export const SENTIMENT = 'sentiment'; +export const THEMES = 'themes'; +export const TONES = 'tones'; export const CONTEXT_KEYS = [ AP_VALUES, diff --git a/test/spec/modules/mobianRtdProvider_spec.js b/test/spec/modules/mobianRtdProvider_spec.js index abe58f3e40f..0794e99151d 100644 --- a/test/spec/modules/mobianRtdProvider_spec.js +++ b/test/spec/modules/mobianRtdProvider_spec.js @@ -4,6 +4,14 @@ import * as ajax from 'src/ajax.js'; import * as gptUtils from 'libraries/gptUtils/gptUtils.js'; import { CONTEXT_KEYS, + AP_VALUES, + CATEGORIES, + EMOTIONS, + GENRES, + RISK, + SENTIMENT, + THEMES, + TONES, extendBidRequestConfig, fetchContextData, getConfig, @@ -13,8 +21,6 @@ import { setTargeting, } from 'modules/mobianRtdProvider.js'; -const { AP_VALUES, CATEGORIES, EMOTIONS, GENRES, RISK, SENTIMENT, THEMES, TONES } = CONTEXT_KEYS; - describe('Mobian RTD Submodule', function () { let ajaxStub; let bidReqConfig; @@ -49,9 +55,9 @@ describe('Mobian RTD Submodule', function () { } const mockKeyValues = { - 'mobian_ap_a1': [2313, 12], - 'mobian_ap_p0': [1231231, 212], - 'mobian_ap_p1': [231, 419], + 'mobian_ap_a1': ['2313', '12'], + 'mobian_ap_p0': ['1231231', '212'], + 'mobian_ap_p1': ['231', '419'], 'mobian_emotions': ['affection'], 'mobian_risk': 'low', 'mobian_sentiment': 'positive', @@ -97,10 +103,6 @@ describe('Mobian RTD Submodule', function () { describe('makeDataFromResponse', function () { it('should format context data response', async function () { - ajaxStub = sinon.stub(ajax, 'ajaxBuilder').returns(function(url, callbacks) { - callbacks.success(mockResponse); - }); - const data = makeDataFromResponse(mockResponse); expect(data).to.deep.equal(mockContextData); }); @@ -126,9 +128,9 @@ describe('Mobian RTD Submodule', function () { setTargeting(parsedConfig, mockContextData); expect(setKeyValueSpy.callCount).to.equal(6); - expect(setKeyValueSpy.calledWith('mobian_ap_a1', [2313, 12])).to.equal(true); - expect(setKeyValueSpy.calledWith('mobian_ap_p0', [1231231, 212])).to.equal(true); - expect(setKeyValueSpy.calledWith('mobian_ap_p1', [231, 419])).to.equal(true); + expect(setKeyValueSpy.calledWith('mobian_ap_a1', ['2313', '12'])).to.equal(true); + expect(setKeyValueSpy.calledWith('mobian_ap_p0', ['1231231', '212'])).to.equal(true); + expect(setKeyValueSpy.calledWith('mobian_ap_p1', ['231', '419'])).to.equal(true); expect(setKeyValueSpy.calledWith('mobian_emotions', ['affection'])).to.equal(true); expect(setKeyValueSpy.calledWith('mobian_risk', 'low')).to.equal(true); expect(setKeyValueSpy.calledWith('mobian_sentiment', 'positive')).to.equal(true); From 2821c94321b54315b7bbfd9f394d985e5fe00d21 Mon Sep 17 00:00:00 2001 From: Ariel <155993606+arielmtk@users.noreply.github.com> Date: Mon, 30 Dec 2024 13:45:47 -0300 Subject: [PATCH 7/7] Updates types --- modules/mobianRtdProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mobianRtdProvider.js b/modules/mobianRtdProvider.js index 92e5cfa2aee..01a0a5d93d1 100644 --- a/modules/mobianRtdProvider.js +++ b/modules/mobianRtdProvider.js @@ -185,7 +185,7 @@ export function extendBidRequestConfig(bidReqConfig, contextData, config) { } /** - * @param {MobianConfig} config + * @param {MobianConfig} rawConfig * @returns {boolean} */ function init(rawConfig) {