Skip to content

Commit

Permalink
kargo adapter track request count (prebid#4074)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhorwitz authored and sa1omon committed Nov 28, 2019
1 parent 65b07bb commit fc360e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const HOST = 'https://krk.kargo.com';
const SYNC = 'https://crb.kargo.com/api/v1/initsyncrnd/{UUID}?seed={SEED}&idx={INDEX}';
const SYNC_COUNT = 5;

let sessionId;
let sessionId,
lastPageUrl,
requestCounter;

export const spec = {
code: BIDDER_CODE,
Expand All @@ -31,6 +33,7 @@ export const spec = {
}
const transformedParams = Object.assign({}, {
sessionId: spec._getSessionId(),
requestCount: spec._getRequestCount(),
timeout: bidderRequest.timeout,
currency: currency,
cpmGranularity: 1,
Expand Down Expand Up @@ -202,6 +205,14 @@ export const spec = {
return sessionId;
},

_getRequestCount() {
if (lastPageUrl === window.location.pathname) {
return ++requestCounter;
}
lastPageUrl = window.location.pathname;
return requestCounter = 0;
},

_generateRandomUuid() {
try {
// crypto.getRandomValues is supported everywhere but Opera Mini for years
Expand Down
3 changes: 2 additions & 1 deletion test/spec/modules/kargoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('kargo adapter tests', function () {
});

describe('build request', function() {
var bids, undefinedCurrency, noAdServerCurrency, cookies = [], localStorageItems = [], sessionIds = [];
var bids, undefinedCurrency, noAdServerCurrency, cookies = [], localStorageItems = [], sessionIds = [], requestCount = 0;

beforeEach(function () {
undefinedCurrency = false;
Expand Down Expand Up @@ -222,6 +222,7 @@ describe('kargo adapter tests', function () {
function getExpectedKrakenParams(excludeUserIds, excludeKrux, expectedRawCRB, expectedRawCRBCookie) {
var base = {
timeout: 200,
requestCount: requestCount++,
currency: 'USD',
cpmGranularity: 1,
timestamp: frozenNow.getTime(),
Expand Down

0 comments on commit fc360e5

Please sign in to comment.