-
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.
- Loading branch information
1 parent
28d3316
commit 2e55667
Showing
5 changed files
with
121 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* This module adds naveggId to the User ID module | ||
* The {@link module:modules/userId} module is required | ||
* @module modules/naveggId | ||
* @requires module:modules/userId | ||
*/ | ||
import * as utils from '../src/utils.js' | ||
import { submodule } from '../src/hook.js'; | ||
import { getStorageManager } from '../src/storageManager.js'; | ||
|
||
const MODULE_NAME = 'naveggId'; | ||
export const storage = getStorageManager(); | ||
|
||
function readnaveggIdFromLocalStorage() { | ||
return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage('nvggid') : null; | ||
} | ||
|
||
function readnaveggIDFromCookie() { | ||
return storage.cookiesAreEnabled ? storage.getCookie('nvggid') : null; | ||
} | ||
|
||
function readoldnaveggIDFromCookie() { | ||
return storage.cookiesAreEnabled ? storage.getCookie('nid') : null; | ||
} | ||
|
||
function readnvgIDFromCookie() { | ||
return storage.cookiesAreEnabled ? storage.findSimilarCookies('nvg')[0] : null; | ||
} | ||
|
||
function readnavIDFromCookie() { | ||
return storage.cookiesAreEnabled ? storage.findSimilarCookies('nav')[0] : null; | ||
} | ||
|
||
function readnvgnavFromLocalStorage() { | ||
var i, results = []; | ||
const query = '^nvg|^nav'; | ||
for (i in window.localStorage) { | ||
if (i.match(query) || (!query && typeof i === 'string')) { | ||
return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(i.match(query).input) : null; | ||
} | ||
} | ||
} | ||
|
||
/** @type {Submodule} */ | ||
export const naveggIdSubmodule = { | ||
/** | ||
* used to link submodule with config | ||
* @type {string} | ||
*/ | ||
name: MODULE_NAME, | ||
/** | ||
* decode the stored id value for passing to bid requests | ||
* @function | ||
* @param { Object | string | undefined } value | ||
* @return { Object | string | undefined } | ||
*/ | ||
decode(value) { | ||
const naveggIdVal = value ? utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined : undefined; | ||
return naveggIdVal ? { | ||
'naveggId': naveggIdVal | ||
} : undefined; | ||
}, | ||
/** | ||
* performs action to obtain id and return a value in the callback's response argument | ||
* @function | ||
* @param {SubmoduleConfig} config | ||
* @return {{id: string | undefined } | undefined} | ||
*/ | ||
getId() { | ||
const naveggIdString = readnaveggIdFromLocalStorage() || readnaveggIDFromCookie() || readoldnaveggIDFromCookie() || readnvgIDFromCookie() || readnavIDFromCookie() || readnvgnavFromLocalStorage(); | ||
|
||
if (typeof naveggIdString == 'string' && naveggIdString) { | ||
try { | ||
return { id: naveggIdString }; | ||
// return { id: naveggIdString ? { naveggId: naveggIdString } : undefined } | ||
} catch (error) { | ||
utils.logError(error); | ||
} | ||
} | ||
return undefined; | ||
} | ||
}; | ||
submodule('userId', naveggIdSubmodule); |
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,22 @@ | ||
## Navegg User ID Submodule | ||
|
||
For assistance setting up your module please contact us at [[email protected]]([email protected]). | ||
|
||
### Prebid Params | ||
|
||
Individual params may be set for the IDx Submodule. | ||
``` | ||
pbjs.setConfig({ | ||
userSync: { | ||
userIds: [{ | ||
name: 'naveggId', | ||
}] | ||
} | ||
}); | ||
``` | ||
## Parameter Descriptions for the `userSync` Configuration Section | ||
The below parameters apply only to the naveggID integration. | ||
|
||
| Param under usersync.userIds[] | Scope | Type | Description | Example | | ||
| --- | --- | --- | --- | --- | | ||
| name | Required | String | ID of the module - `"naveggId"` | `"naveggId"` | |
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