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 1 commit
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
8 changes: 6 additions & 2 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 @@ -230,6 +231,9 @@
name: "_li_pbid",
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 @@ -12,7 +12,8 @@
"netIdSystem",
"identityLinkIdSystem",
"sharedIdSystem",
"intentIqIdSystem"
"intentIqIdSystem",
"quantcastIdSystem"
],
"adpod": [
"freeWheelAdserverVideo",
Expand Down
43 changes: 43 additions & 0 deletions modules/quantcastIdSystem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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() {
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 @@ -123,6 +123,12 @@ const USER_IDS_CONFIG = {
third: data.third
} : undefined;
}
},

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

Expand Down
10 changes: 9 additions & 1 deletion modules/userId/eids.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ userIdAsEids = [
third: 'some-random-id-value'
}
}]
}
},

{
source: 'quantcast.com',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
},
]
```
11 changes: 11 additions & 0 deletions test/spec/modules/eids_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ 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() {
window.document.cookie = '__qca= ; expires = Thu, 01 Jan 1970 00:00:00 GMT;';
smenzer marked this conversation as resolved.
Show resolved Hide resolved
});

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