From d88da281286ca82d3cf935490df160e9da256608 Mon Sep 17 00:00:00 2001 From: Carlos Felix Date: Fri, 17 Jun 2022 12:57:25 -0500 Subject: [PATCH 01/10] capture display-related client side attributes --- modules/33acrossBidAdapter.js | 68 ++++++++ test/spec/modules/33acrossBidAdapter_spec.js | 173 ++++++++++++++++++- 2 files changed, 240 insertions(+), 1 deletion(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 700b1409da2..44feea50896 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -254,6 +254,7 @@ function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageU }); ttxRequest.site = { id: siteId }; + ttxRequest.device = _buildDeviceORTB(); if (pageUrl) { ttxRequest.site.page = pageUrl; @@ -734,6 +735,73 @@ function _createSync({ siteId = 'zzz000000000003zzz', gdprConsent = {}, uspConse return sync; } +// BUILD REQUESTS: DEVICE +function _buildDeviceORTB() { + const win = getWindowSelf(); + + return setExtensions({ + ...getScreenDimensions(), + pxratio: win.devicePixelRatio + }, { + ttx: { + viewport: getViewportDimensions(), + availheight: getWindowSelf().screen.availHeight, + maxtouchpoints: win.navigator.maxTouchPoints + } + }); +} + +function getTopMostAccessibleWindow() { + let mostAccessibleWindow = getWindowSelf(); + + try { + while (mostAccessibleWindow.parent !== mostAccessibleWindow && + mostAccessibleWindow.parent.document) { + mostAccessibleWindow = mostAccessibleWindow.parent; + } + } catch (err) { + // Do not throw an exception if we can't access the topmost frame. + } + + return mostAccessibleWindow; +} + +function getViewportDimensions() { + const topWin = getTopMostAccessibleWindow(); + const documentElement = topWin.document.documentElement; + + return { + w: documentElement.clientWidth, + h: documentElement.clientHeight, + }; +} + +function getScreenDimensions() { + const { + innerWidth: windowWidth, + innerHeight: windowHeight, + screen + } = getWindowSelf(); + + const [biggerDimension, smallerDimension] = [ + Math.max(screen.width, screen.height), + Math.min(screen.width, screen.height), + ]; + + if (windowHeight > windowWidth) { // Portrait mode + return { + w: smallerDimension, + h: biggerDimension, + }; + } + + // Landscape mode + return { + w: biggerDimension, + h: smallerDimension, + }; +} + export const spec = { NON_MEASURABLE, diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 4c5ff808bc0..7187c9405d7 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -30,6 +30,21 @@ describe('33acrossBidAdapter:', function () { site: { id: siteId }, + device: { + w: 1024, + h: 728, + pxratio: 2, + ext: { + ttx: { + viewport: { + w: 800, + h: 600 + }, + availheight: 500, + maxtouchpoints: 0 + } + } + }, id: 'r1', regs: { ext: { @@ -166,6 +181,12 @@ describe('33acrossBidAdapter:', function () { return this; }; + this.withDevice = (device) => { + utils.mergeDeep(ttxRequest, { device }); + + return this; + }; + this.withPageUrl = pageUrl => { Object.assign(ttxRequest.site, { page: pageUrl @@ -360,8 +381,21 @@ describe('33acrossBidAdapter:', function () { }; win = { parent: null, + devicePixelRatio: 2, + screen: { + width: 1024, + height: 728, + availHeight: 500 + }, + navigator: { + maxTouchPoints: 0 + }, document: { - visibilityState: 'visible' + visibilityState: 'visible', + documentElement: { + clientWidth: 800, + clientHeight: 600 + } }, innerWidth: 800, @@ -755,6 +789,143 @@ describe('33acrossBidAdapter:', function () { const [ buildRequest ] = spec.buildRequests(bidRequests); validateBuiltServerRequest(buildRequest, serverRequest); }); + + context('when all the wrapping windows are accessible', function() { + it('returns the viewport dimensions of the top most accessible window', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withDevice({ + ext: { + ttx: { + viewport: { + w: 6789, + h: 2345 + } + } + } + }) + .withProduct() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + sandbox.stub(win, 'parent').value({ + document: { + documentElement: { + clientWidth: 1234, + clientHeight: 4567 + } + }, + parent: { + document: { + documentElement: { + clientWidth: 6789, + clientHeight: 2345 + } + }, + } + }); + + const [ buildRequest ] = spec.buildRequests(bidRequests); + validateBuiltServerRequest(buildRequest, serverRequest); + }); + }); + + context('when one of the wrapping windows cannot be accessed', function() { + it('returns the viewport dimensions of the top most accessible window', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withDevice({ + ext: { + ttx: { + viewport: { + w: 9876, + h: 5432 + } + } + } + }) + .withProduct() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + const notAccessibleParentWindow = {}; + + Object.defineProperty(notAccessibleParentWindow, 'document', { + get() { throw new Error('fakeError'); } + }); + + sandbox.stub(win, 'parent').value({ + document: { + documentElement: { + clientWidth: 1234, + clientHeight: 4567 + } + }, + parent: { + parent: notAccessibleParentWindow, + document: { + documentElement: { + clientWidth: 9876, + clientHeight: 5432 + } + }, + } + }); + + const [ buildRequest ] = spec.buildRequests(bidRequests); + validateBuiltServerRequest(buildRequest, serverRequest); + }); + }); + }); + + it('returns the screen dimensions', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withDevice({ + w: 1024, + h: 728 + }) + .withProduct() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + win.screen.width = 1024; + win.screen.height = 728; + + const [ buildRequest ] = spec.buildRequests(bidRequests); + + validateBuiltServerRequest(buildRequest, serverRequest); + }); + + context('when the window height is greater than the width', function() { + it('returns the smaller screen dimension as the width', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withDevice({ + w: 728, + h: 1024 + }) + .withProduct() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + win.screen.width = 1024; + win.screen.height = 728; + + win.innerHeight = 728; + win.innerWidth = 727; + + const [ buildRequest ] = spec.buildRequests(bidRequests); + + validateBuiltServerRequest(buildRequest, serverRequest); + }); }); context('when tab is inactive', function() { From b3d2e36e2ebb7f0113ab57c671814e6a6d93ff5a Mon Sep 17 00:00:00 2001 From: Carlos Felix Date: Fri, 1 Jul 2022 10:01:49 -0500 Subject: [PATCH 02/10] rename the client display attributes --- modules/33acrossBidAdapter.js | 19 ++++++------ test/spec/modules/33acrossBidAdapter_spec.js | 32 ++++++++++++-------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 44feea50896..a765f152403 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -739,16 +739,17 @@ function _createSync({ siteId = 'zzz000000000003zzz', gdprConsent = {}, uspConse function _buildDeviceORTB() { const win = getWindowSelf(); - return setExtensions({ - ...getScreenDimensions(), - pxratio: win.devicePixelRatio - }, { - ttx: { - viewport: getViewportDimensions(), - availheight: getWindowSelf().screen.availHeight, - maxtouchpoints: win.navigator.maxTouchPoints + return { + ext: { + ttx: { + ...getScreenDimensions(), + pxr: win.devicePixelRatio, + vp: getViewportDimensions(), + ah: getWindowSelf().screen.availHeight, + mtp: win.navigator.maxTouchPoints + } } - }); + }; } function getTopMostAccessibleWindow() { diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 7187c9405d7..301b26a5218 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -31,17 +31,17 @@ describe('33acrossBidAdapter:', function () { id: siteId }, device: { - w: 1024, - h: 728, - pxratio: 2, ext: { ttx: { - viewport: { + w: 1024, + h: 728, + pxr: 2, + vp: { w: 800, h: 600 }, - availheight: 500, - maxtouchpoints: 0 + ah: 500, + mtp: 0 } } }, @@ -797,7 +797,7 @@ describe('33acrossBidAdapter:', function () { .withDevice({ ext: { ttx: { - viewport: { + vp: { w: 6789, h: 2345 } @@ -839,7 +839,7 @@ describe('33acrossBidAdapter:', function () { .withDevice({ ext: { ttx: { - viewport: { + vp: { w: 9876, h: 5432 } @@ -885,8 +885,12 @@ describe('33acrossBidAdapter:', function () { const ttxRequest = new TtxRequestBuilder() .withBanner() .withDevice({ - w: 1024, - h: 728 + ext: { + ttx: { + w: 1024, + h: 728 + } + } }) .withProduct() .build(); @@ -907,8 +911,12 @@ describe('33acrossBidAdapter:', function () { const ttxRequest = new TtxRequestBuilder() .withBanner() .withDevice({ - w: 728, - h: 1024 + ext: { + ttx: { + w: 728, + h: 1024 + } + } }) .withProduct() .build(); From 152cf5c0fb42c30d262ba4304744439ca1ce5e52 Mon Sep 17 00:00:00 2001 From: Carlos Felix Date: Fri, 1 Jul 2022 09:38:49 -0500 Subject: [PATCH 03/10] Obtain the UA entropy values --- modules/33acrossBidAdapter.js | 47 +++++++++++++++++++- test/spec/modules/33acrossBidAdapter_spec.js | 21 +++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index a765f152403..7c88a68db9f 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -1,5 +1,6 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; +import { getStorageManager } from '../src/storageManager.js'; import { deepAccess, uniques, @@ -61,6 +62,41 @@ function getTTXConfig() { return ttxSettings; } +const storage = getStorageManager({gvlid: GVLID, moduleName: BIDDER_CODE}) +const UA_DATA_KEY = `${BIDDER_CODE}UaReducedData`; + +function getStoredUaReducedData() { + try { + return JSON.parse(storage.getDataFromLocalStorage(UA_DATA_KEY)); + } catch (err) { + return null; + } +} + +function storeUaReducedData(uaData) { + storage.setDataInLocalStorage(UA_DATA_KEY, JSON.stringify(uaData)); +} + +function calculateUaReducedData() { + let uaReducedData = {}; + + getWindowSelf().navigator.userAgentData.getHighEntropyValues( + ['model', 'uaFullVersion', 'platformVersion'] + ).then((uaData) => { + uaReducedData = uaData; + + storeUaReducedData(uaReducedData); + }); + + return uaReducedData; +} + +calculateUaReducedData(); + +function fetchUAReducedData() { + return getStoredUaReducedData() || calculateUaReducedData(); +} + // **************************** VALIDATION *************************** // function isBidRequestValid(bid) { return ( @@ -739,14 +775,23 @@ function _createSync({ siteId = 'zzz000000000003zzz', gdprConsent = {}, uspConse function _buildDeviceORTB() { const win = getWindowSelf(); + const { + uaFullVersion: browserv, + platformVersion: osv, + model + } = fetchUAReducedData(); + return { ext: { ttx: { ...getScreenDimensions(), pxr: win.devicePixelRatio, + osv, + ...(model ? { mdl: model } : {}), vp: getViewportDimensions(), ah: getWindowSelf().screen.availHeight, - mtp: win.navigator.maxTouchPoints + mtp: win.navigator.maxTouchPoints, + browserv } } }; diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 301b26a5218..7648159a1d3 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -36,12 +36,15 @@ describe('33acrossBidAdapter:', function () { w: 1024, h: 728, pxr: 2, + osv: 'fooosv', + mdl: 'foomodel', vp: { w: 800, h: 600 }, ah: 500, - mtp: 0 + mtp: 0, + browserv: 'foouafullversion' } } }, @@ -388,7 +391,20 @@ describe('33acrossBidAdapter:', function () { availHeight: 500 }, navigator: { - maxTouchPoints: 0 + maxTouchPoints: 0, + userAgentData: { + getHighEntropyValues() { + return { + then(fn) { + fn({ + platformVersion: 'fooosv', + uaFullVersion: 'foouafullversion', + model: 'foomodel' + }); + } + } + } + } }, document: { visibilityState: 'visible', @@ -407,7 +423,6 @@ describe('33acrossBidAdapter:', function () { .withBanner() .build() ); - sandbox = sinon.sandbox.create(); sandbox.stub(Date, 'now').returns(1); sandbox.stub(document, 'getElementById').returns(element); From 063c8a70af10187397ade06abca240f3a1319062 Mon Sep 17 00:00:00 2001 From: Carlos Felix Date: Wed, 6 Jul 2022 12:04:02 -0500 Subject: [PATCH 04/10] apply CR feedback, reuse win constant --- modules/33acrossBidAdapter.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 7c88a68db9f..7c6cdae9ee5 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -789,9 +789,8 @@ function _buildDeviceORTB() { osv, ...(model ? { mdl: model } : {}), vp: getViewportDimensions(), - ah: getWindowSelf().screen.availHeight, - mtp: win.navigator.maxTouchPoints, - browserv + ah: win.screen.availHeight, + mtp: win.navigator.maxTouchPoints } } }; From 97b55b1d2a358feb780ec31b805f6f38ba6c256b Mon Sep 17 00:00:00 2001 From: Carlos Felix Date: Mon, 11 Jul 2022 11:41:53 -0500 Subject: [PATCH 05/10] pass gpid into build --- modules/33acrossBidAdapter.js | 6 +++ test/spec/modules/33acrossBidAdapter_spec.js | 49 ++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 7c6cdae9ee5..83f27501d2c 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -379,6 +379,12 @@ function _buildImpORTB(bidRequest) { } }; + const gpid = deepAccess(bidRequest, 'ortb2Imp.ext.gpid'); + + if (gpid) { + imp.ext.gpid = gpid; + } + if (deepAccess(bidRequest, 'mediaTypes.banner')) { imp.banner = { ..._buildBannerORTB(bidRequest) diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 7648159a1d3..1b7b3ef3e20 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -147,6 +147,21 @@ describe('33acrossBidAdapter:', function () { return this; }; + this.withProductAndGPID = (prod = 'siab', gpid) => { + ttxRequest.imp.forEach((imp) => { + Object.assign(imp, { + ext: { + gpid, + ttx: { + prod + } + } + }); + }); + + return this; + }; + this.withGdprConsent = (consent, gdpr) => { Object.assign(ttxRequest, { user: { @@ -1171,6 +1186,40 @@ describe('33acrossBidAdapter:', function () { }); }); + context('when Global Placement ID (gpid) is defined', function() { + let bidderRequest; + + beforeEach(function() { + bidderRequest = {}; + }); + + it('passes the Global Placement ID (gpid) in the request', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withProductAndGPID('siab', 'fakeGPID0') + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + let copyBidRequest = utils.deepClone(bidRequests); + const addGPIDBidRequests = copyBidRequest.map(function(bidRequest, index) { + return { + ...bidRequest, + ortb2Imp: { + ext: { + gpid: 'fakeGPID' + index + } + } + }; + }); + + const [ builtServerRequest ] = spec.buildRequests(addGPIDBidRequests, bidderRequest); + + validateBuiltServerRequest(builtServerRequest, serverRequest); + }); + }); + context('when referer value is not available', function() { it('returns corresponding server requests without site.page set', function() { const bidderRequest = { From 23a555e3411230788452600730aa1c5fd016b83d Mon Sep 17 00:00:00 2001 From: Anthony Lin Date: Tue, 12 Jul 2022 15:39:19 -0400 Subject: [PATCH 06/10] feedback changes --- modules/33acrossBidAdapter.js | 11 ++++------- test/spec/modules/33acrossBidAdapter_spec.js | 18 ++++++++---------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 83f27501d2c..2d2119c6e7f 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -370,21 +370,18 @@ function setExtensions(obj = {}, extFields) { // BUILD REQUESTS: IMP function _buildImpORTB(bidRequest) { + const gpid = deepAccess(bidRequest, 'ortb2Imp.ext.gpid'); + const imp = { id: bidRequest.bidId, ext: { ttx: { prod: deepAccess(bidRequest, 'params.productId') - } + }, + ...(gpid ? { gpid } : {}) } }; - const gpid = deepAccess(bidRequest, 'ortb2Imp.ext.gpid'); - - if (gpid) { - imp.ext.gpid = gpid; - } - if (deepAccess(bidRequest, 'mediaTypes.banner')) { imp.banner = { ..._buildBannerORTB(bidRequest) diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 1b7b3ef3e20..b5b71c3e3f8 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -135,7 +135,7 @@ describe('33acrossBidAdapter:', function () { this.withProduct = (prod = 'siab') => { ttxRequest.imp.forEach((imp) => { - Object.assign(imp, { + utils.mergeDeep(imp, { ext: { ttx: { prod @@ -147,14 +147,11 @@ describe('33acrossBidAdapter:', function () { return this; }; - this.withProductAndGPID = (prod = 'siab', gpid) => { + this.withGpid = (gpid) => { ttxRequest.imp.forEach((imp) => { - Object.assign(imp, { + utils.mergeDeep(imp, { ext: { - gpid, - ttx: { - prod - } + gpid } }); }); @@ -1196,14 +1193,15 @@ describe('33acrossBidAdapter:', function () { it('passes the Global Placement ID (gpid) in the request', function() { const ttxRequest = new TtxRequestBuilder() .withBanner() - .withProductAndGPID('siab', 'fakeGPID0') + .withProduct() + .withGpid('fakeGPID0') .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); let copyBidRequest = utils.deepClone(bidRequests); - const addGPIDBidRequests = copyBidRequest.map(function(bidRequest, index) { + const bidRequestsWithGpid = copyBidRequest.map(function(bidRequest, index) { return { ...bidRequest, ortb2Imp: { @@ -1214,7 +1212,7 @@ describe('33acrossBidAdapter:', function () { }; }); - const [ builtServerRequest ] = spec.buildRequests(addGPIDBidRequests, bidderRequest); + const [ builtServerRequest ] = spec.buildRequests(bidRequestsWithGpid, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); From 318f851c0e6fad93ee09bb0b07e1443629ee737a Mon Sep 17 00:00:00 2001 From: Carlos Felix Date: Thu, 14 Jul 2022 10:44:41 -0500 Subject: [PATCH 07/10] fix missing native property in some browsers --- modules/33acrossBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 2d2119c6e7f..ebaaad0e1c6 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -80,7 +80,7 @@ function storeUaReducedData(uaData) { function calculateUaReducedData() { let uaReducedData = {}; - getWindowSelf().navigator.userAgentData.getHighEntropyValues( + getWindowSelf().navigator?.userAgentData?.getHighEntropyValues( ['model', 'uaFullVersion', 'platformVersion'] ).then((uaData) => { uaReducedData = uaData; From a96e5eb7f90bf2af84ea1cb5b69f0a007290899c Mon Sep 17 00:00:00 2001 From: Carlos Felix Date: Fri, 15 Jul 2022 11:56:01 -0500 Subject: [PATCH 08/10] rename entropy fields --- modules/33acrossBidAdapter.js | 12 +++++++----- test/spec/modules/33acrossBidAdapter_spec.js | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index ebaaad0e1c6..3e0ecc36351 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -80,7 +80,8 @@ function storeUaReducedData(uaData) { function calculateUaReducedData() { let uaReducedData = {}; - getWindowSelf().navigator?.userAgentData?.getHighEntropyValues( + // eslint-disable-next-line no-unused-expressions + getWindowSelf().navigator.userAgentData?.getHighEntropyValues( ['model', 'uaFullVersion', 'platformVersion'] ).then((uaData) => { uaReducedData = uaData; @@ -779,8 +780,8 @@ function _buildDeviceORTB() { const win = getWindowSelf(); const { - uaFullVersion: browserv, - platformVersion: osv, + uaFullVersion: uafv, + platformVersion: pfv, model } = fetchUAReducedData(); @@ -789,11 +790,12 @@ function _buildDeviceORTB() { ttx: { ...getScreenDimensions(), pxr: win.devicePixelRatio, - osv, + pfv, ...(model ? { mdl: model } : {}), vp: getViewportDimensions(), ah: win.screen.availHeight, - mtp: win.navigator.maxTouchPoints + mtp: win.navigator.maxTouchPoints, + uafv } } }; diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index b5b71c3e3f8..8cc35b34f88 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -36,7 +36,7 @@ describe('33acrossBidAdapter:', function () { w: 1024, h: 728, pxr: 2, - osv: 'fooosv', + pfv: 'fooosversion', mdl: 'foomodel', vp: { w: 800, @@ -44,7 +44,7 @@ describe('33acrossBidAdapter:', function () { }, ah: 500, mtp: 0, - browserv: 'foouafullversion' + uafv: 'foouafullversion' } } }, @@ -409,7 +409,7 @@ describe('33acrossBidAdapter:', function () { return { then(fn) { fn({ - platformVersion: 'fooosv', + platformVersion: 'fooosversion', uaFullVersion: 'foouafullversion', model: 'foomodel' }); From bf17145e1a3cc123591438be4a23a45efa1f9e85 Mon Sep 17 00:00:00 2001 From: Carlos Felix Date: Tue, 19 Jul 2022 13:17:20 -0500 Subject: [PATCH 09/10] only store entropy data when it's present --- modules/33acrossBidAdapter.js | 8 ++++--- test/spec/modules/33acrossBidAdapter_spec.js | 24 +++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 3e0ecc36351..02adb0a60bb 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -62,8 +62,8 @@ function getTTXConfig() { return ttxSettings; } -const storage = getStorageManager({gvlid: GVLID, moduleName: BIDDER_CODE}) -const UA_DATA_KEY = `${BIDDER_CODE}UaReducedData`; +export const storage = getStorageManager({gvlid: GVLID, moduleName: BIDDER_CODE}) +export const UA_DATA_KEY = `${BIDDER_CODE}UaReducedData`; function getStoredUaReducedData() { try { @@ -86,7 +86,9 @@ function calculateUaReducedData() { ).then((uaData) => { uaReducedData = uaData; - storeUaReducedData(uaReducedData); + if (Object.values(uaData).find(value => !!value).length) { + storeUaReducedData(uaReducedData); + } }); return uaReducedData; diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 8cc35b34f88..950e63c3665 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -3,7 +3,7 @@ import { expect } from 'chai'; import * as utils from 'src/utils.js'; import { config } from 'src/config.js'; -import { spec } from 'modules/33acrossBidAdapter.js'; +import { spec, storage, UA_DATA_KEY } from 'modules/33acrossBidAdapter.js'; function validateBuiltServerRequest(builtReq, expectedReq) { expect(builtReq.url).to.equal(expectedReq.url); @@ -440,6 +440,10 @@ describe('33acrossBidAdapter:', function () { sandbox.stub(document, 'getElementById').returns(element); sandbox.stub(utils, 'getWindowTop').returns(win); sandbox.stub(utils, 'getWindowSelf').returns(win); + sandbox + .stub(storage, 'getDataFromLocalStorage') + .withArgs(UA_DATA_KEY) + .returns(null); }); afterEach(function() { @@ -1218,6 +1222,24 @@ describe('33acrossBidAdapter:', function () { }); }); + it('stores the user agent entropy values', function() { + const ttxRequest = new TtxRequestBuilder() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + sandbox.spy(storage, 'setDataInLocalStorage'); + + spec.buildRequests(bidRequests); + + sinon.assert.calledWith(storage.setDataInLocalStorage, UA_DATA_KEY, JSON.stringify({ + platformVersion: 'fooosversion', + uaFullVersion: 'foouafullversion', + model: 'foomodel' + })); + }); + context('when referer value is not available', function() { it('returns corresponding server requests without site.page set', function() { const bidderRequest = { From 7616d120a61c7bb03031ddae8c687ce309503a26 Mon Sep 17 00:00:00 2001 From: Anthony Lin Date: Wed, 27 Jul 2022 10:31:12 -0400 Subject: [PATCH 10/10] remove client hints --- modules/33acrossBidAdapter.js | 50 +------------------- test/spec/modules/33acrossBidAdapter_spec.js | 44 ++--------------- 2 files changed, 4 insertions(+), 90 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 02adb0a60bb..ad2b092baa8 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -1,6 +1,5 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; -import { getStorageManager } from '../src/storageManager.js'; import { deepAccess, uniques, @@ -62,44 +61,6 @@ function getTTXConfig() { return ttxSettings; } -export const storage = getStorageManager({gvlid: GVLID, moduleName: BIDDER_CODE}) -export const UA_DATA_KEY = `${BIDDER_CODE}UaReducedData`; - -function getStoredUaReducedData() { - try { - return JSON.parse(storage.getDataFromLocalStorage(UA_DATA_KEY)); - } catch (err) { - return null; - } -} - -function storeUaReducedData(uaData) { - storage.setDataInLocalStorage(UA_DATA_KEY, JSON.stringify(uaData)); -} - -function calculateUaReducedData() { - let uaReducedData = {}; - - // eslint-disable-next-line no-unused-expressions - getWindowSelf().navigator.userAgentData?.getHighEntropyValues( - ['model', 'uaFullVersion', 'platformVersion'] - ).then((uaData) => { - uaReducedData = uaData; - - if (Object.values(uaData).find(value => !!value).length) { - storeUaReducedData(uaReducedData); - } - }); - - return uaReducedData; -} - -calculateUaReducedData(); - -function fetchUAReducedData() { - return getStoredUaReducedData() || calculateUaReducedData(); -} - // **************************** VALIDATION *************************** // function isBidRequestValid(bid) { return ( @@ -781,23 +742,14 @@ function _createSync({ siteId = 'zzz000000000003zzz', gdprConsent = {}, uspConse function _buildDeviceORTB() { const win = getWindowSelf(); - const { - uaFullVersion: uafv, - platformVersion: pfv, - model - } = fetchUAReducedData(); - return { ext: { ttx: { ...getScreenDimensions(), pxr: win.devicePixelRatio, - pfv, - ...(model ? { mdl: model } : {}), vp: getViewportDimensions(), ah: win.screen.availHeight, - mtp: win.navigator.maxTouchPoints, - uafv + mtp: win.navigator.maxTouchPoints } } }; diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 950e63c3665..3657f7da912 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -3,7 +3,7 @@ import { expect } from 'chai'; import * as utils from 'src/utils.js'; import { config } from 'src/config.js'; -import { spec, storage, UA_DATA_KEY } from 'modules/33acrossBidAdapter.js'; +import { spec } from 'modules/33acrossBidAdapter.js'; function validateBuiltServerRequest(builtReq, expectedReq) { expect(builtReq.url).to.equal(expectedReq.url); @@ -36,15 +36,12 @@ describe('33acrossBidAdapter:', function () { w: 1024, h: 728, pxr: 2, - pfv: 'fooosversion', - mdl: 'foomodel', vp: { w: 800, h: 600 }, ah: 500, - mtp: 0, - uafv: 'foouafullversion' + mtp: 0 } } }, @@ -403,20 +400,7 @@ describe('33acrossBidAdapter:', function () { availHeight: 500 }, navigator: { - maxTouchPoints: 0, - userAgentData: { - getHighEntropyValues() { - return { - then(fn) { - fn({ - platformVersion: 'fooosversion', - uaFullVersion: 'foouafullversion', - model: 'foomodel' - }); - } - } - } - } + maxTouchPoints: 0 }, document: { visibilityState: 'visible', @@ -440,10 +424,6 @@ describe('33acrossBidAdapter:', function () { sandbox.stub(document, 'getElementById').returns(element); sandbox.stub(utils, 'getWindowTop').returns(win); sandbox.stub(utils, 'getWindowSelf').returns(win); - sandbox - .stub(storage, 'getDataFromLocalStorage') - .withArgs(UA_DATA_KEY) - .returns(null); }); afterEach(function() { @@ -1222,24 +1202,6 @@ describe('33acrossBidAdapter:', function () { }); }); - it('stores the user agent entropy values', function() { - const ttxRequest = new TtxRequestBuilder() - .build(); - const serverRequest = new ServerRequestBuilder() - .withData(ttxRequest) - .build(); - - sandbox.spy(storage, 'setDataInLocalStorage'); - - spec.buildRequests(bidRequests); - - sinon.assert.calledWith(storage.setDataInLocalStorage, UA_DATA_KEY, JSON.stringify({ - platformVersion: 'fooosversion', - uaFullVersion: 'foouafullversion', - model: 'foomodel' - })); - }); - context('when referer value is not available', function() { it('returns corresponding server requests without site.page set', function() { const bidderRequest = {