Skip to content

Commit

Permalink
OMS Adapter: add gpid support (#11238)
Browse files Browse the repository at this point in the history
* OMS Adapter: add gpid support

* Oms Adapter: move gpid to imp.ext

* Oms Adapter: cover with tests gpid integration
  • Loading branch information
prBigBrother authored Mar 25, 2024
1 parent af20eda commit c5e8af7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
15 changes: 14 additions & 1 deletion modules/omsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ function buildRequests(bidReqs, bidderRequest) {
const minSize = _getMinSize(processedSizes);
const viewabilityAmount = _isViewabilityMeasurable(element) ? _getViewability(element, getWindowTop(), minSize) : 'na';
const viewabilityAmountRounded = isNaN(viewabilityAmount) ? viewabilityAmount : Math.round(viewabilityAmount);
const gpidData = _extractGpidData(bid);

const imp = {
id: bid.bidId,
banner: {
format: processedSizes,
ext: {
viewability: viewabilityAmountRounded
viewability: viewabilityAmountRounded,
}
},
ext: {
...gpidData
},
tagid: String(bid.adUnitCode)
};

Expand Down Expand Up @@ -241,6 +245,15 @@ function _getViewability(element, topWin, {w, h} = {}) {
return getWindowTop().document.visibilityState === 'visible' ? percentInView(element, topWin, {w, h}) : 0;
}

function _extractGpidData(bid) {
return {
gpid: bid?.ortb2Imp?.ext?.gpid,
adserverName: bid?.ortb2Imp?.ext?.data?.adserver?.name,
adslot: bid?.ortb2Imp?.ext?.data?.adserver?.adslot,
pbadslot: bid?.ortb2Imp?.ext?.data?.pbadslot,
}
}

function _isIframe() {
try {
return getWindowSelf() !== getWindowTop();
Expand Down
22 changes: 22 additions & 0 deletions test/spec/modules/omsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,28 @@ describe('omsBidAdapter', function () {
expect(data.user.ext.ids).is.deep.equal(userId);
});

it('sends gpid parameters', function () {
bidRequests[0].ortb2Imp = {
'ext': {
'gpid': '/1111/home-left',
'data': {
'adserver': {
'name': 'gam',
'adslot': '/1111/home'
},
'pbadslot': '/1111/home-left'
}
}
}

const data = JSON.parse(spec.buildRequests(bidRequests).data);
expect(data.imp[0].ext).to.not.be.undefined;
expect(data.imp[0].ext.gpid).to.not.be.undefined;
expect(data.imp[0].ext.adserverName).to.not.be.undefined;
expect(data.imp[0].ext.adslot).to.not.be.undefined;
expect(data.imp[0].ext.pbadslot).to.not.be.undefined;
});

context('when element is fully in view', function () {
it('returns 100', function () {
Object.assign(element, {width: 600, height: 400});
Expand Down

0 comments on commit c5e8af7

Please sign in to comment.