From 78555aa8945476c1b7e5ad4bc8326c68832a079d Mon Sep 17 00:00:00 2001 From: jxdeveloper1 <71084096+jxdeveloper1@users.noreply.github.com> Date: Mon, 21 Aug 2023 23:19:01 +1000 Subject: [PATCH] Jixie adapter changes: adding sendingi of gpid, and send several ids that sits in first party cookie (#10369) * Adapter does not seem capable of supporting advertiserDomains #6650 added response comment and some trivial code. * removed a blank line at the end of file added a space behind the // in comments * in response to comment from reviewer. add the aspect of advertiserdomain in unit tests * added the code to get the keywords from the meta tags if available. * WIP * cleaned up * correcting formatting errors from circleci --- modules/jixieBidAdapter.js | 28 +++++------- test/spec/modules/jixieBidAdapter_spec.js | 52 ++++++++++++++++++++--- 2 files changed, 56 insertions(+), 24 deletions(-) diff --git a/modules/jixieBidAdapter.js b/modules/jixieBidAdapter.js index b587011c748..824bc3828b4 100644 --- a/modules/jixieBidAdapter.js +++ b/modules/jixieBidAdapter.js @@ -43,7 +43,8 @@ function fetchIds_() { client_id_c: '', client_id_ls: '', session_id_c: '', - session_id_ls: '' + session_id_ls: '', + jxeids: {} }; try { let tmp = storage.getCookie('_jxx'); @@ -55,8 +56,10 @@ function fetchIds_() { if (tmp) ret.client_id_ls = tmp; tmp = storage.getDataFromLocalStorage('_jxxs'); if (tmp) ret.session_id_ls = tmp; - tmp = storage.getCookie('_jxtoko'); - if (tmp) ret.jxtoko_id = tmp; + ['_jxtoko', '_jxifo', '_jxtdid', '__uid2_advertising_token'].forEach(function(n) { + tmp = storage.getCookie(n); + if (tmp) ret.jxeids[n] = tmp; + }); } catch (error) {} return ret; } @@ -132,17 +135,6 @@ function getMiscDims_() { return ret; } -/* function addUserId(eids, id, source, rti) { - if (id) { - if (rti) { - eids.push({ source, id, rti_partner: rti }); - } else { - eids.push({ source, id }); - } - } - return eids; -} */ - // easier for replacement in the unit test export const internal = { getDevice: getDevice_, @@ -170,13 +162,16 @@ export const spec = { let bids = []; validBidRequests.forEach(function(one) { - bids.push({ + let gpid = deepAccess(one, 'ortb2Imp.ext.gpid', deepAccess(one, 'ortb2Imp.ext.data.pbadslot', '')); + let tmp = { bidId: one.bidId, adUnitCode: one.adUnitCode, mediaTypes: (one.mediaTypes === 'undefined' ? {} : one.mediaTypes), sizes: (one.sizes === 'undefined' ? [] : one.sizes), params: one.params, - }); + gpid: gpid + }; + bids.push(tmp); }); let jixieCfgBlob = config.getConfig('jixie'); @@ -199,7 +194,6 @@ export const spec = { if (!pg) { pg = {}; } - let transformedParams = Object.assign({}, { // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionid: bidderRequest.auctionId, diff --git a/test/spec/modules/jixieBidAdapter_spec.js b/test/spec/modules/jixieBidAdapter_spec.js index 5bf2a3b6fc9..4a0fa3b4d57 100644 --- a/test/spec/modules/jixieBidAdapter_spec.js +++ b/test/spec/modules/jixieBidAdapter_spec.js @@ -72,6 +72,16 @@ describe('jixie Adapter', function () { const clientIdTest1_ = '1aba6a40-f711-11e9-868c-53a2ae972xxx'; const sessionIdTest1_ = '1594782644-1aba6a40-f711-11e9-868c-53a2ae972xxx'; const jxtokoTest1_ = 'eyJJRCI6ImFiYyJ9'; + const jxifoTest1_ = 'fffffbbbbbcccccaaaaae890606aaaaa'; + const jxtdidTest1_ = '222223d1-1111-2222-3333-b9f129299999'; + const __uid2_advertising_token_Test1 = 'AAAAABBBBBCCCCCDDDDDEEEEEUkkZPQfifpkPnnlJhtsa4o+gf4nfqgN5qHiTVX73ymTSbLT9jz1nf+Q7QdxNh9nTad9UaN5pzfHMt/rs1woQw72c1ip+8heZXPfKGZtZP7ldJesYhlo3/0FVcL/wl9ZlAo1jYOEfHo7Y9zFzNXABbbbbb=='; + + const refJxEids_ = { + '_jxtoko': jxtokoTest1_, + '_jxifo': jxifoTest1_, + '_jxtdid': jxtdidTest1_, + '__uid2_advertising_token': __uid2_advertising_token_Test1 + }; // to serve as the object that prebid will call jixie buildRequest with: (param2) const bidderRequest_ = { @@ -90,7 +100,12 @@ describe('jixie Adapter', function () { 'adUnitCode': adUnitCode0_, 'bidId': bidId0_, 'bidderRequestId': bidderRequestId_, - 'auctionId': auctionId_ + 'auctionId': auctionId_, + 'ortb2Imp': { + 'ext': { + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-1' + } + } }, { 'bidder': 'jixie', @@ -109,7 +124,12 @@ describe('jixie Adapter', function () { 'adUnitCode': adUnitCode1_, 'bidId': bidId1_, 'bidderRequestId': bidderRequestId_, - 'auctionId': auctionId_ + 'auctionId': auctionId_, + 'ortb2Imp': { + 'ext': { + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-2' + } + } }, { 'bidder': 'jixie', @@ -128,7 +148,12 @@ describe('jixie Adapter', function () { 'adUnitCode': adUnitCode2_, 'bidId': bidId2_, 'bidderRequestId': bidderRequestId_, - 'auctionId': auctionId_ + 'auctionId': auctionId_, + 'ortb2Imp': { + 'ext': { + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-3' + } + } } ]; @@ -141,7 +166,8 @@ describe('jixie Adapter', function () { 'sizes': [[300, 250], [300, 600]], 'params': { 'unit': 'prebidsampleunit' - } + }, + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-1' }, { 'bidId': bidId1_, @@ -157,7 +183,8 @@ describe('jixie Adapter', function () { 'sizes': [[300, 250]], 'params': { 'unit': 'prebidsampleunit' - } + }, + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-2' }, { 'bidId': bidId2_, @@ -173,7 +200,8 @@ describe('jixie Adapter', function () { 'sizes': [[300, 250], [300, 600]], 'params': { 'unit': 'prebidsampleunit' - } + }, + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-3' } ]; @@ -202,6 +230,15 @@ describe('jixie Adapter', function () { getCookieStub .withArgs('_jxtoko') .returns(jxtokoTest1_); + getCookieStub + .withArgs('_jxifo') + .returns(jxifoTest1_); + getCookieStub + .withArgs('_jxtdid') + .returns(jxtdidTest1_); + getCookieStub + .withArgs('__uid2_advertising_token') + .returns(__uid2_advertising_token_Test1); getCookieStub .withArgs('_jxx') .returns(clientIdTest1_); @@ -224,6 +261,7 @@ describe('jixie Adapter', function () { it('sends bid request to ENDPOINT via POST', function () { expect(request.method).to.equal('POST') }) + expect(request.data).to.be.an('string'); const payload = JSON.parse(request.data); expect(payload).to.have.property('auctionid', auctionId_); @@ -231,7 +269,7 @@ describe('jixie Adapter', function () { expect(payload).to.have.property('client_id_ls', clientIdTest1_); expect(payload).to.have.property('session_id_c', sessionIdTest1_); expect(payload).to.have.property('session_id_ls', sessionIdTest1_); - expect(payload).to.have.property('jxtoko_id', jxtokoTest1_); + expect(payload).to.have.property('jxeids').that.deep.equals(refJxEids_); expect(payload).to.have.property('device', device_); expect(payload).to.have.property('domain', domain_); expect(payload).to.have.property('pageurl', pageurl_);