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

Pass Prebid version and update IDs in Criteo bidding adapter #2913

Merged
merged 2 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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