Skip to content

Commit

Permalink
add quantcast ID submodule (#5727)
Browse files Browse the repository at this point in the history
* add quantcast ID submodule

* use setCookie in test

* add comment for consent signals
  • Loading branch information
mckurt authored Sep 16, 2020
1 parent 04ea603 commit 298139f
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 7 deletions.
16 changes: 10 additions & 6 deletions integrationExamples/gpt/userId_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down Expand Up @@ -216,10 +217,10 @@
name: "sharedid",
expires: 28
}
},
},
{
name: 'lotamePanoramaId'
},
},
{
name: "liveIntentId",
params: {
Expand All @@ -230,7 +231,7 @@
name: "_li_pbid",
expires: 28
}
},
},
{
name: "zeotapIdPlus"
},
Expand All @@ -241,7 +242,10 @@
name: "haloId",
expires: 28
}
}
},
{
name: "quantcastId"
}
],
syncDelay: 5000,
auctionDelay: 1000
Expand Down
3 changes: 2 additions & 1 deletion modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"sharedIdSystem",
"intentIqIdSystem",
"zeotapIdPlusIdSystem",
"haloIdSystem"
"haloIdSystem",
"quantcastIdSystem"
],
"adpod": [
"freeWheelAdserverVideo",
Expand Down
44 changes: 44 additions & 0 deletions modules/quantcastIdSystem.js
Original file line number Diff line number Diff line change
@@ -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);
6 changes: 6 additions & 0 deletions modules/userId/eids.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ const USER_IDS_CONFIG = {
'haloId': {
source: 'audigent.com',
atype: 1
},

// quantcastId
'quantcastId': {
source: 'quantcast.com',
atype: 1
}
};

Expand Down
7 changes: 7 additions & 0 deletions modules/userId/eids.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ userIdAsEids = [
id: 'some-random-id-value',
atype: 1
}]
},
{
source: 'quantcast.com',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
}
]
```
15 changes: 15 additions & 0 deletions test/spec/modules/eids_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
19 changes: 19 additions & 0 deletions test/spec/modules/quantcastIdSystem_spec.js
Original file line number Diff line number Diff line change
@@ -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});
});
});

0 comments on commit 298139f

Please sign in to comment.