diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index 521eb8bc9fa..8e69bc6c6a7 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -83,9 +83,10 @@ var adUnits = [ { code: 'test-div', - sizes: [[300,250],[300,600],[728,90]], mediaTypes: { - banner: {} + banner: { + sizes: [[300,250],[300,600],[728,90]] + } }, bids: [ { @@ -216,10 +217,10 @@ name: "sharedid", expires: 28 } - }, + }, { name: 'lotamePanoramaId' - }, + }, { name: "liveIntentId", params: { @@ -230,7 +231,7 @@ name: "_li_pbid", expires: 28 } - }, + }, { name: "zeotapIdPlus" }, @@ -241,7 +242,10 @@ name: "haloId", expires: 28 } - } + }, + { + name: "quantcastId" + } ], syncDelay: 5000, auctionDelay: 1000 diff --git a/modules/.submodules.json b/modules/.submodules.json index 575c3294bf1..18e75dd1794 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -14,7 +14,8 @@ "sharedIdSystem", "intentIqIdSystem", "zeotapIdPlusIdSystem", - "haloIdSystem" + "haloIdSystem", + "quantcastIdSystem" ], "adpod": [ "freeWheelAdserverVideo", diff --git a/modules/quantcastIdSystem.js b/modules/quantcastIdSystem.js new file mode 100644 index 00000000000..e86c130dc5b --- /dev/null +++ b/modules/quantcastIdSystem.js @@ -0,0 +1,44 @@ +/** + * This module adds QuantcastID to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/quantcastIdSystem + * @requires module:modules/userId + */ + +import {submodule} from '../src/hook.js' +import { getStorageManager } from '../src/storageManager.js'; + +const QUANTCAST_FPA = '__qca'; + +export const storage = getStorageManager(); + +/** @type {Submodule} */ +export const quantcastIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'quantcastId', + + /** + * decode the stored id value for passing to bid requests + * @function + * @returns {{quantcastId: string} | undefined} + */ + decode(value) { + return value; + }, + + /** + * read Quantcast first party cookie and pass it along in quantcastId + * @function + * @returns {{id: {quantcastId: string} | undefined}}} + */ + getId() { + // Consent signals are currently checked on the server side. + let fpa = storage.getCookie(QUANTCAST_FPA); + return { id: fpa ? { quantcastId: fpa } : undefined } + } +}; + +submodule('userId', quantcastIdSubmodule); diff --git a/modules/userId/eids.js b/modules/userId/eids.js index 65907370ad6..eebd0146d50 100644 --- a/modules/userId/eids.js +++ b/modules/userId/eids.js @@ -136,6 +136,12 @@ const USER_IDS_CONFIG = { 'haloId': { source: 'audigent.com', atype: 1 + }, + + // quantcastId + 'quantcastId': { + source: 'quantcast.com', + atype: 1 } }; diff --git a/modules/userId/eids.md b/modules/userId/eids.md index e5dca014172..03aec46cf48 100644 --- a/modules/userId/eids.md +++ b/modules/userId/eids.md @@ -109,6 +109,13 @@ userIdAsEids = [ id: 'some-random-id-value', atype: 1 }] + }, + { + source: 'quantcast.com', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] } ] ``` diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index fdb5fc8005d..a6a44f9296d 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -222,6 +222,21 @@ describe('eids array generation for known sub-modules', function() { }] }); }); + + it('quantcastId', function() { + const userId = { + quantcastId: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'quantcast.com', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] + }); + }); }); describe('Negative case', function() { diff --git a/test/spec/modules/quantcastIdSystem_spec.js b/test/spec/modules/quantcastIdSystem_spec.js new file mode 100644 index 00000000000..12c8689fd3f --- /dev/null +++ b/test/spec/modules/quantcastIdSystem_spec.js @@ -0,0 +1,19 @@ +import { quantcastIdSubmodule, storage } from 'modules/quantcastIdSystem.js'; + +describe('QuantcastId module', function () { + beforeEach(function() { + storage.setCookie('__qca', '', 'Thu, 01 Jan 1970 00:00:00 GMT'); + }); + + it('getId() should return a quantcast id when the Quantcast first party cookie exists', function () { + storage.setCookie('__qca', 'P0-TestFPA'); + + const id = quantcastIdSubmodule.getId(); + expect(id).to.be.deep.equal({id: {quantcastId: 'P0-TestFPA'}}); + }); + + it('getId() should return an empty id when the Quantcast first party cookie is missing', function () { + const id = quantcastIdSubmodule.getId(); + expect(id).to.be.deep.equal({id: undefined}); + }); +});