Skip to content

Commit

Permalink
Adagio Bid Adapter: Add full ORTB2 device data to request payload (#1…
Browse files Browse the repository at this point in the history
…2006)

Co-authored-by: Bohdan V <[email protected]>
  • Loading branch information
jwrosewell and BohdanVV authored Dec 26, 2024
1 parent 059e77f commit 9ec45f6
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 10 deletions.
34 changes: 24 additions & 10 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
deepAccess,
deepClone,
generateUUID,
getDNT,
getWindowSelf,
isArray,
isFn,
Expand All @@ -14,6 +13,7 @@ import {
logError,
logInfo,
logWarn,
mergeDeep,
} from '../src/utils.js';
import { getRefererInfo, parseDomain } from '../src/refererDetection.js';
import { OUTSTREAM, validateOrtbVideoFields } from '../src/video.js';
Expand All @@ -39,19 +39,33 @@ export const BB_RENDERER_URL = `https://${BB_PUBLICATION}.bbvms.com/r/$RENDERER.
const CURRENCY = 'USD';

/**
* Returns the window.ADAGIO global object used to store Adagio data.
* This object is created in window.top if possible, otherwise in window.self.
* Get device data object, with some properties
* deviated from the OpenRTB spec.
* @param {Object} ortb2Data
* @returns {Object} Device data object
*/
function getDevice() {
function getDevice(ortb2Data) {
const _device = {};

// Merge the device object from ORTB2 data.
if (ortb2Data?.device) {
mergeDeep(_device, ortb2Data.device);
}

// If the geo object is not defined, create it.
if (!_device.geo) {
_device.geo = {};
}

const language = navigator.language ? 'language' : 'userLanguage';
return {
mergeDeep(_device, {
userAgent: navigator.userAgent,
language: navigator[language],
dnt: getDNT() ? 1 : 0,
geo: {},
js: 1
};
};
});

return _device;
}

function getSite(bidderRequest) {
const { refererInfo } = bidderRequest;
Expand Down Expand Up @@ -502,7 +516,7 @@ export const spec = {
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

const secure = (location.protocol === 'https:') ? 1 : 0;
const device = _internal.getDevice();
const device = _internal.getDevice(bidderRequest?.ortb2);
const site = _internal.getSite(bidderRequest);
const pageviewId = _internal.getAdagioNs().pageviewId;
const gdprConsent = _getGdprConsent(bidderRequest) || {};
Expand Down
34 changes: 34 additions & 0 deletions test/spec/modules/adagioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,40 @@ describe('Adagio bid adapter', () => {
expect(requests[0].data.regs.dsa).to.be.undefined;
});
})

describe('with ORTB2', function() {
it('should add ortb2 device data to the request', function() {
const ortb2 = {
device: {
w: 980,
h: 1720,
dnt: 0,
ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/125.0.6422.80 Mobile/15E148 Safari/604.1',
language: 'en',
devicetype: 1,
make: 'Apple',
model: 'iPhone 12 Pro Max',
os: 'iOS',
osv: '17.4',
ext: {fiftyonedegrees_deviceId: '17595-133085-133468-18092'},
},
};

const bid01 = new BidRequestBuilder().withParams().build();
const bidderRequest = new BidderRequestBuilder({ortb2}).build();
const requests = spec.buildRequests([bid01], bidderRequest);

const expectedData = {
...ortb2.device,
language: navigator[navigator.language ? 'language' : 'userLanguage'],
js: 1,
geo: {},
userAgent: navigator.userAgent,
};

expect(requests[0].data.device).to.deep.equal(expectedData);
});
});
});

describe('interpretResponse()', function() {
Expand Down

0 comments on commit 9ec45f6

Please sign in to comment.