-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
LiveIntent UserId module: update LiveConnect dependency #9672
Changes from 4 commits
37c066b
b54a0b7
cd46721
e7e9cd7
4497730
dcba68b
4f5f3de
2ee57ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import { LiveConnect } from 'live-connect-js'; // eslint-disable-line prebid/val | |
import { gdprDataHandler, uspDataHandler } from '../src/adapterManager.js'; | ||
import { getStorageManager } from '../src/storageManager.js'; | ||
|
||
const EVENTS_TOPIC = 'pre_lips' | ||
const MODULE_NAME = 'liveIntentId'; | ||
export const storage = getStorageManager({gvlid: null, moduleName: MODULE_NAME}); | ||
const defaultRequestedAttributes = {'nonId': true} | ||
|
@@ -39,8 +40,9 @@ let liveConnect = null; | |
* This function is used in tests | ||
*/ | ||
export function reset() { | ||
if (window && window.liQ) { | ||
window.liQ = []; | ||
if (window && window.liQ_instances) { | ||
window.liQ_instances.forEach(i => i.eventBus.off(EVENTS_TOPIC, setEventFiredFlag)) | ||
window.liQ_instances = []; | ||
} | ||
liveIntentIdSubmodule.setModuleMode(null) | ||
eventFired = false; | ||
|
@@ -100,6 +102,7 @@ function initializeLiveConnect(configParams) { | |
liveConnectConfig.wrapperName = 'prebid'; | ||
liveConnectConfig.identityResolutionConfig = identityResolutionConfig; | ||
liveConnectConfig.identifiersToResolve = configParams.identifiersToResolve || []; | ||
liveConnectConfig.fireEventDelay = configParams.fireEventDelay; | ||
const usPrivacyString = uspDataHandler.getConsentData(); | ||
if (usPrivacyString) { | ||
liveConnectConfig.usPrivacyString = usPrivacyString; | ||
|
@@ -119,10 +122,20 @@ function initializeLiveConnect(configParams) { | |
return liveConnect; | ||
} | ||
|
||
const setEventFiredFlag = function(_) { | ||
eventFired = true | ||
} | ||
|
||
function tryFireEvent() { | ||
if (!eventFired && liveConnect) { | ||
liveConnect.fire(); | ||
eventFired = true; | ||
const eventDelay = liveConnect.config.fireEventDelay || 500 | ||
setTimeout(() => { | ||
const instances = window.liQ_instances | ||
instances.forEach(i => i.eventBus.once(EVENTS_TOPIC, setEventFiredFlag)) | ||
if (!eventFired && liveConnect) { | ||
liveConnect.fire(); | ||
} | ||
}, eventDelay) | ||
Comment on lines
+134
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This prevents duplicate events in cases where apart from LiveIntent's Prebid user id module another LiveConnect wrapper is installed on the same page. Mid term, the goal is to remove this guard and handle all events on the backend. |
||
} | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only used for testing.