From 2f9cda35fe69a34958624900812757da152f36a0 Mon Sep 17 00:00:00 2001 From: Valentin FOURNY Date: Mon, 7 Nov 2022 13:06:46 +0100 Subject: [PATCH] adding timeline data to logging events --- modules/oguryBidAdapter.js | 7 +++-- test/spec/modules/oguryBidAdapter_spec.js | 32 +++++++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/modules/oguryBidAdapter.js b/modules/oguryBidAdapter.js index cb082f2d9a9..da62ce5c0a1 100644 --- a/modules/oguryBidAdapter.js +++ b/modules/oguryBidAdapter.js @@ -11,7 +11,7 @@ const DEFAULT_TIMEOUT = 1000; const BID_HOST = 'https://mweb-hb.presage.io/api/header-bidding-request'; const TIMEOUT_MONITORING_HOST = 'https://ms-ads-monitoring-events.presage.io'; const MS_COOKIE_SYNC_DOMAIN = 'https://ms-cookie-sync.presage.io'; -const ADAPTER_VERSION = '1.3.0'; +const ADAPTER_VERSION = '1.4.0'; function getClientWidth() { const documentElementClientWidth = window.top.document.documentElement.clientWidth @@ -114,7 +114,10 @@ function buildRequests(validBidRequests, bidderRequest) { banner: { format: sizes }, - ext: bidRequest.params + ext: { + ...bidRequest.params, + timeSpentOnPage: document.timeline && document.timeline.currentTime ? document.timeline.currentTime : 0 + } }); } }); diff --git a/test/spec/modules/oguryBidAdapter_spec.js b/test/spec/modules/oguryBidAdapter_spec.js index b9e4b44b571..f7cdcc0d11a 100644 --- a/test/spec/modules/oguryBidAdapter_spec.js +++ b/test/spec/modules/oguryBidAdapter_spec.js @@ -244,12 +244,16 @@ describe('OguryBidAdapter', function () { describe('buildRequests', function () { const stubbedWidth = 200 const stubbedHeight = 600 + const stubbedCurrentTime = 1234567890 const stubbedWidthMethod = sinon.stub(window.top.document.documentElement, 'clientWidth').get(function() { return stubbedWidth; }); const stubbedHeightMethod = sinon.stub(window.top.document.documentElement, 'clientHeight').get(function() { return stubbedHeight; }); + const stubbedCurrentTimeMethod = sinon.stub(document.timeline, 'currentTime').get(function() { + return stubbedCurrentTime; + }); const defaultTimeout = 1000; const expectedRequestObject = { @@ -266,7 +270,10 @@ describe('OguryBidAdapter', function () { h: 250 }] }, - ext: bidRequests[0].params + ext: { + ...bidRequests[0].params, + timeSpentOnPage: stubbedCurrentTime + } }, { id: bidRequests[1].bidId, tagid: bidRequests[1].params.adUnitId, @@ -276,7 +283,10 @@ describe('OguryBidAdapter', function () { h: 500 }] }, - ext: bidRequests[1].params + ext: { + ...bidRequests[1].params, + timeSpentOnPage: stubbedCurrentTime + } }], regs: { ext: { @@ -295,7 +305,7 @@ describe('OguryBidAdapter', function () { }, ext: { prebidversion: '$prebid.version$', - adapterversion: '1.3.0' + adapterversion: '1.4.0' }, device: { w: stubbedWidth, @@ -306,6 +316,7 @@ describe('OguryBidAdapter', function () { after(function() { stubbedWidthMethod.restore(); stubbedHeightMethod.restore(); + stubbedCurrentTimeMethod.restore(); }); it('sends bid request to ENDPOINT via POST', function () { @@ -316,6 +327,17 @@ describe('OguryBidAdapter', function () { expect(request.method).to.equal('POST'); }); + it('timeSpentOnpage should be 0 if timeline is undefined', function () { + const stubbedTimelineMethod = sinon.stub(document, 'timeline').get(function() { + return undefined; + }); + const validBidRequests = utils.deepClone(bidRequests) + + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.data.imp[0].ext.timeSpentOnPage).to.equal(0); + stubbedTimelineMethod.restore(); + }); + it('bid request object should be conform', function () { const validBidRequests = utils.deepClone(bidRequests) @@ -675,7 +697,7 @@ describe('OguryBidAdapter', function () { advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[0].adomain }, nurl: openRtbBidResponse.body.seatbid[0].bid[0].nurl, - adapterVersion: '1.3.0', + adapterVersion: '1.4.0', prebidVersion: '$prebid.version$' }, { requestId: openRtbBidResponse.body.seatbid[0].bid[1].impid, @@ -692,7 +714,7 @@ describe('OguryBidAdapter', function () { advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[1].adomain }, nurl: openRtbBidResponse.body.seatbid[0].bid[1].nurl, - adapterVersion: '1.3.0', + adapterVersion: '1.4.0', prebidVersion: '$prebid.version$' }]