Skip to content

Commit

Permalink
Pass Prebid version and update IDs in Criteo bidding adapter (prebid#…
Browse files Browse the repository at this point in the history
…2913)

* Pass Prebid version to Criteo direct bidder

* Update Criteo profile IDs
  • Loading branch information
Spark-NF authored and AlessandroDG committed Sep 13, 2018
1 parent c64f171 commit c5656c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { parse } from 'src/url';
import * as utils from 'src/utils';
import find from 'core-js/library/fn/array/find';

const ADAPTER_VERSION = 8;
const ADAPTER_VERSION = 11;
const BIDDER_CODE = 'criteo';
const CDB_ENDPOINT = '//bidder.criteo.com/cdb';
const CRITEO_VENDOR_ID = 91;
const INTEGRATION_MODES = {
'amp': 1,
};
const PROFILE_ID = 207;
const PROFILE_ID_INLINE = 207;
const PROFILE_ID_PUBLISHERTAG = 185;

// Unminified source code can be found in: https://github.com/Prebid-org/prebid-js-external-js-criteo/blob/master/dist/prod.js
const PUBLISHER_TAG_URL = '//static.criteo.net/js/ld/publishertag.prebid.js';
Expand Down Expand Up @@ -51,7 +52,7 @@ export const spec = {
}

if (publisherTagAvailable()) {
const adapter = new Criteo.PubTag.Adapters.Prebid(PROFILE_ID, ADAPTER_VERSION, bidRequests, bidderRequest);
const adapter = new Criteo.PubTag.Adapters.Prebid(PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, bidRequests, bidderRequest, '$prebid.version$');
url = adapter.buildCdbUrl();
data = adapter.buildCdbRequest();
} else {
Expand Down Expand Up @@ -156,8 +157,9 @@ function buildContext(bidRequests) {
*/
function buildCdbUrl(context) {
let url = CDB_ENDPOINT;
url += '?profileId=' + PROFILE_ID;
url += '?profileId=' + PROFILE_ID_INLINE;
url += '&av=' + String(ADAPTER_VERSION);
url += '&wv=' + encodeURIComponent('$prebid.version$');
url += '&cb=' + String(Math.floor(Math.random() * 99999999999));

if (context.integrationMode in INTEGRATION_MODES) {
Expand Down
6 changes: 3 additions & 3 deletions test/spec/modules/criteoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('The Criteo bidding adapter', () => {
},
];
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&cb=\d/);
expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/);
expect(request.method).to.equal('POST');
const ortbRequest = request.data;
expect(ortbRequest.publisher.url).to.equal(utils.getTopWindowUrl());
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('The Criteo bidding adapter', () => {
},
];
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&cb=\d/);
expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/);
expect(request.method).to.equal('POST');
const ortbRequest = request.data;
expect(ortbRequest.publisher.url).to.equal(utils.getTopWindowUrl());
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('The Criteo bidding adapter', () => {
},
];
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&cb=\d/);
expect(request.url).to.match(/^\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/);
expect(request.method).to.equal('POST');
const ortbRequest = request.data;
expect(ortbRequest.publisher.url).to.equal(utils.getTopWindowUrl());
Expand Down

0 comments on commit c5656c2

Please sign in to comment.