diff --git a/modules/insticatorBidAdapter.js b/modules/insticatorBidAdapter.js index 8688a85be10..f953af7365d 100644 --- a/modules/insticatorBidAdapter.js +++ b/modules/insticatorBidAdapter.js @@ -7,7 +7,7 @@ import {find} from '../src/polyfill.js'; const BIDDER_CODE = 'insticator'; const ENDPOINT = 'https://ex.ingage.tech/v1/openrtb'; // production endpoint -const USER_ID_KEY = 'hb_insticator_uid'; +const USER_ID_KEY = 'instUid'; const USER_ID_COOKIE_EXP = 7776000000; // 90 days const BID_TTL = 300; // 5 minutes const GVLID = 910; @@ -23,14 +23,10 @@ config.setDefaults({ function getUserId() { let uid = localStorage.getItem(USER_ID_KEY); - if (uid && isUserIdValid(uid)) { - return uid; - } - - uid = storage.getCookie(USER_ID_KEY); if (uid && isUserIdValid(uid)) { const expireIn = new Date(Date.now() + USER_ID_COOKIE_EXP).toUTCString(); - storage.setCookie(USER_ID_KEY, uid, expireIn); + const domain = window.location.hostname.match(/[^.]*\.[^.]{2,3}(?:\.[^.]{2,3})?$/mg); + storage.setCookie(USER_ID_KEY, uid, expireIn, 'none', `.${domain}`); return uid; } @@ -44,36 +40,15 @@ function isUserIdValid(uid) { function generateUserId() { const uid = generateUUID(); - if (isLocalStoreEnabled()) { - localStorage.setItem(USER_ID_KEY, uid); - return uid; - } - if (isCookieEnabled()) { const expireIn = new Date(Date.now() + USER_ID_COOKIE_EXP).toUTCString(); - storage.setCookie(USER_ID_KEY, uid, expireIn); + const domain = window.location.hostname.match(/[^.]*\.[^.]{2,3}(?:\.[^.]{2,3})?$/mg); + storage.setCookie(USER_ID_KEY, uid, expireIn, 'none', `.${domain}`); } return uid; } -function isLocalStoreEnabled() { - let enabled = false; - - try { - localStorage.setItem('prebid.localStoreTest', 'true'); - enabled = Boolean(localStorage.getItem('prebid.localStoreTest')); - } catch (err) { - return false - } finally { - if (enabled) { - localStorage.removeItem('insticator.prebid.localStoreTest'); - } - } - - return enabled; -} - function isCookieEnabled() { let enabled = false; @@ -321,7 +296,10 @@ export const spec = { buildRequests: function (validBidRequests, bidderRequest) { const requests = []; let endpointUrl = config.getConfig('insticator.endpointUrl') || ENDPOINT; - endpointUrl = endpointUrl.replace(/^http:/, 'https:'); + + if (endpointUrl.indexOf('localhost') === -1) { + endpointUrl = endpointUrl.replace(/^http:/, 'https:'); + } if (validBidRequests.length > 0) { requests.push({ diff --git a/test/spec/modules/insticatorBidAdapter_spec.js b/test/spec/modules/insticatorBidAdapter_spec.js index 09952f833f8..bebf25dbcd1 100644 --- a/test/spec/modules/insticatorBidAdapter_spec.js +++ b/test/spec/modules/insticatorBidAdapter_spec.js @@ -335,7 +335,7 @@ describe('InsticatorBidAdapter', function () { const requests = spec.buildRequests([bidRequest], bidderRequest); const data = JSON.parse(requests[0].data); - expect(data.user.buyeruid).to.equal(USER_ID_STUBBED); + expect(data.user.id).to.equal(USER_ID_STUBBED); }); it('should return empty regs object if no gdprConsent is passed', function () { const requests = spec.buildRequests([bidRequest], { ...bidderRequest, ...{ gdprConsent: false } });