Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
peixunzhang committed Aug 19, 2024
1 parent 4337a8b commit 7c17b1e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
4 changes: 2 additions & 2 deletions libraries/liveIntentIdSystem/liveIntentIdHubSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function initializeClient(configParams) {
let integration
if (collectConfig.appId != null) {
integration = { type: 'application', appId: collectConfig.appId, publisherId: configParams.publisherId }
} else if (configParams.distributorId != null) {
} else if (configParams.distributorId != null && configParams.publisherId == null) {
integration = { type: 'distributor', distributorId: configParams.distributorId }
} else {
integration = { type: 'custom', publisherId: configParams.publisherId, distributorId: configParams.distributorId }
Expand All @@ -39,7 +39,7 @@ function initializeClient(configParams) {
const collectSettings = { timeout: collectConfig.ajaxTimeout ?? DEFAULT_AJAX_TIMEOUT }

let identityPartner
if (configParams.appId == null && configParams.distributorId != null) {
if (collectConfig.appId == null && configParams.distributorId != null) {
identityPartner = configParams.distributorId
} else if (configParams.partner != null) {
identityPartner = configParams.partner
Expand Down
7 changes: 3 additions & 4 deletions libraries/liveIntentIdSystem/liveIntentIdSystemShared.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ export const GVLID = 148;
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_REQUESTED_ATTRIBUTES = { 'nonId': true }
export const DEFAULT_DELAY = 500
const defaultRequestedAttributes = {'nonId': true}

export function parseRequestedAttributes(overrides) {
function renameAttribute(attribute) {
Expand All @@ -23,9 +22,9 @@ export function parseRequestedAttributes(overrides) {
return Object.entries(config).flatMap(([k, v]) => (typeof v === 'boolean' && v) ? [renameAttribute(k)] : []);
}
if (typeof overrides === 'object') {
return createParameterArray({...defaultRequestedAttributes, ...overrides});
return createParameterArray({...DEFAULT_REQUESTED_ATTRIBUTES, ...overrides});
} else {
return createParameterArray(defaultRequestedAttributes);
return createParameterArray(DEFAULT_REQUESTED_ATTRIBUTES);
}
}

Expand Down
40 changes: 37 additions & 3 deletions test/spec/modules/liveIntentIdHubSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,35 @@ describe('LiveIntentIdHub', function() {
resetSubmodule();
});

it('should use appId in integration when both appId and distributorId are provided', function() {
const configParams = {
params: {
...defaultConfigParams.params,
distributorId: 'did-1111',
liCollectConfig: {
appId: 'a-0001'
},
emailHash: '123'
}
}
liveIntentIdHubSubmodule.decode({}, configParams);
expect(window.liQHub).to.eql([{
clientDetails: { name: 'prebid', version: '$prebid.version$' },
clientRef: {},
collectSettings: { timeout: DEFAULT_AJAX_TIMEOUT },
consent: {},
integration: { appId: 'a-0001', publisherId: '89899', type: 'application' },
partnerCookies: new Set(),
resolveSettings: { identityPartner: 'prebid', timeout: DEFAULT_AJAX_TIMEOUT },
type: 'register_client'
},
{
clientRef: {},
sourceEvent: { hash: '123' },
type: 'collect'
}])
});

it('should fire an event and resolve when getId and include the privacy settings into the resolution request', function () {
uspConsentDataStub.returns('1YNY');
gdprConsentDataStub.returns({
Expand Down Expand Up @@ -115,13 +144,18 @@ describe('LiveIntentIdHub', function() {
});

it('should have the same data after call decode when appId, disrtributorId and sourceEvent is absent', function() {
liveIntentIdHubSubmodule.decode({}, defaultConfigParams);
liveIntentIdHubSubmodule.decode({}, {
params: {
...defaultConfigParams.params,
distributorId: undefined
}
});
expect(window.liQHub).to.eql([{
clientDetails: { name: 'prebid', version: '$prebid.version$' },
clientRef: {},
collectSettings: { timeout: DEFAULT_AJAX_TIMEOUT },
consent: {},
integration: { distributorId: defaultConfigParams.distributorId, publisherId: '89899', type: 'custom' },
integration: { distributorId: undefined, publisherId: '89899', type: 'custom' },
partnerCookies: new Set(),
resolveSettings: { identityPartner: 'prebid', timeout: DEFAULT_AJAX_TIMEOUT },
type: 'register_client'
Expand Down Expand Up @@ -175,7 +209,7 @@ describe('LiveIntentIdHub', function() {
clientRef: {},
collectSettings: { timeout: DEFAULT_AJAX_TIMEOUT },
consent: {},
integration: { distributorId: 'did-1111', type: 'distributor' },
integration: { distributorId: 'did-1111', publisherId: defaultConfigParams.params.publisherId, type: 'custom' },
partnerCookies: new Set(),
resolveSettings: { identityPartner: 'did-1111', timeout: DEFAULT_AJAX_TIMEOUT },
type: 'register_client'
Expand Down

0 comments on commit 7c17b1e

Please sign in to comment.