forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cee Id System : initial ID module release (prebid#11510)
* Update tests for sspBC adapter Update tests for sspBC adapter: - change userSync test (due to tcf param appended in v4.6) - add tests for onBidWon and onTimeout * [sspbc-adapter] 5.3 updates: content-type for notifications * [sspbc-adapter] pass CTA to native bid * [sspbc-5.3] keep pbsize for detected adunits * [maintenance] - remove old test for sspBc bid adaptor * [sspbc-5.3] increment adaptor ver * [sspbc-adapter] maintenance update to sspBCBidAdapter * remove yarn.lock * Delete package-lock.json * remove package-lock.jsonfrom pull request * [sspbc-adapter] send pageViewId in request * [sspbc-adapter] update pageViewId test * [sspbc-adapter] add viewabiility tracker to native ads * [sspbc-adapter] add support for bid.admNative property * [sspbc-adapter] ensure that placement id length is always 3 (improves matching response to request) * [sspbc-adapter] read publisher id and custom ad label, then send them to banner creative * [sspbc-adapter] adlabel and pubid are set as empty strings, if not present in bid response * [sspbc-adapter] jstracker data fix * [sspbc-adapter] jstracker data fix * [sspbc-adapter] send tagid in notifications * [sspbc-adapter] add gvlid to spec; prepare getUserSyncs for iframe + image sync * update remote repo * cleanup of grupawp/prebid master branch * update sspBC adapter to v 5.9 * update tests for sspBC bid adapter * [sspbc-adapter] add support for topicsFPD module * [sspbc-adapter] change topic segment ids to int * add pirIdSystem * pirIdSystem * piridSystem - preCR * fix after CR * name change --------- Co-authored-by: wojciech-bialy-wpm <67895844+wojciech-bialy-wpm@users.noreply.github.com> Co-authored-by: Wojciech Biały <wb@WojciechBialy.local> Co-authored-by: Wojciech Biały <wojciech.bialy@grupawp.pl>
- Loading branch information
1 parent
de0e260
commit af91057
Showing
3 changed files
with
166 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* This module adds ceeId to the User ID module | ||
* The {@link module:modules/userId} module is required | ||
* @module modules/ceeId | ||
* @requires module:modules/userId | ||
*/ | ||
|
||
import { MODULE_TYPE_UID } from '../src/activities/modules.js'; | ||
import { getStorageManager } from '../src/storageManager.js'; | ||
import { submodule } from '../src/hook.js'; | ||
import {domainOverrideToRootDomain} from '../libraries/domainOverrideToRootDomain/index.js'; | ||
|
||
/** | ||
* @typedef {import('../modules/userId/index.js').Submodule} Submodule | ||
* @typedef {import('../modules/userId/index.js').IdResponse} IdResponse | ||
*/ | ||
|
||
const MODULE_NAME = 'ceeId'; | ||
const ID_TOKEN = 'WPxid'; | ||
export const storage = getStorageManager({ moduleName: MODULE_NAME, moduleType: MODULE_TYPE_UID }); | ||
|
||
/** | ||
* Reads the ID token from local storage or cookies. | ||
* @returns {string|undefined} The ID token, or undefined if not found. | ||
*/ | ||
export const readId = () => storage.getDataFromLocalStorage(ID_TOKEN) || storage.getCookie(ID_TOKEN); | ||
|
||
/** @type {Submodule} */ | ||
export const ceeIdSubmodule = { | ||
name: MODULE_NAME, | ||
gvlid: 676, | ||
|
||
/** | ||
* decode the stored id value for passing to bid requests | ||
* @function decode | ||
* @param {string} value | ||
* @returns {(Object|undefined)} | ||
*/ | ||
decode(value) { | ||
return typeof value === 'string' ? { 'ceeId': value } : undefined; | ||
}, | ||
|
||
/** | ||
* performs action to obtain id and return a value | ||
* @function | ||
* @returns {(IdResponse|undefined)} | ||
*/ | ||
getId() { | ||
const ceeIdToken = readId(); | ||
|
||
return ceeIdToken ? { id: ceeIdToken } : undefined; | ||
}, | ||
domainOverride: domainOverrideToRootDomain(storage, MODULE_NAME), | ||
eids: { | ||
'ceeId': { | ||
source: 'ceeid.eu', | ||
atype: 1 | ||
}, | ||
}, | ||
}; | ||
|
||
submodule('userId', ceeIdSubmodule); |
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,27 @@ | ||
# Overview | ||
|
||
Module Name: ceeIdSystem | ||
Module Type: UserID Module | ||
Maintainer: pawel.grudzien@grupawp.pl | ||
|
||
# Description | ||
|
||
User identification system for WPM | ||
|
||
### Prebid Params example | ||
|
||
``` | ||
pbjs.setConfig({ | ||
userSync: { | ||
userIds: [{ | ||
name: 'ceeId', | ||
storage: { | ||
type: 'cookie', | ||
name: 'ceeIdToken', | ||
expires: 7, | ||
refreshInSeconds: 360 | ||
} | ||
}] | ||
} | ||
}); | ||
``` |
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,77 @@ | ||
import { ceeIdSubmodule, storage, readId } from 'modules/ceeIdSystem.js'; | ||
import sinon from 'sinon'; | ||
|
||
describe('ceeIdSystem', () => { | ||
let sandbox; | ||
let getCookieStub; | ||
let getDataFromLocalStorageStub; | ||
|
||
beforeEach(() => { | ||
sandbox = sinon.createSandbox(); | ||
getCookieStub = sandbox.stub(storage, 'getCookie'); | ||
getDataFromLocalStorageStub = sandbox.stub(storage, 'getDataFromLocalStorage'); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
describe('getId', () => { | ||
it('should return an object with id when ceeIdToken is found', () => { | ||
getDataFromLocalStorageStub.returns('testToken'); | ||
getCookieStub.returns('testToken'); | ||
|
||
const result = ceeIdSubmodule.getId(); | ||
|
||
expect(result).to.deep.equal({ id: 'testToken' }); | ||
}); | ||
|
||
it('should return undefined when ceeIdToken is not found', () => { | ||
const result = ceeIdSubmodule.getId(); | ||
|
||
expect(result).to.be.undefined; | ||
}); | ||
}); | ||
|
||
describe('decode', () => { | ||
it('should return an object with ceeId when value is a string', () => { | ||
const result = ceeIdSubmodule.decode('testId'); | ||
|
||
expect(result).to.deep.equal({ ceeId: 'testId' }); | ||
}); | ||
|
||
it('should return undefined when value is not a string', () => { | ||
const result = ceeIdSubmodule.decode({}); | ||
|
||
expect(result).to.be.undefined; | ||
}); | ||
}); | ||
|
||
describe('readId', () => { | ||
it('should return data from local storage when it exists', () => { | ||
getDataFromLocalStorageStub.returns('local_storage_data'); | ||
|
||
const result = readId(); | ||
|
||
expect(result).to.equal('local_storage_data'); | ||
}); | ||
|
||
it('should return data from cookie when local storage data does not exist', () => { | ||
getDataFromLocalStorageStub.returns(null); | ||
getCookieStub.returns('cookie_data'); | ||
|
||
const result = readId(); | ||
|
||
expect(result).to.equal('cookie_data'); | ||
}); | ||
|
||
it('should return null when neither local storage data nor cookie data exists', () => { | ||
getDataFromLocalStorageStub.returns(null); | ||
getCookieStub.returns(null); | ||
|
||
const result = readId(); | ||
|
||
expect(result).to.be.null; | ||
}); | ||
}); | ||
}); |