Skip to content

Commit

Permalink
update quantcastBidAdapter to pass quantcast fpa in the bid request (#…
Browse files Browse the repository at this point in the history
…5947)

* update quantcastBidAdapter to pass quantcast fpa in the bid request

* remove empty line from lunamediahBidAdapter

* pass quantcast vendor id when obtaining storage manager
  • Loading branch information
mckurt authored Nov 17, 2020
1 parent 5aa0fe6 commit c04bd6d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
14 changes: 12 additions & 2 deletions modules/quantcastBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as utils from '../src/utils.js';
import { ajax } from '../src/ajax.js';
import { config } from '../src/config.js';
import { getStorageManager } from '../src/storageManager.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import find from 'core-js-pure/features/array/find.js';

Expand All @@ -18,6 +19,9 @@ export const QUANTCAST_TEST_PUBLISHER = 'test-publisher';
export const QUANTCAST_TTL = 4;
export const QUANTCAST_PROTOCOL = 'https';
export const QUANTCAST_PORT = '8443';
export const QUANTCAST_FPA = '__qca';

export const storage = getStorageManager(QUANTCAST_VENDOR_ID, BIDDER_CODE);

function makeVideoImp(bid) {
const video = {};
Expand Down Expand Up @@ -101,6 +105,11 @@ function checkTCFv2(tcData) {
return !!(vendorConsent && purposeConsent);
}

function getQuantcastFPA() {
let fpa = storage.getCookie(QUANTCAST_FPA)
return fpa || ''
}

let hasUserSynced = false;

/**
Expand All @@ -109,7 +118,7 @@ let hasUserSynced = false;
*/
export const spec = {
code: BIDDER_CODE,
GVLID: 11,
GVLID: QUANTCAST_VENDOR_ID,
supportedMediaTypes: ['banner', 'video'],

/**
Expand Down Expand Up @@ -189,7 +198,8 @@ export const spec = {
uspSignal: uspConsent ? 1 : 0,
uspConsent,
coppa: config.getConfig('coppa') === true ? 1 : 0,
prebidJsVersion: '$prebid.version$'
prebidJsVersion: '$prebid.version$',
fpa: getQuantcastFPA()
};

const data = JSON.stringify(requestData);
Expand Down
27 changes: 21 additions & 6 deletions test/spec/modules/quantcastBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
QUANTCAST_TEST_PUBLISHER,
QUANTCAST_PROTOCOL,
QUANTCAST_PORT,
spec as qcSpec
spec as qcSpec,
storage
} from '../../../modules/quantcastBidAdapter.js';
import { newBidder } from '../../../src/adapters/bidderFactory.js';
import { parseUrl } from 'src/utils.js';
Expand Down Expand Up @@ -42,6 +43,8 @@ describe('Quantcast adapter', function () {
canonicalUrl: 'http://example.com/hello.html'
}
};

storage.setCookie('__qca', '', 'Thu, 01 Jan 1970 00:00:00 GMT');
});

function setupVideoBidRequest(videoParams) {
Expand Down Expand Up @@ -140,7 +143,8 @@ describe('Quantcast adapter', function () {
gdprSignal: 0,
uspSignal: 0,
coppa: 0,
prebidJsVersion: '$prebid.version$'
prebidJsVersion: '$prebid.version$',
fpa: ''
};

it('sends banner bid requests contains all the required parameters', function () {
Expand Down Expand Up @@ -208,7 +212,8 @@ describe('Quantcast adapter', function () {
gdprSignal: 0,
uspSignal: 0,
coppa: 0,
prebidJsVersion: '$prebid.version$'
prebidJsVersion: '$prebid.version$',
fpa: ''
};

expect(requests[0].data).to.equal(JSON.stringify(expectedVideoBidRequest));
Expand Down Expand Up @@ -244,7 +249,8 @@ describe('Quantcast adapter', function () {
gdprSignal: 0,
uspSignal: 0,
coppa: 0,
prebidJsVersion: '$prebid.version$'
prebidJsVersion: '$prebid.version$',
fpa: ''
};

expect(requests[0].data).to.equal(JSON.stringify(expectedVideoBidRequest));
Expand Down Expand Up @@ -276,7 +282,8 @@ describe('Quantcast adapter', function () {
gdprSignal: 0,
uspSignal: 0,
coppa: 0,
prebidJsVersion: '$prebid.version$'
prebidJsVersion: '$prebid.version$',
fpa: ''
};

expect(requests[0].data).to.equal(JSON.stringify(expectedVideoBidRequest));
Expand Down Expand Up @@ -340,7 +347,8 @@ describe('Quantcast adapter', function () {
gdprSignal: 0,
uspSignal: 0,
coppa: 0,
prebidJsVersion: '$prebid.version$'
prebidJsVersion: '$prebid.version$',
fpa: ''
};

expect(requests[0].data).to.equal(JSON.stringify(expectedBidRequest));
Expand Down Expand Up @@ -584,6 +592,13 @@ describe('Quantcast adapter', function () {
expect(parsed.uspConsent).to.equal('consentString');
});

it('propagates Quantcast first-party cookie (fpa)', function() {
storage.setCookie('__qca', 'P0-TestFPA');
const requests = qcSpec.buildRequests([bidRequest], bidderRequest);
const parsed = JSON.parse(requests[0].data);
expect(parsed.fpa).to.equal('P0-TestFPA');
});

describe('propagates coppa', function() {
let sandbox;
beforeEach(() => {
Expand Down

0 comments on commit c04bd6d

Please sign in to comment.