From 24918d86ca12f2adb62f2dd11d798db63af9059b Mon Sep 17 00:00:00 2001 From: acsbendi Date: Fri, 6 Dec 2024 14:44:15 +0100 Subject: [PATCH] Added page view ID to Kobler bid adapter. --- modules/koblerBidAdapter.js | 6 +++++- test/spec/modules/koblerBidAdapter_spec.js | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/koblerBidAdapter.js b/modules/koblerBidAdapter.js index 9cde2e96d4e..a5c14e7bce1 100644 --- a/modules/koblerBidAdapter.js +++ b/modules/koblerBidAdapter.js @@ -1,5 +1,6 @@ import { deepAccess, + generateUUID, getWindowSelf, isArray, isStr, @@ -14,6 +15,8 @@ import { getCurrencyFromBidderRequest } from '../libraries/ortb2Utils/currency.j const additionalData = new WeakMap(); +export const pageViewId = generateUUID(); + export function setAdditionalData(obj, key, value) { const prevValue = additionalData.get(obj) || {}; additionalData.set(obj, { ...prevValue, [key]: value }); @@ -169,7 +172,8 @@ function buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest) { ext: { kobler: { tcf_purpose_2_given: purpose2Given, - tcf_purpose_3_given: purpose3Given + tcf_purpose_3_given: purpose3Given, + page_view_id: pageViewId } } }; diff --git a/test/spec/modules/koblerBidAdapter_spec.js b/test/spec/modules/koblerBidAdapter_spec.js index 47b89bb5956..8bee7c0e2cb 100644 --- a/test/spec/modules/koblerBidAdapter_spec.js +++ b/test/spec/modules/koblerBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/koblerBidAdapter.js'; +import {pageViewId, spec} from 'modules/koblerBidAdapter.js'; import {newBidder} from 'src/adapters/bidderFactory.js'; import {config} from 'src/config.js'; import * as utils from 'src/utils.js'; @@ -247,6 +247,21 @@ describe('KoblerAdapter', function () { expect(openRtbRequest.site.page).to.be.equal(testUrl); }); + it('should reuse the same page view ID on subsequent calls', function () { + const testUrl = 'kobler.no'; + const auctionId1 = '8319af54-9795-4642-ba3a-6f57d6ff9100'; + const auctionId2 = 'e19f2d0c-602d-4969-96a1-69a22d483f47'; + const timeout = 5000; + const validBidRequests = [createValidBidRequest()]; + const bidderRequest1 = createBidderRequest(auctionId1, timeout, testUrl); + const bidderRequest2 = createBidderRequest(auctionId2, timeout, testUrl); + + const openRtbRequest1 = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest1).data); + expect(openRtbRequest1.ext.kobler.page_view_id).to.be.equal(pageViewId); + const openRtbRequest2 = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest2).data); + expect(openRtbRequest2.ext.kobler.page_view_id).to.be.equal(pageViewId); + }); + it('should read data from valid bid requests', function () { const firstSize = [400, 800]; const secondSize = [450, 950]; @@ -538,7 +553,8 @@ describe('KoblerAdapter', function () { ext: { kobler: { tcf_purpose_2_given: true, - tcf_purpose_3_given: false + tcf_purpose_3_given: false, + page_view_id: pageViewId } } };