Skip to content

Commit 60d8fd6

Browse files
jsadwithwwongkargoandyrusiecki
authored
Kargo Bid Adapter: onTimeout Support (prebid#8449)
* Kargo Bid Adapter: Use currency from Bid Response * Kargo Bid Adapter: Fix failed test * Kargo Bid Adapter: adding media type to bid response, supporting vastXml response (prebid#8426) * kargo adapter - adding mediaType to bid response, conditionally set vastXml field * kargo adapter - updating tests * Kargo Bid Adapter: onTimeout Support (#6) * Adding additional param * Adding response time function * Remove debug * Updating response time log to be set by bid response * Adding screen width/height to request * Test fix * Test fix * Removing interpretResponse signaling * Simplifying send data function Co-authored-by: Wei Wong <[email protected]> Co-authored-by: Andy Rusiecki <[email protected]>
1 parent 74e7d20 commit 60d8fd6

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

modules/kargoBidAdapter.js

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { _each } from '../src/utils.js';
1+
import { _each, buildUrl, triggerPixel } from '../src/utils.js';
22
import { config } from '../src/config.js';
33
import { registerBidder } from '../src/adapters/bidderFactory.js';
44
import { getStorageManager } from '../src/storageManager.js';
@@ -55,6 +55,10 @@ export const spec = {
5555
},
5656
bidIDs,
5757
bidSizes,
58+
device: {
59+
width: window.screen.width,
60+
height: window.screen.height
61+
},
5862
prebidRawBidRequests: validBidRequests
5963
}, spec._getAllMetadata(tdid, bidderRequest.uspConsent, bidderRequest.gdprConsent));
6064
const encodedParams = encodeURIComponent(JSON.stringify(transformedParams));
@@ -133,6 +137,15 @@ export const spec = {
133137
return syncs;
134138
},
135139
supportedMediaTypes: SUPPORTED_MEDIA_TYPES,
140+
onTimeout: function(timeoutData) {
141+
if (timeoutData == null) {
142+
return;
143+
}
144+
145+
timeoutData.forEach((bid) => {
146+
this._sendTimeoutData(bid.auctionId, bid.timeout);
147+
});
148+
},
136149

137150
// PRIVATE
138151
_readCookie(name) {
@@ -263,6 +276,24 @@ export const spec = {
263276
} catch (e) {
264277
return '';
265278
}
279+
},
280+
281+
_sendTimeoutData(auctionId, auctionTimeout) {
282+
let params = {
283+
aid: auctionId,
284+
ato: auctionTimeout,
285+
};
286+
287+
try {
288+
let timeoutRequestUrl = buildUrl({
289+
protocol: 'https',
290+
hostname: 'krk.kargo.com',
291+
pathname: '/api/v1/event/timeout',
292+
search: params
293+
});
294+
295+
triggerPixel(timeoutRequestUrl);
296+
} catch (e) {}
266297
}
267298
};
268299
registerBidder(spec);

test/spec/modules/kargoBidAdapter_spec.js

+27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {expect, assert} from 'chai';
22
import {spec} from 'modules/kargoBidAdapter.js';
33
import {config} from 'src/config.js';
4+
const utils = require('src/utils');
45

56
describe('kargo adapter tests', function () {
67
var sandbox, clock, frozenNow = new Date();
@@ -249,6 +250,10 @@ describe('kargo adapter tests', function () {
249250
2: [[320, 50], [300, 250], [300, 600]],
250251
3: [[320, 50], [300, 250], [300, 600]]
251252
},
253+
device: {
254+
width: screen.width,
255+
height: screen.height,
256+
},
252257
userIDs: {
253258
kargoID: '5f108831-302d-11e7-bf6b-4595acd3bf6c',
254259
clientID: '2410d8f2-c111-4811-88a5-7b5e190e475f',
@@ -683,4 +688,26 @@ describe('kargo adapter tests', function () {
683688
safelyRun(() => expect(getUserSyncsWhenForbidden()).to.be.an('array').that.is.empty);
684689
});
685690
});
691+
692+
describe('timeout pixel trigger', function () {
693+
let triggerPixelStub;
694+
695+
beforeEach(function () {
696+
triggerPixelStub = sinon.stub(utils, 'triggerPixel');
697+
});
698+
699+
afterEach(function () {
700+
utils.triggerPixel.restore();
701+
});
702+
703+
it('should call triggerPixel utils function when timed out is filled', function () {
704+
spec.onTimeout();
705+
expect(triggerPixelStub.getCall(0)).to.be.null;
706+
spec.onTimeout([{ auctionId: '1234', timeout: 2000 }]);
707+
expect(triggerPixelStub.getCall(0)).to.not.be.null;
708+
expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('https://krk.kargo.com/api/v1/event/timeout');
709+
expect(triggerPixelStub.getCall(0).args[0]).to.include('aid=1234');
710+
expect(triggerPixelStub.getCall(0).args[0]).to.include('ato=2000');
711+
});
712+
});
686713
});

0 commit comments

Comments
 (0)