Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Kobler bid adapter: added page view ID #12556

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading