Skip to content

Commit

Permalink
Support for cids (prebid#11713)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinGumGum authored and DecayConstant committed Jul 18, 2024
1 parent 4b68862 commit fcdc4db
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
30 changes: 24 additions & 6 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,12 @@ function buildRequests(validBidRequests, bidderRequest) {
data.fp = floor;
data.fpc = currency;
}

if (bidderRequest && bidderRequest.ortb2 && bidderRequest.ortb2.site) {
setIrisId(data, bidderRequest.ortb2.site, params);
}
if (params.iriscat && typeof params.iriscat === 'string') {
data.iriscat = params.iriscat;
}

if (params.irisid && typeof params.irisid === 'string') {
data.irisid = params.irisid;
}

if (params.zone || params.pubId) {
params.zone ? (data.t = params.zone) : (data.pubId = params.pubId);

Expand Down Expand Up @@ -447,6 +444,27 @@ function buildRequests(validBidRequests, bidderRequest) {
});
return bids;
}
export function getCids(site) {
if (site.content && Array.isArray(site.content.data)) {
for (const dataItem of site.content.data) {
if (dataItem.name.includes('iris.com') || dataItem.name.includes('iris.tv')) {
return dataItem.ext.cids.join(',');
}
}
}
return null;
}
export function setIrisId(data, site, params) {
let irisID = getCids(site);
if (irisID) {
data.irisid = irisID;
} else {
// Just adding this chechk for safty and if needed we can remove
if (params.irisid && typeof params.irisid === 'string') {
data.irisid = params.irisid;
}
}
}

function handleLegacyParams(params, sizes) {
const data = {};
Expand Down
34 changes: 27 additions & 7 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,28 @@ describe('gumgumAdapter', function () {

describe('buildRequests', function () {
let sizesArray = [[300, 250], [300, 600]];
const bidderRequest = {
ortb2: {
site: {
content: {
data: [{
name: 'www.iris.com',
ext: {
segtax: 500,
cids: ['iris_c73g5jq96mwso4d8']
}
}]
},
page: 'http://pub.com/news',
ref: 'http://google.com',
publisher: {
id: 'p10000',
domain: 'pub.com'
}
}
}
};

let bidRequests = [
{
gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
Expand Down Expand Up @@ -259,19 +281,17 @@ describe('gumgumAdapter', function () {
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data).to.have.property('iriscat');
});
it('should set the irisid param when found iris_c73g5jq96mwso4d8', function() {
const request = { ...bidRequests[0], params: { irisid: 'abc123' } };
const bidRequest = spec.buildRequests([request], bidderRequest)[0];
expect(bidRequest.data).to.have.property('irisid', 'iris_c73g5jq96mwso4d8');
});

it('should not set the iriscat param when not found', function () {
const request = { ...bidRequests[0] }
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data).to.not.have.property('iriscat');
});

it('should set the irisid param when found', function () {
const request = { ...bidRequests[0], params: { irisid: 'abc123' } }
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data).to.have.property('irisid');
});

it('should not set the irisid param when not found', function () {
const request = { ...bidRequests[0] }
const bidRequest = spec.buildRequests([request])[0];
Expand Down

0 comments on commit fcdc4db

Please sign in to comment.