Skip to content

Commit ed74a03

Browse files
hrkhitoMurano Takamasagn-daikichitakm-furukawafurukawaTakumi
authored
SSP_Genie Bid Adapter : ID5 Compatible Adapter (#12974)
* modify adUnit infomation * fix imuid module * feat(GenieeBidAdapter): Add support for GPID and pbadslot - Add support for GPID (Global Placement ID) from ortb2Imp.ext.gpid - Add fallback support for ortb2Imp.ext.data.pbadslot - Include gpid parameter in request when GPID exists - Add test cases to verify GPID, pbadslot, and priority behavior * Aladdin Bidder ID5 Compatible Adapter * add comment * modified test message * the import of buildExtuidQuery was missing * test: add test cases for id5id in extuid query * delete duplicate test --------- Co-authored-by: Murano Takamasa <[email protected]> Co-authored-by: daikichiteranishi <[email protected]> Co-authored-by: teranishi daikichi <[email protected]> Co-authored-by: gn-daikichi <[email protected]> Co-authored-by: takumi-furukawa <[email protected]> Co-authored-by: furukawaTakumi <[email protected]> Co-authored-by: furukawaTakumi <[email protected]> Co-authored-by: haruki-yamaguchi <[email protected]>
1 parent f89550a commit ed74a03

File tree

2 files changed

+110
-16
lines changed

2 files changed

+110
-16
lines changed

modules/ssp_genieeBidAdapter.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ function hasParamsNotBlankString(params, key) {
124124
);
125125
}
126126

127+
export const buildExtuidQuery = ({id5, imuId}) => {
128+
const params = [
129+
...(id5 ? [`id5:${id5}`] : []),
130+
...(imuId ? [`im:${imuId}`] : []),
131+
];
132+
133+
const queryString = params.join('\t');
134+
if (!queryString) return null;
135+
return queryString;
136+
}
137+
127138
/**
128139
* making request data be used commonly banner and native
129140
* @see https://docs.prebid.org/dev-docs/bidder-adaptor.html#location-and-referrers
@@ -215,9 +226,11 @@ function makeCommonRequestData(bid, geparameter, refererInfo) {
215226
}
216227
}
217228

218-
// imuid
219-
const imuidQuery = getImuidAsQueryParameter(bid);
220-
if (imuidQuery) data.extuid = imuidQuery;
229+
// imuid, id5
230+
const id5 = utils.deepAccess(bid, 'userId.id5id.uid');
231+
const imuId = utils.deepAccess(bid, 'userId.imuid');
232+
const extuidQuery = buildExtuidQuery({id5, imuId});
233+
if (extuidQuery) data.extuid = extuidQuery;
221234

222235
// makeUAQuery
223236
// To avoid double encoding, not using encodeURIComponent here
@@ -311,14 +324,6 @@ function makeBidResponseAd(innerHTML) {
311324
return '<body marginwidth="0" marginheight="0">' + innerHTML + '</body>';
312325
}
313326

314-
/**
315-
* return imuid strings as query parameters
316-
*/
317-
function getImuidAsQueryParameter(bid) {
318-
const imuid = utils.deepAccess(bid, 'userId.imuid');
319-
return imuid ? 'im:' + imuid : ''; // To avoid double encoding, not using encodeURIComponent here
320-
}
321-
322327
function getUserAgent() {
323328
return storage.getDataFromLocalStorage('key') || null;
324329
}

test/spec/modules/ssp_genieeBidAdapter_spec.js

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { expect } from 'chai';
22
import {
33
spec,
44
BANNER_ENDPOINT,
5+
buildExtuidQuery,
56
} from 'modules/ssp_genieeBidAdapter.js';
67
import { config } from 'src/config.js';
78

@@ -347,15 +348,103 @@ describe('ssp_genieeBidAdapter', function () {
347348
expect(request[0].data.apid).to.deep.equal(bundle);
348349
});
349350

