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

add quantcast ID submodule #5727

Merged
merged 5 commits into from
Sep 16, 2020
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
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]]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that a recent PR tackled the same issue (#5606), but I was still getting errors if the sizes aren't defined inside the banner object. I can move this to a different PR if that'd be better.

}
},
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});
});
});