Skip to content

Commit

Permalink
Merge pull request #55 from 33Across/IDG-329_remove_client_hints
Browse files Browse the repository at this point in the history
Remove client hints from 33across adapter
  • Loading branch information
anthonyjl92 authored Jul 27, 2022
2 parents bf17145 + 7616d12 commit 2ff40e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 90 deletions.
50 changes: 1 addition & 49 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}
}
};
Expand Down
44 changes: 3 additions & 41 deletions test/spec/modules/33acrossBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
}
}
},
Expand Down Expand Up @@ -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',
Expand All @@ -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() {
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 2ff40e8

Please sign in to comment.