Skip to content

Commit

Permalink
Added page view ID to Kobler bid adapter. (#12556)
Browse files Browse the repository at this point in the history
  • Loading branch information
acsbendi authored Dec 12, 2024
1 parent f0adee0 commit 91ae090
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 5 additions & 1 deletion modules/koblerBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
deepAccess,
generateUUID,
getWindowSelf,
isArray,
isStr,
Expand All @@ -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 });
Expand Down Expand Up @@ -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
}
}
};
Expand Down
20 changes: 18 additions & 2 deletions test/spec/modules/koblerBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
}
}
};
Expand Down

0 comments on commit 91ae090

Please sign in to comment.