-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add quantcast ID submodule * use setCookie in test * add comment for consent signals
- Loading branch information
Showing
7 changed files
with
103 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); | ||
}); | ||
}); |