Skip to content

Commit

Permalink
Jixie Bid adapter: support more userids (#8314)
Browse files Browse the repository at this point in the history
* 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.

* adding jixie adaptor to send tid and uid2 and publisher ids

* changed to send all the ids to our backend. added a little comment

* send the config info of price granularity to our backend

* corrected code formatting violations that failed some checks
  • Loading branch information
jxdeveloper1 authored Apr 29, 2022
1 parent d90b454 commit b728298
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 0 deletions.
29 changes: 29 additions & 0 deletions modules/jixieBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { ajax } from '../src/ajax.js';
import { getRefererInfo } from '../src/refererDetection.js';
import { Renderer } from '../src/Renderer.js';
import {createEidsArray} from './userId/eids.js';

const BIDDER_CODE = 'jixie';
export const storage = getStorageManager({bidderCode: BIDDER_CODE});
Expand Down Expand Up @@ -121,6 +122,17 @@ 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 @@ -163,7 +175,22 @@ export const spec = {
}

let ids = fetchIds_();
let eids = [];
let miscDims = internal.getMiscDims();

// all available user ids are sent to our backend in the standard array layout:
if (validBidRequests[0].userId) {
let eids1 = createEidsArray(validBidRequests[0].userId);
if (eids1.length) {
eids = eids1;
}
}
// we want to send this blob of info to our backend:
let pg = config.getConfig('priceGranularity');
if (!pg) {
pg = {};
}

let transformedParams = Object.assign({}, {
auctionid: bidderRequest.auctionId,
timeout: bidderRequest.timeout,
Expand All @@ -174,6 +201,8 @@ export const spec = {
pageurl: miscDims.pageurl,
mkeywords: miscDims.mkeywords,
bids: bids,
eids: eids,
pricegranularity: pg,
cfg: jixieCfgBlob
}, ids);
return Object.assign({}, {
Expand Down
1 change: 1 addition & 0 deletions modules/jixieBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Maintainer: contact@jixie.io
# Description

Module that connects to Jixie demand source to fetch bids.
All prebid-supported user ids are sent to Jixie endpoint, if available.

# Test Parameters
```
Expand Down
96 changes: 96 additions & 0 deletions test/spec/modules/jixieBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,102 @@ describe('jixie Adapter', function () {
getLocalStorageStub.restore();
miscDimsStub.restore();
});// it

it('it should popular the pricegranularity when info is available', function () {
let content = {
'ranges': [{
'max': 12,
'increment': 0.5
},
{
'max': 5,
'increment': 0.1
}],
precision: 1
};
let getConfigStub = sinon.stub(config, 'getConfig');
getConfigStub.callsFake(function fakeFn(prop) {
if (prop == 'priceGranularity') {
return content;
}
return null;
});

const oneSpecialBidReq = Object.assign({}, bidRequests_[0]);
const request = spec.buildRequests([oneSpecialBidReq], bidderRequest_);
const payload = JSON.parse(request.data);
getConfigStub.restore();
expect(payload.pricegranularity).to.deep.include(content);
});

it('should populate eids when supported userIds are available', function () {
const oneSpecialBidReq = Object.assign({}, bidRequests_[0], {
userId: {
tdid: '11111111-2222-3333-4444-555555555555',
uid2: { id: 'AbCdEfGhIjKlMnO9qdQBW7qtMw8f1WTUvtkHe6u+fqLfhbtsqrJ697Z6YoI3IB9klGUv1wvlFIbwH7ELDlqQBGtj8AC1v7fMJ/Q45E7W90dts7UQLTDMLNmtHBRDXVb0Fpas4Vh3yN1jGVQNhzXC/RpGIVtZE8dCxcjfa7VfcTNcvxxxxx==' },
pubProvidedId: [{
source: 'puburl1.com',
uids: [{
id: 'pubid1',
atype: 1,
ext: {
stype: 'ppuid'
}
}]
}, {
source: 'puburl2.com',
uids: [{
id: 'pubid2'
}]
}]
}
});
const request = spec.buildRequests([oneSpecialBidReq], bidderRequest_);
const payload = JSON.parse(request.data);
expect(payload.eids).to.deep.include({
'source': 'adserver.org',
'uids': [
{
'id': '11111111-2222-3333-4444-555555555555',
'atype': 1,
'ext': {
'rtiPartner': 'TDID'
}
}
]
});
expect(payload.eids).to.deep.include({
'source': 'uidapi.com',
'uids': [
{
'id': 'AbCdEfGhIjKlMnO9qdQBW7qtMw8f1WTUvtkHe6u+fqLfhbtsqrJ697Z6YoI3IB9klGUv1wvlFIbwH7ELDlqQBGtj8AC1v7fMJ/Q45E7W90dts7UQLTDMLNmtHBRDXVb0Fpas4Vh3yN1jGVQNhzXC/RpGIVtZE8dCxcjfa7VfcTNcvxxxxx==',
'atype': 3
}
]
});

expect(payload.eids).to.deep.include({
'source': 'puburl1.com',
'uids': [
{
'id': 'pubid1',
'atype': 1,
'ext': {
'stype': 'ppuid'
}
}
]
});

expect(payload.eids).to.deep.include({
'source': 'puburl2.com',
'uids': [
{
'id': 'pubid2'
}
]
});
});
});// describe

/**
Expand Down

0 comments on commit b728298

Please sign in to comment.