diff --git a/modules/beopBidAdapter.js b/modules/beopBidAdapter.js index 103820651fa..5b9e57628c6 100644 --- a/modules/beopBidAdapter.js +++ b/modules/beopBidAdapter.js @@ -1,6 +1,6 @@ import { buildUrl, - deepAccess, getBidIdParameter, + deepAccess, generateUUID, getBidIdParameter, getValue, isArray, isPlainObject, @@ -10,6 +10,7 @@ import { } from '../src/utils.js'; import {getRefererInfo} from '../src/refererDetection.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { getStorageManager } from '../src/storageManager.js'; import {config} from '../src/config.js'; import {getAllOrtbKeywords} from '../libraries/keywords/keywords.js'; @@ -21,9 +22,11 @@ import {getAllOrtbKeywords} from '../libraries/keywords/keywords.js'; const BIDDER_CODE = 'beop'; const ENDPOINT_URL = 'https://hb.beop.io/bid'; +const COOKIE_NAME = 'beopid'; const TCF_VENDOR_ID = 666; const validIdRegExp = /^[0-9a-fA-F]{24}$/ +const storage = getStorageManager({bidderCode: BIDDER_CODE}); export const spec = { code: BIDDER_CODE, @@ -64,6 +67,19 @@ export const spec = { const kwdsFromRequest = firstSlot.kwds; let keywords = getAllOrtbKeywords(bidderRequest.ortb2, kwdsFromRequest); + let beopid = ''; + if (storage.cookiesAreEnabled) { + beopid = storage.getCookie(COOKIE_NAME, undefined); + if (!beopid) { + beopid = generateUUID(); + let expirationDate = new Date(); + expirationDate.setTime(expirationDate.getTime() + 86400 * 183 * 1000); + storage.setCookie(COOKIE_NAME, beopid, expirationDate.toUTCString()); + } + } else { + storage.setCookie(COOKIE_NAME, '', 0); + } + const payloadObject = { at: new Date().toString(), nid: firstSlot.nid, @@ -74,6 +90,7 @@ export const spec = { lang: (window.navigator.language || window.navigator.languages[0]), kwds: keywords, dbg: false, + fg: beopid, slts: slots, is_amp: deepAccess(bidderRequest, 'referrerInfo.isAmp'), gdpr_applies: gdpr ? gdpr.gdprApplies : false, diff --git a/test/spec/modules/beopBidAdapter_spec.js b/test/spec/modules/beopBidAdapter_spec.js index d044e71ceb7..0a752761531 100644 --- a/test/spec/modules/beopBidAdapter_spec.js +++ b/test/spec/modules/beopBidAdapter_spec.js @@ -327,4 +327,16 @@ describe('BeOp Bid Adapter tests', () => { expect(payload.eids[0].source).to.equal('provider.com'); }); }) + + describe('Ensure first party cookie is well managed', function () { + let bidRequests = []; + + it(`should generate a new uuid`, function () { + let bid = Object.assign({}, validBid); + bidRequests.push(bid); + const request = spec.buildRequests(bidRequests, {}); + const payload = JSON.parse(request.data); + expect(payload.fg).to.exist; + }) + }) });