Skip to content

Commit

Permalink
Eplanning Bid Adapter: add eids (#6732)
Browse files Browse the repository at this point in the history
  • Loading branch information
fndigrazia authored May 11, 2021
1 parent 5e69152 commit 848c892
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
7 changes: 6 additions & 1 deletion modules/eplanningBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as utils from '../src/utils.js';
import { getGlobal } from '../src/prebidGlobal.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { getStorageManager } from '../src/storageManager.js';

Expand Down Expand Up @@ -46,7 +47,7 @@ export const spec = {
url = 'https://' + urlConfig.isv + '/layers/t_pbjs_2.json';
params = {};
} else {
url = 'https://' + (urlConfig.sv || DEFAULT_SV) + '/hb/1/' + urlConfig.ci + '/' + dfpClientId + '/' + getDomain(pageUrl) + '/' + sec;
url = 'https://' + (urlConfig.sv || DEFAULT_SV) + '/pbjs/1/' + urlConfig.ci + '/' + dfpClientId + '/' + getDomain(pageUrl) + '/' + sec;
const referrerUrl = bidderRequest.refererInfo.referer.reachedTop ? window.top.document.referrer : bidderRequest.refererInfo.referer;

if (storage.hasLocalStorage()) {
Expand Down Expand Up @@ -82,6 +83,10 @@ export const spec = {
if (bidderRequest && bidderRequest.uspConsent) {
params.ccpa = bidderRequest.uspConsent;
}
const userIds = (getGlobal()).getUserIds();
for (var id in userIds) {
params[id] = (typeof userIds[id] === 'object') ? encodeURIComponent(JSON.stringify(userIds[id])) : encodeURIComponent(userIds[id]);
}
}

return {
Expand Down
30 changes: 27 additions & 3 deletions test/spec/modules/eplanningBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expect } from 'chai';
import { spec, storage } from 'modules/eplanningBidAdapter.js';
import { newBidder } from 'src/adapters/bidderFactory.js';
import { config } from 'src/config.js';
import { init } from 'modules/userId/index.js';
import * as utils from 'src/utils.js';

describe('E-Planning Adapter', function () {
Expand Down Expand Up @@ -314,7 +316,7 @@ describe('E-Planning Adapter', function () {

it('should create the url correctly', function () {
const url = spec.buildRequests(bidRequests, bidderRequest).url;
expect(url).to.equal('https://ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS');
expect(url).to.equal('https://ads.us.e-planning.net/pbjs/1/' + CI + '/1/localhost/ROS');
});

it('should return GET method', function () {
Expand Down Expand Up @@ -690,7 +692,7 @@ describe('E-Planning Adapter', function () {
hasLocalStorageStub.returns(false);
const response = spec.buildRequests(bidRequests, bidderRequest);

expect(response.url).to.equal('https://ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS');
expect(response.url).to.equal('https://ads.us.e-planning.net/pbjs/1/' + CI + '/1/localhost/ROS');
expect(response.data.vs).to.equal('F');

sinon.assert.notCalled(getLocalStorageSpy);
Expand All @@ -700,7 +702,7 @@ describe('E-Planning Adapter', function () {
it('should create the url correctly with LocalStorage', function() {
createElementVisible();
const response = spec.buildRequests(bidRequests, bidderRequest);
expect(response.url).to.equal('https://ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS');
expect(response.url).to.equal('https://ads.us.e-planning.net/pbjs/1/' + CI + '/1/localhost/ROS');

expect(response.data.vs).to.equal('F');

Expand Down Expand Up @@ -903,4 +905,26 @@ describe('E-Planning Adapter', function () {
});
});
});
describe('Send eids', function() {
it('should add eids to the request', function() {
init(config);
config.setConfig({
userSync: {
userIds: [
{ name: 'id5Id', value: { 'id5id': { uid: 'ID5-ZHMOL_IfFSt7_lVYX8rBZc6GH3XMWyPQOBUfr4bm0g!', ext: { linkType: 1 } } } },
{ name: 'pubCommonId', value: {'pubcid': 'c29cb2ae-769d-42f6-891a-f53cadee823d'} },
{ name: 'unifiedId', value: {'tdid': 'D6885E90-2A7A-4E0F-87CB-7734ED1B99A3'} }
]
}
});
let bidRequests = [validBidView];
const expected_id5id = encodeURIComponent(JSON.stringify({ uid: 'ID5-ZHMOL_IfFSt7_lVYX8rBZc6GH3XMWyPQOBUfr4bm0g!', ext: { linkType: 1 } }));
const request = spec.buildRequests(bidRequests, bidderRequest);
const dataRequest = request.data;

expect('D6885E90-2A7A-4E0F-87CB-7734ED1B99A3').to.equal(dataRequest.tdid);
expect('c29cb2ae-769d-42f6-891a-f53cadee823d').to.equal(dataRequest.pubcid);
expect(expected_id5id).to.equal(dataRequest.id5id);
});
});
});

0 comments on commit 848c892

Please sign in to comment.