Skip to content

Commit

Permalink
only store entropy data when it's present
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosfelix committed Jul 25, 2022
1 parent a96e5eb commit bf17145
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 5 additions & 3 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -86,7 +86,9 @@ function calculateUaReducedData() {
).then((uaData) => {
uaReducedData = uaData;

storeUaReducedData(uaReducedData);
if (Object.values(uaData).find(value => !!value).length) {
storeUaReducedData(uaReducedData);
}
});

return uaReducedData;
Expand Down
24 changes: 23 additions & 1 deletion 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 } 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);
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit bf17145

Please sign in to comment.