Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relaido Bid Adapter: support imuid module #7422

Merged
merged 15 commits into from
Sep 30, 2021
Merged
10 changes: 8 additions & 2 deletions modules/relaidoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getStorageManager } from '../src/storageManager.js';

const BIDDER_CODE = 'relaido';
const BIDDER_DOMAIN = 'api.relaido.jp';
const ADAPTER_VERSION = '1.0.5';
const ADAPTER_VERSION = '1.0.6';
const DEFAULT_TTL = 300;
const UUID_KEY = 'relaido_uuid';

Expand Down Expand Up @@ -68,9 +68,15 @@ function buildRequests(validBidRequests, bidderRequest) {
media_type: mediaType,
uuid: uuid,
width: width,
height: height
height: height,
pv: '$prebid.version$'
};

const imuid = utils.deepAccess(bidRequest, 'userId.imuid');
if (imuid) {
payload.imuid = imuid;
}

// It may not be encoded, so add it at the end of the payload
payload.ref = bidderRequest.refererInfo.referer;

Expand Down
40 changes: 20 additions & 20 deletions test/spec/modules/relaidoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ describe('RelaidoAdapter', function () {
let bidderRequest;
let serverResponse;
let serverRequest;
let generateUUIDStub;
let triggerPixelStub;

beforeEach(function () {
generateUUIDStub = sinon.stub(utils, 'generateUUID').returns(relaido_uuid);
triggerPixelStub = sinon.stub(utils, 'triggerPixel');
bidRequest = {
bidder: 'relaido',
params: {
Expand Down Expand Up @@ -72,6 +76,10 @@ describe('RelaidoAdapter', function () {
mediaType: 'video',
};
});
afterEach(() => {
generateUUIDStub.restore();
triggerPixelStub.restore();
});

describe('spec.isBidRequestValid', function () {
it('should return true when the required params are passed by video', function () {
Expand Down Expand Up @@ -207,6 +215,7 @@ describe('RelaidoAdapter', function () {
expect(request.data.uuid).to.equal(relaido_uuid);
expect(request.data.width).to.equal(bidRequest.mediaTypes.video.playerSize[0][0]);
expect(request.data.height).to.equal(bidRequest.mediaTypes.video.playerSize[0][1]);
expect(request.data.pv).to.equal('$prebid.version$');
});

it('should build bid requests by banner', function () {
Expand Down Expand Up @@ -251,8 +260,6 @@ describe('RelaidoAdapter', function () {
expect(bidRequests).to.have.lengthOf(1);
const request = bidRequests[0];

// eslint-disable-next-line no-console
console.log(bidRequests);
expect(request.width).to.equal(1);
});

Expand All @@ -264,6 +271,15 @@ describe('RelaidoAdapter', function () {
expect(keys[0]).to.equal('version');
expect(keys[keys.length - 1]).to.equal('ref');
});

it('should get imuid', function () {
bidRequest.userId = {}
bidRequest.userId.imuid = 'i.tjHcK_7fTcqnbrS_YA2vaw';
const bidRequests = spec.buildRequests([bidRequest], bidderRequest);
expect(bidRequests).to.have.lengthOf(1);
const request = bidRequests[0];
expect(request.data.imuid).to.equal('i.tjHcK_7fTcqnbrS_YA2vaw');
});
});

describe('spec.interpretResponse', function () {
Expand Down Expand Up @@ -350,14 +366,6 @@ describe('RelaidoAdapter', function () {
});

describe('spec.onBidWon', function () {
let stub;
beforeEach(() => {
stub = sinon.stub(utils, 'triggerPixel');
});
afterEach(() => {
stub.restore();
});

it('Should create nurl pixel if bid nurl', function () {
let bid = {
bidder: bidRequest.bidder,
Expand All @@ -371,7 +379,7 @@ describe('RelaidoAdapter', function () {
ref: window.location.href,
}
spec.onBidWon(bid);
const parser = utils.parseUrl(stub.getCall(0).args[0]);
const parser = utils.parseUrl(triggerPixelStub.getCall(0).args[0]);
const query = parser.search;
expect(parser.hostname).to.equal('api.relaido.jp');
expect(parser.pathname).to.equal('/tr/v1/prebid/win.gif');
Expand All @@ -387,14 +395,6 @@ describe('RelaidoAdapter', function () {
});

describe('spec.onTimeout', function () {
let stub;
beforeEach(() => {
stub = sinon.stub(utils, 'triggerPixel');
});
afterEach(() => {
stub.restore();
});

it('Should create nurl pixel if bid nurl', function () {
const data = [{
bidder: bidRequest.bidder,
Expand All @@ -405,7 +405,7 @@ describe('RelaidoAdapter', function () {
timeout: bidderRequest.timeout,
}];
spec.onTimeout(data);
const parser = utils.parseUrl(stub.getCall(0).args[0]);
const parser = utils.parseUrl(triggerPixelStub.getCall(0).args[0]);
const query = parser.search;
expect(parser.hostname).to.equal('api.relaido.jp');
expect(parser.pathname).to.equal('/tr/v1/prebid/timeout.gif');
Expand Down