350-
it('should not include the extuid query when bid.userId.imuid does not exist', function () {
351+
it('should include only imuid in extuid query when only imuid exists', function () {
352+
const imuid = 'b.a4ad1d3eeb51e600';
353+
const request = spec.buildRequests([{...BANNER_BID, userId: {imuid}}]);
354+
expect(request[0].data.extuid).to.deep.equal(`im:${imuid}`);
355+
});
356+
357+
it('should include only id5id in extuid query when only id5id exists', function () {
358+
const id5id = 'id5id';
359+
const request = spec.buildRequests([{...BANNER_BID, userId: {id5id: {uid: id5id}}}]);
360+
expect(request[0].data.extuid).to.deep.equal(`id5:${id5id}`);
361+
});
362+
363+
it('should include id5id and imuid in extuid query when id5id and imuid exists', function () {
364+
const imuid = 'b.a4ad1d3eeb51e600';
365+
const id5id = 'id5id';
366+
const request = spec.buildRequests([{...BANNER_BID, userId: {id5id: {uid: id5id}, imuid: imuid}}]);
367+
expect(request[0].data.extuid).to.deep.equal(`id5:${id5id}\tim:${imuid}`);
368+
});
369+
370+
it('should not include the extuid query when both id5 and imuid are missing', function () {
351371
const request = spec.buildRequests([BANNER_BID]);
352372
expect(request[0].data).to.not.have.property('extuid');
353373
});
354374

355-
it('should include an extuid query when bid.userId.imuid exists', function () {
356-
const imuid = 'b.a4ad1d3eeb51e600';
357-
const request = spec.buildRequests([{...BANNER_BID, userId: {imuid}}]);
358-
expect(request[0].data.extuid).to.deep.equal(`im:${imuid}`);
375+
describe('buildExtuidQuery', function() {
376+
it('should return tab-separated string when both id5 and imuId exist', function() {
377+
const result = buildExtuidQuery({ id5: 'test_id5', imuId: 'test_imu' });
378+
expect(result).to.equal('id5:test_id5\tim:test_imu');
379+
});
380+
381+
it('should return only id5 when imuId is missing', function() {
382+
const result = buildExtuidQuery({ id5: 'test_id5', imuId: null });
383+
expect(result).to.equal('id5:test_id5');
384+
});
385+
386+
it('should return only imuId when id5 is missing', function() {
387+
const result = buildExtuidQuery({ id5: null, imuId: 'test_imu' });
388+
expect(result).to.equal('im:test_imu');
389+
});
390+
391+
it('should return null when both id5 and imuId are missing', function() {
392+
const result = buildExtuidQuery({ id5: null, imuId: null });
393+
expect(result).to.be.null;
394+
});
395+
});
396+
397+
it('should include gpid when ortb2Imp.ext.gpid exists', function () {
398+
const gpid = '/123/abc';
399+
const bidWithGpid = {
400+
...BANNER_BID,
401+
ortb2Imp: {
402+
ext: {
403+
gpid: gpid
404+
}
405+
}
406+
};
407+
const request = spec.buildRequests([bidWithGpid]);
408+
expect(String(request[0].data.gpid)).to.have.string(gpid);
409+
});
410+
411+
it('should include gpid when ortb2Imp.ext.data.pbadslot exists', function () {
412+
const pbadslot = '/123/abc';
413+
const bidWithPbadslot = {
414+
...BANNER_BID,
415+
ortb2Imp: {
416+
ext: {
417+
data: {
418+
pbadslot: pbadslot
419+
}
420+
}
421+
}
422+
};
423+
const request = spec.buildRequests([bidWithPbadslot]);
424+
expect(String(request[0].data.gpid)).to.have.string(pbadslot);
425+
});
426+
427+
it('should prioritize ortb2Imp.ext.gpid over ortb2Imp.ext.data.pbadslot', function () {
428+
const gpid = '/123/abc';
429+
const pbadslot = '/456/def';
430+
const bidWithBoth = {
431+
...BANNER_BID,
432+
ortb2Imp: {
433+
ext: {
434+
gpid: gpid,
435+
data: {
436+
pbadslot: pbadslot
437+
}
438+
}
439+
}
440+
};
441+
const request = spec.buildRequests([bidWithBoth]);
442+
expect(String(request[0].data.gpid)).to.have.string(gpid);
443+
});
444+
445+
it('should not include gpid when neither ortb2Imp.ext.gpid nor ortb2Imp.ext.data.pbadslot exists', function () {
446+
const request = spec.buildRequests([BANNER_BID]);
447+
expect(request[0].data).to.not.have.property('gpid');
359448
});
360449

361450
it('should include gpid when ortb2Imp.ext.gpid exists', function () {

0 commit comments

Comments
 (0)