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: Support for Ad unit specific First Party Data #9821

Merged
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
30 changes: 30 additions & 0 deletions modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ function bidToVideoImp(bid) {
// populate imp level transactionId
imp.ext.tid = deepAccess(bid, 'ortb2Imp.ext.tid');

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

// copy all video properties to imp object
for (const adUnitProperty in videoAdUnitRef) {
if (VIDEO_PARAMS_ALLOW_LIST.indexOf(adUnitProperty) !== -1 && !imp.video.hasOwnProperty(adUnitProperty)) {
Expand Down Expand Up @@ -268,6 +271,9 @@ function bidToNativeImp(bid) {
// populate imp level transactionId
imp.ext.tid = deepAccess(bid, 'ortb2Imp.ext.tid');

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

_applyFloor(bid, imp, NATIVE);

return imp;
Expand Down Expand Up @@ -956,6 +962,11 @@ function addImpressions(impressions, transactionIds, r, adUnitIndex) {
_bannerImpression.bidfloorcur = impressionObjects[0].bidfloorcur;
}

const adUnitFPD = impressions[transactionIds[adUnitIndex]].adUnitFPD
if (adUnitFPD) {
_bannerImpression.ext.data = adUnitFPD;
}

r.imp.push(_bannerImpression);
} else {
// set imp.ext.gpid to resolved gpid for each imp
Expand Down Expand Up @@ -1011,6 +1022,19 @@ function addFPD(bidderRequest, r, fpd, site, user) {
return r;
}

/**
* Adds First-Party Data (FPD) from the bid object to the imp object.
*
* @param {Object} imp - The imp object, representing an impression in the OpenRTB format.
* @param {Object} bid - The bid object, containing information about the bid request.
*/
function addAdUnitFPD(imp, bid) {
const adUnitFPD = deepAccess(bid, 'ortb2Imp.ext.data');
if (adUnitFPD) {
deepSetValue(imp, 'ext.data', adUnitFPD)
}
}

/**
* addIdentifiersInfo adds indentifier info to ixDaig.
*
Expand Down Expand Up @@ -1196,6 +1220,12 @@ function createBannerImps(validBidRequest, missingBannerSizes, bannerImps) {
bannerImps[validBidRequest.transactionId].tagId = deepAccess(validBidRequest, 'params.tagId');
bannerImps[validBidRequest.transactionId].pos = deepAccess(validBidRequest, 'mediaTypes.banner.pos');

// AdUnit-Specific First Party Data
const adUnitFPD = deepAccess(validBidRequest, 'ortb2Imp.ext.data');
if (adUnitFPD) {
bannerImps[validBidRequest.transactionId].adUnitFPD = adUnitFPD;
}

const sid = deepAccess(validBidRequest, 'params.id');
if (sid && (typeof sid === 'string' || typeof sid === 'number')) {
bannerImps[validBidRequest.transactionId].sid = String(sid);
Expand Down
57 changes: 57 additions & 0 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,63 @@ describe('IndexexchangeAdapter', function () {
expect(r.regs.gpp_sid).to.be.an('array');
expect(r.regs.gpp_sid).to.include(1);
});

it('should add adunit specific data to imp ext for banner', function () {
const AD_UNIT_CODE = '/19968336/some-adunit-path';
const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID);
validBids[0].ortb2Imp = {
ext: {
data: {
adserver: {
name: 'gam banner',
adslot: AD_UNIT_CODE
}
}
}
};
const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
const imp = extractPayload(requests[0]).imp[0];
expect(deepAccess(imp, 'ext.data.adserver.name')).to.equal('gam banner');
expect(deepAccess(imp, 'ext.data.adserver.adslot')).to.equal(AD_UNIT_CODE);
});

it('should add adunit specific data to imp ext for native', function () {
const AD_UNIT_CODE = '/19968336/some-adunit-path';
const validBids = utils.deepClone(DEFAULT_NATIVE_VALID_BID);
validBids[0].ortb2Imp = {
ext: {
data: {
adserver: {
name: 'gam native',
adslot: AD_UNIT_CODE
}
}
}
};
const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
const imp = extractPayload(requests[0]).imp[0];
expect(deepAccess(imp, 'ext.data.adserver.name')).to.equal('gam native');
expect(deepAccess(imp, 'ext.data.adserver.adslot')).to.equal(AD_UNIT_CODE);
});

it('should add adunit specific data to imp ext for video', function () {
const AD_UNIT_CODE = '/19968336/some-adunit-path';
const validBids = utils.deepClone(DEFAULT_VIDEO_VALID_BID);
validBids[0].ortb2Imp = {
ext: {
data: {
adserver: {
name: 'gam video',
adslot: AD_UNIT_CODE
}
}
}
};
const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
const imp = extractPayload(requests[0]).imp[0];
expect(deepAccess(imp, 'ext.data.adserver.name')).to.equal('gam video');
expect(deepAccess(imp, 'ext.data.adserver.adslot')).to.equal(AD_UNIT_CODE);
});
});

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