Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ogury Bid Adapter: adding timeline data to logging events #9208

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
7 changes: 5 additions & 2 deletions modules/oguryBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
});
}
});
Expand Down
32 changes: 27 additions & 5 deletions test/spec/modules/oguryBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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,
Expand All @@ -276,7 +283,10 @@ describe('OguryBidAdapter', function () {
h: 500
}]
},
ext: bidRequests[1].params
ext: {
...bidRequests[1].params,
timeSpentOnPage: stubbedCurrentTime
}
}],
regs: {
ext: {
Expand All @@ -295,7 +305,7 @@ describe('OguryBidAdapter', function () {
},
ext: {
prebidversion: '$prebid.version$',
adapterversion: '1.3.0'
adapterversion: '1.4.0'
},
device: {
w: stubbedWidth,
Expand All @@ -306,6 +316,7 @@ describe('OguryBidAdapter', function () {
after(function() {
stubbedWidthMethod.restore();
stubbedHeightMethod.restore();
stubbedCurrentTimeMethod.restore();
});

it('sends bid request to ENDPOINT via POST', function () {
Expand All @@ -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)

Expand Down Expand Up @@ -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,
Expand All @@ -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$'
}]

Expand Down