Skip to content

Commit

Permalink
only keep collect and rename
Browse files Browse the repository at this point in the history
  • Loading branch information
peixunzhang committed Aug 21, 2024
1 parent 7c17b1e commit 301b88e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 49 deletions.
6 changes: 2 additions & 4 deletions libraries/liveIntentIdSystem/liveIntentIdHubSystem.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { logError } from '../../src/utils.js';
import { gdprDataHandler, uspDataHandler, gppDataHandler } from '../../src/adapterManager.js';
import { submodule } from '../../src/hook.js';
import { DEFAULT_AJAX_TIMEOUT, MODULE_NAME, parseRequestedAttributes, composeIdObject, eids, DEFAULT_DELAY, GVLID } from './liveIntentIdSystemShared.js'
import { DEFAULT_AJAX_TIMEOUT, MODULE_NAME, parseRequestedAttributes, composeIdObject, eids, GVLID } from './liveIntentIdSystemShared.js'

// reference to the client for the liQHub
let cachedClientRef
Expand Down Expand Up @@ -97,11 +97,9 @@ function initializeClient(configParams) {
resolveSettings
})

// fire default collect request
// only collect call if there is email hash
if (configParams.emailHash != null) {
window.liQHub.push({ type: 'collect', clientRef, sourceEvent: { hash: configParams.emailHash } })
} else {
window.liQHub.push({ type: 'schedule_default_collect', clientRef, delay: configParams.fireEventDelay ?? DEFAULT_DELAY })
}

cachedClientRef = clientRef
Expand Down
1 change: 0 additions & 1 deletion libraries/liveIntentIdSystem/liveIntentIdSystemShared.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const DEFAULT_AJAX_TIMEOUT = 5000
export const MODULE_NAME = 'liveIntentId';
export const LI_PROVIDER_DOMAIN = 'liveintent.com';
export const DEFAULT_REQUESTED_ATTRIBUTES = { 'nonId': true }
export const DEFAULT_DELAY = 500

export function parseRequestedAttributes(overrides) {
function renameAttribute(attribute) {
Expand Down
2 changes: 1 addition & 1 deletion modules/liveIntentIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function loadModule() {
// Load appropriate module based on the build flag. Constant folding ensures
// that the other one will not be included in the bundle.
// eslint-disable-next-line no-constant-condition
if ('$$LIVE_INTENT_MODULE_MODE$$' === 'hub') {
if ('$$LIVE_INTENT_MODULE_MODE$$' === 'external') {
// eslint-disable-next-line no-restricted-globals
return require('../libraries/liveIntentIdSystem/liveIntentIdHubSystem.js')
} else {
Expand Down
52 changes: 9 additions & 43 deletions test/spec/modules/liveIntentIdHubSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('LiveIntentIdHub', function() {

const expectedConsent = { gdpr: { consentString: 'consentDataString', gdprApplies: true }, gpp: { applicableSections: [1, 2], consentString: 'gppConsentDataString' }, usPrivacy: { consentString: '1YNY' } }

expect(window.liQHub).to.have.length(3)
expect(window.liQHub).to.have.length(2)

expect(window.liQHub[0]).to.eql({
clientDetails: { name: 'prebid', version: '$prebid.version$' },
Expand All @@ -86,13 +86,7 @@ describe('LiveIntentIdHub', function() {
type: 'register_client'
})

expect(window.liQHub[1]).to.eql({
clientRef: {},
delay: defaultConfigParams.params.fireEventDelay,
type: 'schedule_default_collect'
})

const resolveCommand = window.liQHub[2]
const resolveCommand = window.liQHub[1]
// functions cannot be reasonably compared, remove them
delete resolveCommand.onSuccess[0].callback
delete resolveCommand.onFailure
Expand Down Expand Up @@ -159,11 +153,6 @@ describe('LiveIntentIdHub', function() {
partnerCookies: new Set(),
resolveSettings: { identityPartner: 'prebid', timeout: DEFAULT_AJAX_TIMEOUT },
type: 'register_client'
},
{
clientRef: {},
delay: defaultConfigParams.params.fireEventDelay,
type: 'schedule_default_collect'
}])
});

Expand Down Expand Up @@ -241,19 +230,14 @@ describe('LiveIntentIdHub', function() {
partnerCookies: new Set(),
resolveSettings: { identityPartner: 'prebid', timeout: DEFAULT_AJAX_TIMEOUT },
type: 'register_client'
},
{
clientRef: {},
delay: defaultConfigParams.params.fireEventDelay,
type: 'schedule_default_collect'
}])
});

it('should not fire event again when it is already fired', function() {
liveIntentIdHubSubmodule.decode({}, defaultConfigParams);
liveIntentIdHubSubmodule.decode({}, defaultConfigParams);

expect(window.liQHub).to.have.length(2) // instead of 4
expect(window.liQHub).to.have.length(1) // instead of 2
});

it('should not return a decoded identifier when the unifiedId is not present in the value', function() {
Expand All @@ -277,7 +261,7 @@ describe('LiveIntentIdHub', function() {
...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } }
} }).callback(() => {});

expect(window.liQHub).to.have.length(3)
expect(window.liQHub).to.have.length(2)
expect(window.liQHub[0]).to.eql({
clientDetails: { name: 'prebid', version: '$prebid.version$' },
clientRef: {},
Expand All @@ -289,13 +273,7 @@ describe('LiveIntentIdHub', function() {
type: 'register_client'
})

expect(window.liQHub[1]).to.eql({
clientRef: {},
delay: defaultConfigParams.params.fireEventDelay,
type: 'schedule_default_collect'
})

const resolveCommand = window.liQHub[2]
const resolveCommand = window.liQHub[1]

// functions cannot be reasonably compared, remove them
delete resolveCommand.onSuccess[0].callback
Expand Down Expand Up @@ -367,7 +345,7 @@ describe('LiveIntentIdHub', function() {
...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } }
} }).callback(() => {});

expect(window.liQHub).to.have.length(3)
expect(window.liQHub).to.have.length(2)
expect(window.liQHub[0]).to.eql({
clientDetails: { name: 'prebid', version: '$prebid.version$' },
clientRef: {},
Expand All @@ -379,13 +357,7 @@ describe('LiveIntentIdHub', function() {
type: 'register_client'
})

expect(window.liQHub[1]).to.eql({
clientRef: {},
delay: defaultConfigParams.params.fireEventDelay,
type: 'schedule_default_collect'
})

const resolveCommand = window.liQHub[2]
const resolveCommand = window.liQHub[1]
// functions cannot be reasonably compared, remove them
delete resolveCommand.onSuccess[0].callback
delete resolveCommand.onFailure
Expand Down Expand Up @@ -418,7 +390,7 @@ describe('LiveIntentIdHub', function() {
requestedAttributesOverrides: { 'fpid': true } }
}).callback(() => {});

expect(window.liQHub).to.have.length(3)
expect(window.liQHub).to.have.length(2)
expect(window.liQHub[0]).to.eql({
clientDetails: { name: 'prebid', version: '$prebid.version$' },
clientRef: {},
Expand All @@ -431,13 +403,7 @@ describe('LiveIntentIdHub', function() {
type: 'register_client'
})

expect(window.liQHub[1]).to.eql({
clientRef: {},
delay: defaultConfigParams.params.fireEventDelay,
type: 'schedule_default_collect'
})

const resolveCommand = window.liQHub[2]
const resolveCommand = window.liQHub[1]

// functions cannot be reasonably compared, remove them
delete resolveCommand.onSuccess[0].callback
Expand Down

0 comments on commit 301b88e

Please sign in to comment.