Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appnexus bid adapter add ortb2 device #11788

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
logError,
logInfo,
logMessage,
logWarn
logWarn,
mergeDeep
} from '../src/utils.js';
import {Renderer} from '../src/Renderer.js';
import {config} from '../src/config.js';
Expand Down Expand Up @@ -262,6 +263,12 @@ export const spec = {
payload.app = appIdObj;
}

// if present, merge device object from ortb2 into `payload.device`
if (bidderRequest?.ortb2?.device) {
payload.device = payload.device || {};
mergeDeep(payload.device, bidderRequest.ortb2.device);
}

// grab the ortb2 keyword data (if it exists) and convert from the comma list string format to object format
let ortb2 = deepClone(bidderRequest && bidderRequest.ortb2);

Expand Down
25 changes: 25 additions & 0 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,31 @@ describe('AppNexusAdapter', function () {
expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4])
});

it('should include ORTB2 device data when available', function () {
const bidRequest = deepClone(bidRequests[0]);
const bidderRequest = {
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',
},
},
};

const request = spec.buildRequests([bidRequest], bidderRequest);
const payload = JSON.parse(request.data);

expect(payload.device).to.deep.equal(bidderRequest.ortb2.device);
});

it('should add video property when adUnit includes a renderer', function () {
const videoData = {
mediaTypes: {
Expand Down