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

update quantcastBidAdapter to pass quantcast fpa in the bid request #5947

Merged
merged 5 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 11 additions & 1 deletion 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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Quantcast have a registered GVL id?

Passing the following will allow storage access when GDPR Enforcement is enabled.
https://github.com/prebid/Prebid.js/blob/master/modules/appnexusBidAdapter.js#L61

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do. I updated the code accordingly. Thanks for the catch.


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 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