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

GumGum Bid Adapter: Send pubProvidedId in the query string #10561

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
19 changes: 18 additions & 1 deletion modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const JCSI = { t: 0, rq: 8, pbv: '$prebid.version$' }
const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO];
const TIME_TO_LIVE = 60;
const DELAY_REQUEST_TIME = 1800000; // setting to 30 mins
const pubProvidedIdSources = ['dac.co.jp', 'audigent.com', 'id5-sync.com', 'liveramp.com', 'intentiq.com', 'liveintent.com', 'crwdcntrl.net', 'quantcast.com', 'adserver.org', 'yahoo.com']

let invalidRequestIds = {};
let pageViewId = null;
Expand Down Expand Up @@ -310,7 +311,23 @@ function buildRequests(validBidRequests, bidderRequest) {
// ADTS-174 Removed unnecessary checks to fix failing test
data.lt = lt;
data.to = to;

function jsoStringifynWithMaxLength(data, maxLength) {
let jsonString = JSON.stringify(data);
if (jsonString.length <= maxLength) {
return jsonString;
} else {
const truncatedData = data.slice(0, Math.floor(data.length * (maxLength / jsonString.length)));
jsonString = JSON.stringify(truncatedData);
return jsonString;
}
}
// Send filtered pubProvidedId's
if (userId && userId.pubProvidedId) {
let filteredData = userId.pubProvidedId.filter(item => pubProvidedIdSources.includes(item.source));
let maxLength = 1800; // replace this with your desired maximum length
let truncatedJsonString = jsoStringifynWithMaxLength(filteredData, maxLength);
data.pubProvidedId = truncatedJsonString
}
// ADJS-1286 Read id5 id linktype field
if (userId && userId.id5id && userId.id5id.uid && userId.id5id.ext) {
data.id5Id = userId.id5id.uid || null
Expand Down
35 changes: 35 additions & 0 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,30 @@ describe('gumgumAdapter', function () {
}
}
},
pubProvidedId: [
{
uids: [
{
ext: {
stype: 'ppuid',
},
id: 'aac4504f-ef89-401b-a891-ada59db44336',
},
],
source: 'sonobi.com',
},
{
uids: [
{
ext: {
stype: 'ppuid',
},
id: 'y-zqTHmW9E2uG3jEETC6i6BjGcMhPXld2F~A',
},
],
source: 'aol.com',
},
],
adUnitCode: 'adunit-code',
sizes: sizesArray,
bidId: '30b31c1838de1e',
Expand Down Expand Up @@ -168,6 +192,11 @@ describe('gumgumAdapter', function () {
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.aun).to.equal(bidRequests[0].adUnitCode);
});
it('should set pubProvidedId if the uid and pubProvidedId are available', function () {
const request = { ...bidRequests[0] };
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.pubProvidedId).to.equal(JSON.stringify(bidRequests[0].userId.pubProvidedId));
});
it('should set id5Id and id5IdLinkType if the uid and linkType are available', function () {
const request = { ...bidRequests[0] };
const bidRequest = spec.buildRequests([request])[0];
Expand Down Expand Up @@ -488,6 +517,12 @@ describe('gumgumAdapter', function () {
expect(request.data).to.not.include.any.keys('eAdBuyId');
expect(request.data).to.not.include.any.keys('adBuyId');
});
it('should set pubProvidedId if the uid and pubProvidedId are available', function () {
const request = { ...bidRequests[0] };
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.pubProvidedId).to.equal(JSON.stringify(bidRequests[0].userId.pubProvidedId));
});

it('should add gdpr consent parameters if gdprConsent is present', function () {
const gdprConsent = { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', gdprApplies: true };
const fakeBidRequest = { gdprConsent: gdprConsent };
Expand Down