forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
DEP-11967 cookie sync prebid.js integration #1
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
Open
IlliaMil
wants to merge
19
commits into
master
Choose a base branch
from
DEP-11967-Cookie-Sync-Prebid.js-integration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
66101f3
Add Start.io User ID submodule with tests and documentation
IlliaMil 6ff92f8
Merge branch 'refs/heads/master' into DEP-11967-Cookie-Sync-Prebid.js…
IlliaMil 7db3472
Update Start.io User ID module to ensure callbacks and AJAX requests …
IlliaMil 8bbf781
Remove storage-related functionality from Start.io ID submodule and a…
IlliaMil 4f2aee9
Add iframe-based user syncing to Start.io Bid Adapter with consent pa…
IlliaMil d6e0c98
Simplify Start.io ID module by removing storage-related parameters an…
IlliaMil e7774d7
Update Start.io modules to use new endpoint URL and improve user sync…
IlliaMil 8e9a6bd
Fix documentation
90386aa
Enhance Start.io ID module with storage management, caching, and impr…
IlliaMil 827bac2
Merge remote-tracking branch 'origin/DEP-11967-Cookie-Sync-Prebid.js-…
IlliaMil 9adb313
Remove window exposure of startioAdapterSpec for browser testing purp…
IlliaMil 4b004ba
Update Start.io Bid Adapter to clarify prebid params for iframe-based…
IlliaMil 41e3fff
Update Start.io Bid Adapter to clarify prebid params for iframe-based…
IlliaMil 127201c
id fixed to uid and updated
IlliaMil b9babdf
docs updated
IlliaMil 9331767
Make `storeId` and `fetchIdFromServer` functions configurable with `e…
IlliaMil 3c22f00
debugger removed
IlliaMil a8fcb95
test
IlliaMil f7248ee
Extend default cookie expiration for `storeId` from 9 to 90 days.
IlliaMil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,106 @@ | ||
| /** | ||
| * This module adds startio ID support to the User ID module | ||
| * The {@link module:modules/userId} module is required | ||
| * @module modules/startioSystem | ||
| * @requires module:modules/userId | ||
| */ | ||
| import { logError } from '../src/utils.js'; | ||
| import { submodule } from '../src/hook.js'; | ||
| import { ajax } from '../src/ajax.js'; | ||
| import { getStorageManager } from '../src/storageManager.js'; | ||
| import { MODULE_TYPE_UID } from '../src/activities/modules.js'; | ||
|
|
||
| const MODULE_NAME = 'startioId'; | ||
| const DEFAULT_ENDPOINT = 'https://cs.startappnetwork.com/get-uid-obj?p=1002'; | ||
|
|
||
| const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); | ||
|
|
||
| function getCachedId() { | ||
| let cachedId; | ||
|
|
||
| if (storage.cookiesAreEnabled()) { | ||
| cachedId = storage.getCookie(MODULE_NAME); | ||
| } | ||
|
|
||
| if (!cachedId && storage.hasLocalStorage()) { | ||
| const expirationStr = storage.getDataFromLocalStorage(`${MODULE_NAME}_exp`); | ||
| if (expirationStr) { | ||
| const expirationDate = new Date(expirationStr); | ||
| if (expirationDate > new Date()) { | ||
| cachedId = storage.getDataFromLocalStorage(MODULE_NAME); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return cachedId || null; | ||
| } | ||
|
|
||
| function storeId(id, expiresInDays) { | ||
| expiresInDays = expiresInDays || 90; | ||
| const expirationDate = new Date(Date.now() + expiresInDays * 24 * 60 * 60 * 1000).toUTCString(); | ||
|
|
||
| if (storage.cookiesAreEnabled()) { | ||
| storage.setCookie(MODULE_NAME, id, expirationDate, 'None'); | ||
| } | ||
|
|
||
| if (storage.hasLocalStorage()) { | ||
| storage.setDataInLocalStorage(`${MODULE_NAME}_exp`, expirationDate); | ||
| storage.setDataInLocalStorage(MODULE_NAME, id); | ||
| } | ||
| } | ||
|
|
||
| function fetchIdFromServer(callback, expiresInDays) { | ||
| const callbacks = { | ||
| success: response => { | ||
| let responseId; | ||
| try { | ||
| const responseObj = JSON.parse(response); | ||
| if (responseObj && responseObj.uid) { | ||
| responseId = responseObj.uid; | ||
| storeId(responseId, expiresInDays); | ||
| } else { | ||
| logError(`${MODULE_NAME}: Server response missing 'uid' field`); | ||
| } | ||
| } catch (error) { | ||
| logError(`${MODULE_NAME}: Error parsing server response`, error); | ||
| } | ||
| callback(responseId); | ||
| }, | ||
| error: error => { | ||
| logError(`${MODULE_NAME}: ID fetch encountered an error`, error); | ||
| callback(); | ||
| } | ||
| }; | ||
| ajax(DEFAULT_ENDPOINT, callbacks, undefined, { method: 'GET' }); | ||
| } | ||
|
|
||
| export const startioIdSubmodule = { | ||
| name: MODULE_NAME, | ||
| decode(value) { | ||
| return value && typeof value === 'string' | ||
| ? { 'startioId': value } | ||
| : undefined; | ||
| }, | ||
| getId(config, consentData, storedId) { | ||
IlliaMil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (storedId) { | ||
| return { id: storedId }; | ||
| } | ||
|
|
||
| const cachedId = getCachedId(); | ||
| if (cachedId) { | ||
| return { id: cachedId }; | ||
| } | ||
| const storageConfig = config && config.storage; | ||
| const expiresInDays = storageConfig && storageConfig.expires; | ||
| return { callback: (cb) => fetchIdFromServer(cb, expiresInDays) }; | ||
| }, | ||
|
|
||
| eids: { | ||
| 'startioId': { | ||
| source: 'start.io', | ||
| atype: 3 | ||
| }, | ||
| } | ||
| }; | ||
|
|
||
| submodule('userId', startioIdSubmodule); | ||
This file contains hidden or 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,35 @@ | ||
| ## Start.io User ID Submodule | ||
|
|
||
| The Start.io User ID submodule generates and persists a unique user identifier by fetching it from a publisher-supplied endpoint. The ID is stored in both cookies and local storage for subsequent page loads and is made available to other Prebid.js modules via the standard `eids` interface. | ||
|
|
||
| For integration support, contact prebid@start.io. | ||
|
|
||
| ### Prebid Params Enabling User Sync | ||
|
|
||
| To enable iframe-based user syncing for Start.io, include the `filterSettings` configuration in your `userSync` setup: | ||
|
|
||
| ```javascript | ||
| pbjs.setConfig({ | ||
| userSync: { | ||
| userIds: [{ | ||
| name: 'startioId' | ||
| }], | ||
| filterSettings: { | ||
| iframe: { | ||
| bidders: ['startio'], | ||
| filter: 'include' | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| This configuration allows Start.io to sync user data via iframe, which is necessary for cross-domain user identification. | ||
|
|
||
| ## Parameter Descriptions for the `userSync` Configuration Section | ||
|
|
||
| The below parameters apply only to the Start.io User ID integration. | ||
|
|
||
| | Param under userSync.userIds[] | Scope | Type | Description | Example | | ||
| | --- | --- | --- | --- | --- | | ||
| | name | Required | String | The name of this module. | `"startioId"` | |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.