Skip to content

Commit

Permalink
Ogury Adapter add gpid in bid request (prebid#12091)
Browse files Browse the repository at this point in the history
  • Loading branch information
jogury authored Aug 5, 2024
1 parent e10a58c commit 81459cd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 6 deletions.
7 changes: 5 additions & 2 deletions modules/oguryBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import {BANNER} from '../src/mediaTypes.js';
import {getWindowSelf, getWindowTop, isFn, logWarn} from '../src/utils.js';
import {getWindowSelf, getWindowTop, isFn, logWarn, deepAccess} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {ajax} from '../src/ajax.js';
import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js';
Expand All @@ -12,7 +12,7 @@ const DEFAULT_TIMEOUT = 1000;
const BID_HOST = 'https://mweb-hb.presage.io/api/header-bidding-request';
const TIMEOUT_MONITORING_HOST = 'https://ms-ads-monitoring-events.presage.io';
const MS_COOKIE_SYNC_DOMAIN = 'https://ms-cookie-sync.presage.io';
const ADAPTER_VERSION = '1.6.0';
const ADAPTER_VERSION = '1.6.1';

function getClientWidth() {
const documentElementClientWidth = window.top.document.documentElement.clientWidth
Expand Down Expand Up @@ -129,6 +129,8 @@ function buildRequests(validBidRequests, bidderRequest) {
openRtbBidRequestBanner.user.ext.eids = bidRequest.userIdAsEids
}

const gpid = deepAccess(bidRequest, 'ortb2Imp.ext.gpid');

openRtbBidRequestBanner.imp.push({
id: bidRequest.bidId,
tagid: bidRequest.params.adUnitId,
Expand All @@ -138,6 +140,7 @@ function buildRequests(validBidRequests, bidderRequest) {
},
ext: {
...bidRequest.params,
...(gpid && {gpid}),
timeSpentOnPage: document.timeline && document.timeline.currentTime ? document.timeline.currentTime : 0
}
});
Expand Down
54 changes: 50 additions & 4 deletions test/spec/modules/oguryBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ describe('OguryBidAdapter', function () {
bidRequests = [
{
adUnitCode: 'adUnitCode',
ortb2Imp: {
ext: {
gpid: 'gpid'
}
},
auctionId: 'auctionId',
bidId: 'bidId',
bidder: 'ogury',
Expand Down Expand Up @@ -394,6 +399,7 @@ describe('OguryBidAdapter', function () {
},
ext: {
...bidRequests[0].params,
gpid: bidRequests[0].ortb2Imp.ext.gpid,
timeSpentOnPage: stubbedCurrentTime
}
}, {
Expand Down Expand Up @@ -441,7 +447,7 @@ describe('OguryBidAdapter', function () {
},
ext: {
prebidversion: '$prebid.version$',
adapterversion: '1.6.0'
adapterversion: '1.6.1'
},
device: {
w: stubbedWidth,
Expand Down Expand Up @@ -824,7 +830,47 @@ describe('OguryBidAdapter', function () {
const request = spec.buildRequests(validBidRequests, bidderRequest);
expect(request.data).to.deep.equal(expectedRequestWithUnsupportedFloorCurrency);
});
});

it('should not add gpid if ortb2 undefined', () => {
const expectedRequestWithUndefinedGpid = utils.deepClone(expectedRequestObject)

delete expectedRequestWithUndefinedGpid.imp[0].ext.gpid;
delete expectedRequestWithUndefinedGpid.imp[1].ext.gpid;

const validBidRequests = utils.deepClone(bidRequests);
delete validBidRequests[0].ortb2Imp.ext.gpid;

const request = spec.buildRequests(validBidRequests, bidderRequest);
expect(request.data).to.deep.equal(expectedRequestWithUndefinedGpid);
});

it('should not add gpid if gpid undefined', () => {
const expectedRequestWithUndefinedGpid = utils.deepClone(expectedRequestObject)

delete expectedRequestWithUndefinedGpid.imp[0].ext.gpid;
delete expectedRequestWithUndefinedGpid.imp[1].ext.gpid;

const validBidRequests = utils.deepClone(bidRequests);
validBidRequests[0] = {
...validBidRequests[0],
ortb2Imp: {
ext: {}
}
};

const request = spec.buildRequests(validBidRequests, bidderRequest);
expect(request.data).to.deep.equal(expectedRequestWithUndefinedGpid);
});

it('should send gpid in bid request', function() {
const validBidRequests = utils.deepClone(bidRequests)

const request = spec.buildRequests(validBidRequests, bidderRequest);
expect(request.data).to.deep.equal(expectedRequestObject);
expect(request.data.imp[0].ext.gpid).to.be.a('string');
expect(request.data.imp[1].ext.gpid).to.be.undefined
})
})

describe('interpretResponse', function () {
let openRtbBidResponse = {
Expand Down Expand Up @@ -891,7 +937,7 @@ describe('OguryBidAdapter', function () {
advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[0].adomain
},
nurl: openRtbBidResponse.body.seatbid[0].bid[0].nurl,
adapterVersion: '1.6.0',
adapterVersion: '1.6.1',
prebidVersion: '$prebid.version$'
}, {
requestId: openRtbBidResponse.body.seatbid[0].bid[1].impid,
Expand All @@ -908,7 +954,7 @@ describe('OguryBidAdapter', function () {
advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[1].adomain
},
nurl: openRtbBidResponse.body.seatbid[0].bid[1].nurl,
adapterVersion: '1.6.0',
adapterVersion: '1.6.1',
prebidVersion: '$prebid.version$'
}]

Expand Down

0 comments on commit 81459cd

Please sign in to comment.