Skip to content

Commit

Permalink
Vidazoo Bid Adapter: added bid request params (gpid, cat, pagecat) (p…
Browse files Browse the repository at this point in the history
…rebid#9293)

* feat(module): multi size request

* fix getUserSyncs
added tests

* update(module): package-lock.json from master

* feat(module): VidazooBidAdapter - send top query params to server

* added bid request params

* making the linter happy :)

Co-authored-by: roman <shmoop207@gmail.com>
Co-authored-by: Saar Amrani <89377180+saar120@users.noreply.github.com>
Co-authored-by: Saar Amrani <saar120@gmail.com>
  • Loading branch information
4 people authored and jorgeluisrocha committed May 18, 2023
1 parent 5d067dd commit 75a8ad0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 25 deletions.
9 changes: 8 additions & 1 deletion modules/vidazooBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ function buildRequest(bid, topWindowUrl, sizes, bidderRequest) {
const subDomain = extractSubDomain(params);
const ptrace = getCacheOpt();

const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid', deepAccess(bid, 'ortb2Imp.ext.data.pbadslot', ''));
const cat = deepAccess(bidderRequest, 'ortb2.site.cat', []);
const pagecat = deepAccess(bidderRequest, 'ortb2.site.pagecat', []);

if (isFn(bid.getFloor)) {
const floorInfo = bid.getFloor({
currency: 'USD',
Expand Down Expand Up @@ -99,7 +103,10 @@ function buildRequest(bid, topWindowUrl, sizes, bidderRequest) {
prebidVersion: '$prebid.version$',
res: `${screen.width}x${screen.height}`,
schain: schain,
ptrace: ptrace
ptrace: ptrace,
gpid: gpid,
cat: cat,
pagecat: pagecat
};

appendUserIdsToRequestPayload(data, userId);
Expand Down
62 changes: 38 additions & 24 deletions test/spec/modules/vidazooBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect} from 'chai';
import { expect } from 'chai';
import {
spec as adapter,
SUPPORTED_ID_SYSTEMS,
Expand All @@ -15,8 +15,8 @@ import {
getVidazooSessionId,
} from 'modules/vidazooBidAdapter.js';
import * as utils from 'src/utils.js';
import {version} from 'package.json';
import {useFakeTimers} from 'sinon';
import { version } from 'package.json';
import { useFakeTimers } from 'sinon';

const SUB_DOMAIN = 'openrtb';

Expand All @@ -38,7 +38,12 @@ const BID = {
'sizes': [[300, 250], [300, 600]],
'bidderRequestId': '1fdb5ff1b6eaa7',
'requestId': 'b0777d85-d061-450e-9bc7-260dd54bbb7a',
'schain': 'a0819c69-005b-41ed-af06-1be1e0aefefc'
'schain': 'a0819c69-005b-41ed-af06-1be1e0aefefc',
'ortb2Imp': {
'ext': {
'gpid': '1234567890'
}
}
};

const BIDDER_REQUEST = {
Expand All @@ -50,7 +55,13 @@ const BIDDER_REQUEST = {
'refererInfo': {
'page': 'https://www.greatsite.com',
'ref': 'https://www.somereferrer.com'
}
},
'ortb2': {
'site': {
'cat': ['IAB2'],
'pagecat': ['IAB2-2']
}
},
};

const SERVER_RESPONSE = {
Expand Down Expand Up @@ -85,7 +96,7 @@ const REQUEST = {

function getTopWindowQueryParams() {
try {
const parsedUrl = utils.parseUrl(window.top.document.URL, {decodeSearchAsString: true});
const parsedUrl = utils.parseUrl(window.top.document.URL, { decodeSearchAsString: true });
return parsedUrl.search;
} catch (e) {
return '';
Expand Down Expand Up @@ -150,7 +161,7 @@ describe('VidazooBidAdapter', function () {
before(function () {
$$PREBID_GLOBAL$$.bidderSettings = {
vidazoo: {
storageAllowed: true
storageAllowed: true,
}
};
sandbox = sinon.sandbox.create();
Expand Down Expand Up @@ -187,6 +198,9 @@ describe('VidazooBidAdapter', function () {
uqs: getTopWindowQueryParams(),
'ext.param1': 'loremipsum',
'ext.param2': 'dolorsitamet',
gpid: '1234567890',
cat: ['IAB2'],
pagecat: ['IAB2-2']
}
});
});
Expand All @@ -198,7 +212,7 @@ describe('VidazooBidAdapter', function () {
});
describe('getUserSyncs', function () {
it('should have valid user sync with iframeEnabled', function () {
const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]);
const result = adapter.getUserSyncs({ iframeEnabled: true }, [SERVER_RESPONSE]);

expect(result).to.deep.equal([{
type: 'iframe',
Expand All @@ -207,15 +221,15 @@ describe('VidazooBidAdapter', function () {
});

it('should have valid user sync with cid on response', function () {
const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]);
const result = adapter.getUserSyncs({ iframeEnabled: true }, [SERVER_RESPONSE]);
expect(result).to.deep.equal([{
type: 'iframe',
url: 'https://sync.cootlogix.com/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy='
}]);
});

it('should have valid user sync with pixelEnabled', function () {
const result = adapter.getUserSyncs({pixelEnabled: true}, [SERVER_RESPONSE]);
const result = adapter.getUserSyncs({ pixelEnabled: true }, [SERVER_RESPONSE]);

expect(result).to.deep.equal([{
'url': 'https://sync.cootlogix.com/api/sync/image/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=',
Expand All @@ -231,12 +245,12 @@ describe('VidazooBidAdapter', function () {
});

it('should return empty array when there is no ad', function () {
const responses = adapter.interpretResponse({price: 1, ad: ''});
const responses = adapter.interpretResponse({ price: 1, ad: '' });
expect(responses).to.be.empty;
});

it('should return empty array when there is no price', function () {
const responses = adapter.interpretResponse({price: null, ad: 'great ad'});
const responses = adapter.interpretResponse({ price: null, ad: 'great ad' });
expect(responses).to.be.empty;
});

Expand Down Expand Up @@ -276,11 +290,11 @@ describe('VidazooBidAdapter', function () {
const userId = (function () {
switch (idSystemProvider) {
case 'lipb':
return {lipbid: id};
return { lipbid: id };
case 'parrableId':
return {eid: id};
return { eid: id };
case 'id5id':
return {uid: id};
return { uid: id };
default:
return id;
}
Expand All @@ -299,18 +313,18 @@ describe('VidazooBidAdapter', function () {

describe('alternate param names extractors', function () {
it('should return undefined when param not supported', function () {
const cid = extractCID({'c_id': '1'});
const pid = extractPID({'p_id': '1'});
const subDomain = extractSubDomain({'sub_domain': 'prebid'});
const cid = extractCID({ 'c_id': '1' });
const pid = extractPID({ 'p_id': '1' });
const subDomain = extractSubDomain({ 'sub_domain': 'prebid' });
expect(cid).to.be.undefined;
expect(pid).to.be.undefined;
expect(subDomain).to.be.undefined;
});

it('should return value when param supported', function () {
const cid = extractCID({'cID': '1'});
const pid = extractPID({'Pid': '2'});
const subDomain = extractSubDomain({'subDOMAIN': 'prebid'});
const cid = extractCID({ 'cID': '1' });
const pid = extractPID({ 'Pid': '2' });
const subDomain = extractSubDomain({ 'subDOMAIN': 'prebid' });
expect(cid).to.be.equal('1');
expect(pid).to.be.equal('2');
expect(subDomain).to.be.equal('prebid');
Expand Down Expand Up @@ -423,7 +437,7 @@ describe('VidazooBidAdapter', function () {
now
});
setStorageItem('myKey', 2020);
const {value, created} = getStorageItem('myKey');
const { value, created } = getStorageItem('myKey');
expect(created).to.be.equal(now);
expect(value).to.be.equal(2020);
expect(typeof value).to.be.equal('number');
Expand All @@ -439,8 +453,8 @@ describe('VidazooBidAdapter', function () {
});

it('should parse JSON value', function () {
const data = JSON.stringify({event: 'send'});
const {event} = tryParseJSON(data);
const data = JSON.stringify({ event: 'send' });
const { event } = tryParseJSON(data);
expect(event).to.be.equal('send');
});

Expand Down

0 comments on commit 75a8ad0

Please sign in to comment.