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

IX Bid Adapter: signal imp.displaymanager #10131

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
39 changes: 38 additions & 1 deletion modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,41 @@ function bidToBannerImp(bid) {
return imp;
}

/**
* Sets imp.displaymanager
*
* @param {object} imp
* @param {object} bid
*/
function setDisplayManager(imp, bid) {
if (deepAccess(bid, 'mediaTypes.video.context') === OUTSTREAM) {
let renderer = deepAccess(bid, 'mediaTypes.video.renderer');
if (!renderer) {
renderer = deepAccess(bid, 'renderer');
}

if (deepAccess(bid, 'schain', false)) {
imp.displaymanager = 'pbjs_wrapper';
} else if (renderer && typeof (renderer) === 'object') {
if (renderer.url !== undefined) {
let domain = '';
try {
domain = new URL(renderer.url).hostname
} catch {
return;
}
if (domain.includes('js-sec.indexww')) {
imp.displaymanager = 'ix';
} else {
imp.displaymanager = renderer.url;
}
}
} else {
imp.displaymanager = 'ix';
}
}
}

/**
* Transform valid bid request config object to video impression object that will be sent to ad server.
*
Expand All @@ -196,8 +231,10 @@ function bidToVideoImp(bid) {
// populate imp level transactionId
imp.ext.tid = deepAccess(bid, 'ortb2Imp.ext.tid');

setDisplayManager(imp, bid);

// AdUnit-Specific First Party Data
addAdUnitFPD(imp, bid)
addAdUnitFPD(imp, bid);

// copy all video properties to imp object
for (const adUnitProperty in videoAdUnitRef) {
Expand Down
72 changes: 72 additions & 0 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,78 @@ describe('IndexexchangeAdapter', function () {
});
});

describe('video request should set displaymanager', () => {
it('ix renderer preferrered', () => {
const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID);
bid[0].mediaTypes.video.context = 'outstream';
bid[0].mediaTypes.video.w = [[300, 143]];
bid[0].schain = undefined;
const request = spec.buildRequests(bid);
const videoImpression = extractPayload(request[0]).imp[0];
expect(videoImpression.displaymanager).to.equal('ix');
});
it('ix renderer not preferrered', () => {
const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID);
bid[0].mediaTypes.video.context = 'outstream';
bid[0].mediaTypes.video.w = [[300, 143]];
bid[0].mediaTypes.video.renderer = {
url: 'http://publisherplayer.js',
render: () => { }
};
bid[0].schain = undefined;
const request = spec.buildRequests(bid);
const videoImpression = extractPayload(request[0]).imp[0];
expect(videoImpression.displaymanager).to.equal('http://publisherplayer.js');
});
it('ix renderer not preferrered - bad url', () => {
const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID);
bid[0].mediaTypes.video.context = 'outstream';
bid[0].mediaTypes.video.w = [[300, 143]];
bid[0].mediaTypes.video.renderer = {
url: 'publisherplayer.js',
render: () => { }
};
bid[0].schain = undefined;
const request = spec.buildRequests(bid);
const videoImpression = extractPayload(request[0]).imp[0];
expect(videoImpression.displaymanager).to.be.undefined;
});
it('renderer url provided and is ix renderer', () => {
const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID);
bid[0].mediaTypes.video.context = 'outstream';
bid[0].mediaTypes.video.w = [[300, 143]];
bid[0].mediaTypes.video.renderer = {
url: 'http://js-sec.indexww.rendererplayer.com',
render: () => { }
};
bid[0].schain = undefined;
const request = spec.buildRequests(bid);
const videoImpression = extractPayload(request[0]).imp[0];
expect(videoImpression.displaymanager).to.equal('ix');
});
it('renderer url undefined and is ix renderer', () => {
const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID);
bid[0].mediaTypes.video.context = 'outstream';
bid[0].mediaTypes.video.w = [[300, 143]];
bid[0].mediaTypes.video.renderer = {
render: () => { }
};
bid[0].schain = undefined;
const request = spec.buildRequests(bid);
const videoImpression = extractPayload(request[0]).imp[0];
expect(videoImpression.displaymanager).to.be.undefined;
});
it('schain', () => {
const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID);
bid[0].mediaTypes.video.context = 'outstream';
bid[0].mediaTypes.video.w = [[300, 143]];
bid[0].schain = SAMPLE_SCHAIN;
const request = spec.buildRequests(bid);
const videoImpression = extractPayload(request[0]).imp[0];
expect(videoImpression.displaymanager).to.equal('pbjs_wrapper');
});
});

describe('request should contain both banner and native requests', function () {
const request = spec.buildRequests([DEFAULT_BANNER_VALID_BID[0], DEFAULT_NATIVE_VALID_BID[0]]);

Expand Down