Skip to content

Commit

Permalink
Jixie adapter changes: adding sendingi of gpid, and send several ids …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
jxdeveloper1 authored Aug 21, 2023
1 parent 3263e6e commit 78555aa
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 24 deletions.
28 changes: 11 additions & 17 deletions modules/jixieBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
}
Expand Down Expand Up @@ -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_,
Expand Down Expand Up @@ -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');
Expand All @@ -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,
Expand Down
52 changes: 45 additions & 7 deletions test/spec/modules/jixieBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_ = {
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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'
}
}
}
];

Expand All @@ -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_,
Expand All @@ -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_,
Expand All @@ -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'
}
];

Expand Down Expand Up @@ -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_);
Expand All @@ -224,14 +261,15 @@ 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_);
expect(payload).to.have.property('client_id_c', clientIdTest1_);
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_);
Expand Down

0 comments on commit 78555aa

Please sign in to comment.