Skip to content
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

PAIR: Support for Generic TechLab Version #12146

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions modules/pairIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import {MODULE_TYPE_UID} from '../src/activities/modules.js';

const MODULE_NAME = 'pairId';
const PAIR_ID_KEY = 'pairId';
const DEFAULT_LIVERAMP_PAIR_ID_KEY = '_lr_pairId';

const DEFAULT_STORAGE_PAID_ID_KEYS = {
liveramp: '_lr_pairId'
};

export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME});

Expand All @@ -35,11 +38,6 @@ export const pairIdSubmodule = {
* @type {string}
*/
name: MODULE_NAME,
/**
* used to specify vendor id
* @type {number}
*/
gvlid: 755,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this configurable. Should be the DSP

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not included in the bid request at all. this is the owner of the module. we need prebid to confirm.
the prefered thing to do is to leave as-is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use VENDORLESS_GVLID here

/**
* decode the stored id value for passing to bid requests
* @function
Expand All @@ -59,6 +57,7 @@ export const pairIdSubmodule = {
getId(config) {
const pairIdsString = pairIdFromLocalStorage(PAIR_ID_KEY) || pairIdFromCookie(PAIR_ID_KEY)
let ids = []

if (pairIdsString && typeof pairIdsString == 'string') {
try {
ids = ids.concat(JSON.parse(atob(pairIdsString)))
Expand All @@ -67,14 +66,20 @@ export const pairIdSubmodule = {
}
}

const configParams = (config && config.params) || {};
if (configParams && configParams.liveramp) {
let LRStorageLocation = configParams.liveramp.storageKey || DEFAULT_LIVERAMP_PAIR_ID_KEY;
const liverampValue = pairIdFromLocalStorage(LRStorageLocation) || pairIdFromCookie(LRStorageLocation);
const configParams = (config && config.params) ? config.params : {};
const cleanRooms = Object.keys(configParams);

if (liverampValue) {
for (let i = 0; i < cleanRooms.length; i++) {
const cleanRoom = cleanRooms[i];
const cleanRoomParams = configParams[cleanRoom];

const cleanRoomStorageLocation = cleanRoomParams.storageKey || DEFAULT_STORAGE_PAID_ID_KEYS[cleanRoom];
const cleanRoomValue = pairIdFromLocalStorage(cleanRoomStorageLocation) || pairIdFromCookie(cleanRoomStorageLocation);
Comment on lines +72 to +77
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (let i = 0; i < cleanRooms.length; i++) {
const cleanRoom = cleanRooms[i];
const cleanRoomParams = configParams[cleanRoom];
const cleanRoomStorageLocation = cleanRoomParams.storageKey || DEFAULT_STORAGE_PAID_ID_KEYS[cleanRoom];
const cleanRoomValue = pairIdFromLocalStorage(cleanRoomStorageLocation) || pairIdFromCookie(cleanRoomStorageLocation);
Object.entries(configParams).forEach( ([cleanRoom, cleanRoomParams]) => {
const cleanRoomStorageLocation = cleanRoomParams.storageKey || DEFAULT_STORAGE_PAID_ID_KEYS[cleanRoom];
const cleanRoomValue = pairIdFromLocalStorage(cleanRoomStorageLocation) || pairIdFromCookie(cleanRoomStorageLocation);

JS made this a little more convienent 😄
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries

Suggestion won't fully work as there's probably a closing brace missing


if (cleanRoomValue) {
try {
const parsedValue = atob(liverampValue);
const parsedValue = atob(cleanRoomValue);

if (parsedValue) {
const obj = JSON.parse(parsedValue);

Expand All @@ -90,20 +95,21 @@ export const pairIdSubmodule = {
logInfo('Pairid: Error parsing JSON: ', error);
}
} else {
logInfo('Pairid: liverampValue for pairId from storage is empty or null');
logInfo('Pairid: data clean room value for pairId from storage is empty or null');
}
}

if (ids.length == 0) {
logInfo('PairId not found.')
return undefined;
}

return {'id': ids};
},
eids: {
'pairId': {
source: 'google.com',
atype: 571187
source: 'iabtechlab.com',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future IAB may support another Alt ID, so the source for PAIR should clearly mention what it is.
Can we mention it as "pair-iab-tl.com"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that what atype is for? like a single source can have multiple id types?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@pm-harshad-mane pm-harshad-mane Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

atype identifies the user agent types a user identifier is from.
IABTechLab may have another ID with same atype in future hence we should have clear identification in source that tells its a PAIR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@therevoltingx mentioned we will have a unique atype to identify eid as a PAIR

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this? I assumed it was the ID type which is now a techlab id type

atype: 3
},
}
};
Expand Down
33 changes: 33 additions & 0 deletions test/spec/modules/pairIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,39 @@ describe('pairId', function () {
sandbox.restore();
});

it('should read pairId from specified clean room if configured with storageKey', function() {
let pairIds = ['test-pair-id1', 'test-pair-id2', 'test-pair-id3'];
sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('habu_pairId_custom').returns(btoa(JSON.stringify({'envelope': pairIds})));

let id = pairIdSubmodule.getId({
params: {
habu: {
storageKey: 'habu_pairId_custom'
}
}})

expect(id).to.be.deep.equal({id: pairIds});
})

it('should read pairID from liveramp with default storageKey and additional clean room with configured storageKey', function() {
let getDataStub = sandbox.stub(storage, 'getDataFromLocalStorage');
let liveRampPairIds = ['lr-test-pair-id1', 'lr-test-pair-id2', 'lr-test-pair-id3'];
getDataStub.withArgs('_lr_pairId').returns(btoa(JSON.stringify({'envelope': liveRampPairIds})));

let habuPairIds = ['habu-test-pair-id1', 'habu-test-pair-id2', 'habu-test-pair-id3'];
getDataStub.withArgs('habu_pairId_custom').returns(btoa(JSON.stringify({'envelope': habuPairIds})));

let id = pairIdSubmodule.getId({
params: {
habu: {
storageKey: 'habu_pairId_custom'
},
liveramp: {}
}})

expect(id).to.be.deep.equal({id: habuPairIds.concat(liveRampPairIds)});
});

it('should log an error if no ID is found when getId', function() {
pairIdSubmodule.getId({ params: {} });
expect(logInfoStub.calledOnce).to.be.true;
Expand Down