Skip to content

Commit

Permalink
Adding gpc in the bid request (prebid#11028)
Browse files Browse the repository at this point in the history
  • Loading branch information
desidiver authored Feb 1, 2024
1 parent 1b4a1ce commit d000ec8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
14 changes: 13 additions & 1 deletion modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export const spec = {
if (topicsData) {
serverRequest.topics = topicsData;
}
const gpc = getGPCSignal(bidderRequest);
if (gpc) {
serverRequest.gpc = gpc;
}

if (canAccessTopWindow()) {
serverRequest.pr = (LOCAL_WINDOW.document && LOCAL_WINDOW.document.referrer) || '';
Expand Down Expand Up @@ -417,14 +421,22 @@ function openRtbRequest(bidRequests, bidderRequest) {
if (schain) {
openRtbRequest.schain = schain;
}

const gpc = getGPCSignal(bidderRequest);
if (gpc) {
deepSetValue(openRtbRequest, 'regs.ext.gpc', gpc);
}
if (bidRequests[0].auctionId) {
openRtbRequest.auctionId = bidRequests[0].auctionId;
}
populateOpenRtbGdpr(openRtbRequest, bidderRequest);
return openRtbRequest;
}

function getGPCSignal(bidderRequest) {
const gpc = deepAccess(bidderRequest, 'ortb2.regs.ext.gpc');
return gpc;
}

function getTopics(bidderRequest) {
const userData = deepAccess(bidderRequest, 'ortb2.user.data') || [];
const topicsData = userData.filter((dataObj) => {
Expand Down
33 changes: 33 additions & 0 deletions test/spec/modules/yieldmoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,22 @@ describe('YieldmoAdapter', function () {
});
});

it('should send gpc in the banner bid request', function () {
const biddata = build(
[mockBannerBid()],
mockBidderRequest({
ortb2: {
regs: {
ext: {
gpc: '1'
},
},
},
})
);
expect(biddata[0].data.gpc).to.equal('1');
});

it('should add eids to the banner bid request', function () {
const params = {
userIdAsEids: [{
Expand Down Expand Up @@ -667,6 +683,23 @@ describe('YieldmoAdapter', function () {
});
});

it('should send gpc in the bid request', function () {
let videoBidder = mockBidderRequest(
{
ortb2: {
regs: {
ext: {
gpc: '1',
},
},
},
},
[mockVideoBid()]
);
let payload = buildAndGetData([mockVideoBid()], 0, videoBidder);
expect(payload.regs.ext.gpc).to.equal('1');
});

it('should add device info to payload if available', function () {
let videoBidder = mockBidderRequest({ ortb2: {
device: {
Expand Down

0 comments on commit d000ec8

Please sign in to comment.