Skip to content

Commit

Permalink
33Across Bid Adapter: Add structured user agent information to RTB pa…
Browse files Browse the repository at this point in the history
…yload (prebid#9112)

* Add UA high entropy values to the request

* 33x specs: use the right format for "sua" version values
  • Loading branch information
carlosfelix authored and JacobKlein26 committed Feb 8, 2023
1 parent 4f6c826 commit 5875e5e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 12 deletions.
29 changes: 18 additions & 11 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
logWarn,
getWindowSelf,
mergeDeep,
pick
} from '../src/utils.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';

Expand Down Expand Up @@ -242,7 +243,8 @@ function _getMRAKey(bidRequest) {
// Infer the necessary data from valid bid for a minimal ttxRequest and create HTTP request
function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageUrl, ttxSettings }) {
const ttxRequest = {};
const { siteId, test } = bidRequests[0].params;
const firstBidRequest = bidRequests[0];
const { siteId, test } = firstBidRequest.params;

/*
* Infer data for the request payload
Expand All @@ -254,23 +256,23 @@ function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageU
});

ttxRequest.site = { id: siteId };
ttxRequest.device = _buildDeviceORTB();
ttxRequest.device = _buildDeviceORTB(firstBidRequest.ortb2?.device);

if (pageUrl) {
ttxRequest.site.page = pageUrl;
}

ttxRequest.id = bidRequests[0].auctionId;
ttxRequest.id = firstBidRequest.auctionId;

if (gdprConsent.consentString) {
ttxRequest.user = setExtensions(ttxRequest.user, {
'consent': gdprConsent.consentString
});
}

if (Array.isArray(bidRequests[0].userIdAsEids) && bidRequests[0].userIdAsEids.length > 0) {
if (Array.isArray(firstBidRequest.userIdAsEids) && firstBidRequest.userIdAsEids.length > 0) {
ttxRequest.user = setExtensions(ttxRequest.user, {
'eids': bidRequests[0].userIdAsEids
'eids': firstBidRequest.userIdAsEids
});
}

Expand All @@ -294,9 +296,9 @@ function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageU
}
};

if (bidRequests[0].schain) {
if (firstBidRequest.schain) {
ttxRequest.source = setExtensions(ttxRequest.source, {
'schain': bidRequests[0].schain
'schain': firstBidRequest.schain
});
}

Expand Down Expand Up @@ -739,10 +741,9 @@ function _createSync({ siteId = 'zzz000000000003zzz', gdprConsent = {}, uspConse
}

// BUILD REQUESTS: DEVICE
function _buildDeviceORTB() {
function _buildDeviceORTB(device = {}) {
const win = getWindowSelf();

return {
const deviceProps = {
ext: {
ttx: {
...getScreenDimensions(),
Expand All @@ -752,7 +753,13 @@ function _buildDeviceORTB() {
mtp: win.navigator.maxTouchPoints
}
}
};
}

if (device.sua) {
deviceProps.sua = pick(device.sua, [ 'browsers', 'platform', 'model' ]);
}

return deviceProps;
}

function getTopMostAccessibleWindow() {
Expand Down
45 changes: 44 additions & 1 deletion test/spec/modules/33acrossBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ describe('33acrossBidAdapter:', function () {
ah: 500,
mtp: 0
}
},
sua: {
browsers: [{
brand: 'Google Chrome',
version: ['104', '0', '5112', '79']
}],
platform: {
brand: 'macOS',
version: ['11', '6', '8']
},
model: ''
}
},
id: 'r1',
Expand Down Expand Up @@ -305,7 +316,23 @@ describe('33acrossBidAdapter:', function () {
adUnitCode: 'div-id',
auctionId: 'r1',
mediaTypes: {},
transactionId: 't1'
transactionId: 't1',
ortb2: {
device: {
sua: {
browsers: [{
brand: 'Google Chrome',
version: ['104', '0', '5112', '79']
}],
platform: {
brand: 'macOS',
version: ['11', '6', '8']
},
model: '',
mobile: false
}
}
}
}
];

Expand All @@ -322,6 +349,22 @@ describe('33acrossBidAdapter:', function () {
auctionId: 'r1',
mediaTypes: {},
transactionId: 't2',
ortb2: {
device: {
sua: {
browsers: [{
brand: 'Google Chrome',
version: ['104', '0', '5112', '79']
}],
platform: {
brand: 'macOS',
version: ['11', '6', '8']
},
model: '',
mobile: false
}
}
},
...bidParams
});

Expand Down

0 comments on commit 5875e5e

Please sign in to comment.