Skip to content

Commit

Permalink
Lotame Panorama ID Module : add safari handling (prebid#9418)
Browse files Browse the repository at this point in the history
* GRUE-176 work in progress, trying to make the id URL dynamic.

* GRUE-176 After some attempts with leveraging environment variables, decided to look for an environment variable passed on configuration.

* GRUE-177 WIP added a fix for handling timestamps, plus there's some temporary debugging that I was using to understand flow.

* GRUE-177 Fixed bug with localStorage checking for empty, included null as a possible return value.

* GRUE-177 updated the environment handling for dev, qa, and prod. I'm still on the fence on whether we need this, but it's allowing the tests to pass currently, so leaving it in for now.

* GRUE-178 removed the dynamic URL handling for the ID endpoint. We will manage that change with the build process for testing.

* GRUE-339 changes to check for browser, and accomodate Safari with a different URL.

* GRUE-339 changes to check for browser, and accomodate Safari with a different URL.

* GRUE-339 Removed the obfuscation from the Safari URL, as it was deemed unnecessary.

* GRUE-339 corrected the safari id endpoint - I had forgotten that it was different than the usual one.

* GRUE-339 Updated test to cover Safari handling.

* GRUE-340 Updated the variable name for the cookieless domain, to remove the emphasis on Safari and better illustrate that this is a general approach.

Co-authored-by: Mark Conrad <mconrad@lotame.com>
Co-authored-by: Mark <markaconrad@users.noreply.github.com>
  • Loading branch information
3 people authored and JacobKlein26 committed Feb 8, 2023
1 parent b2bb99e commit 8bc7eb5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
10 changes: 9 additions & 1 deletion modules/lotamePanoramaIdSystem.js
Expand Up @@ -29,6 +29,7 @@ const DAY_MS = 60 * 60 * 24 * 1000;
const MISSING_CORE_CONSENT = 111;
const GVLID = 95;
const ID_HOST = 'id.crwdcntrl.net';
const ID_HOST_COOKIELESS = 'c.ltmsphrcl.net';

export const storage = getStorageManager({gvlid: GVLID, moduleName: MODULE_NAME});
let cookieDomain;
Expand Down Expand Up @@ -252,6 +253,13 @@ export const lotamePanoramaIdSubmodule = {
usPrivacy = getFromStorage('us_privacy');
}

const getRequestHost = function() {
if (navigator.userAgent && navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
return ID_HOST_COOKIELESS;
}
return ID_HOST;
}

const resolveIdFunction = function (callback) {
let queryParams = {};
if (storedUserId) {
Expand Down Expand Up @@ -288,7 +296,7 @@ export const lotamePanoramaIdSubmodule = {

const url = buildUrl({
protocol: 'https',
host: ID_HOST,
host: getRequestHost(),
pathname: '/id',
search: isEmpty(queryParams) ? undefined : queryParams,
});
Expand Down
26 changes: 16 additions & 10 deletions test/spec/modules/lotamePanoramaIdSystem_spec.js
Expand Up @@ -18,6 +18,7 @@ describe('LotameId', function() {
let removeFromLocalStorageStub;
let timeStampStub;
let uspConsentDataStub;
let requestHost;

const nowTimestamp = new Date().getTime();

Expand All @@ -33,6 +34,11 @@ describe('LotameId', function() {
);
timeStampStub = sinon.stub(utils, 'timestamp').returns(nowTimestamp);
uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData');
if (navigator.userAgent && navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
requestHost = 'https://c.ltmsphrcl.net/id';
} else {
requestHost = 'https://id.crwdcntrl.net/id';
}
});

afterEach(function () {
Expand Down Expand Up @@ -69,7 +75,7 @@ describe('LotameId', function() {
});

it('should call the remote server when getId is called', function () {
expect(request.url).to.be.eq('https://id.crwdcntrl.net/id');
expect(request.url).to.be.eq(`${requestHost}`);
expect(callBackSpy.calledOnce).to.be.true;
});

Expand Down Expand Up @@ -439,7 +445,7 @@ describe('LotameId', function() {

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_applies=true&gdpr_consent=consentGiven'
`${requestHost}?gdpr_applies=true&gdpr_consent=consentGiven`
);
});
});
Expand Down Expand Up @@ -471,7 +477,7 @@ describe('LotameId', function() {

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_applies=true&gdpr_consent=consentGiven'
`${requestHost}?gdpr_applies=true&gdpr_consent=consentGiven`
);
});
});
Expand Down Expand Up @@ -503,7 +509,7 @@ describe('LotameId', function() {

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_applies=true&gdpr_consent=consentGiven'
`${requestHost}?gdpr_applies=true&gdpr_consent=consentGiven`
);
});
});
Expand Down Expand Up @@ -531,7 +537,7 @@ describe('LotameId', function() {

it('should not include the gdpr consent string on the url', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_applies=true'
`${requestHost}?gdpr_applies=true`
);
});
});
Expand Down Expand Up @@ -560,7 +566,7 @@ describe('LotameId', function() {

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_consent=consentGiven'
`${requestHost}?gdpr_consent=consentGiven`
);
});
});
Expand Down Expand Up @@ -589,7 +595,7 @@ describe('LotameId', function() {

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_consent=consentGiven'
`${requestHost}?gdpr_consent=consentGiven`
);
});
});
Expand All @@ -613,7 +619,7 @@ describe('LotameId', function() {
});

it('should pass the gdpr consent string back', function() {
expect(request.url).to.be.eq('https://id.crwdcntrl.net/id');
expect(request.url).to.be.eq(`${requestHost}`);
});
});

Expand Down Expand Up @@ -835,7 +841,7 @@ describe('LotameId', function() {

it('should pass the usp consent string and client id back', function () {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_applies=false&us_privacy=1NNN&c=1234'
`${requestHost}?gdpr_applies=false&us_privacy=1NNN&c=1234`
);
});

Expand Down Expand Up @@ -923,7 +929,7 @@ describe('LotameId', function() {

it('should pass client id back', function () {
expect(request.url).to.be.eq(
'https://id.crwdcntrl.net/id?gdpr_applies=false&c=1234'
`${requestHost}?gdpr_applies=false&c=1234`
);
});

Expand Down

0 comments on commit 8bc7eb5

Please sign in to comment.