Skip to content

Commit

Permalink
Finteza adapter: fix request params (prebid#3690)
Browse files Browse the repository at this point in the history
  • Loading branch information
finteza authored and Isaac Dettman committed Mar 29, 2019
1 parent b06919c commit 155b42a
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 51 deletions.
26 changes: 15 additions & 11 deletions modules/fintezaAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const CONSTANTS = require('../src/constants.json');
const ANALYTICS_TYPE = 'endpoint';
const FINTEZA_HOST = 'https://content.mql5.com/tr';
const BID_REQUEST_TRACK = 'Bid Request %BIDDER%';
const BID_RESPONSE_TRACK = 'Bid Response %BIDDER%';
const BID_RESPONSE_PRICE_TRACK = 'Bid Response Price %BIDDER%';
const BID_RESPONSE_TIME_TRACK = 'Bid Response Time %BIDDER%';
const BID_TIMEOUT_TRACK = 'Bid Timeout %BIDDER%';
const BID_WON_TRACK = 'Bid Won %BIDDER%';

Expand Down Expand Up @@ -265,28 +266,30 @@ function prepareBidRequestedParams(args) {

function prepareBidResponseParams(args) {
return [{
event: encodeURIComponent(replaceBidder(fntzAnalyticsAdapter.context.bidResponseTrack, args.bidderCode)),
c1_value: args.timeToRespond,
c1_unit: 'ms',
c2_value: args.cpm,
c2_unit: 'usd',
event: encodeURIComponent(replaceBidder(fntzAnalyticsAdapter.context.bidResponsePriceTrack, args.bidderCode)),
value: args.cpm,
unit: 'usd'
}, {
event: encodeURIComponent(replaceBidder(fntzAnalyticsAdapter.context.bidResponseTimeTrack, args.bidderCode)),
value: args.timeToRespond,
unit: 'ms'
}];
}

function prepareBidWonParams(args) {
return [{
event: encodeURIComponent(replaceBidder(fntzAnalyticsAdapter.context.bidWonTrack, args.bidderCode)),
c1_value: args.cpm,
c1_unit: 'usd',
value: args.cpm,
unit: 'usd'
}];
}

function prepareBidTimeoutParams(args) {
return args.map(function(bid) {
return {
event: encodeURIComponent(replaceBidder(fntzAnalyticsAdapter.context.bidTimeoutTrack, bid.bidder)),
c1_value: bid.timeout,
c1_unit: 'ms',
value: bid.timeout,
unit: 'ms'
};
})
}
Expand Down Expand Up @@ -387,7 +390,8 @@ fntzAnalyticsAdapter.enableAnalytics = function (config) {
host: config.options.host || FINTEZA_HOST,
id: config.options.id,
bidRequestTrack: config.options.bidRequestTrack || BID_REQUEST_TRACK,
bidResponseTrack: config.options.bidResponseTrack || BID_RESPONSE_TRACK,
bidResponsePriceTrack: config.options.bidResponsePriceTrack || BID_RESPONSE_PRICE_TRACK,
bidResponseTimeTrack: config.options.bidResponseTimeTrack || BID_RESPONSE_TIME_TRACK,
bidTimeoutTrack: config.options.bidTimeoutTrack || BID_TIMEOUT_TRACK,
bidWonTrack: config.options.bidWonTrack || BID_WON_TRACK,
firstVisit: initFirstVisit(),
Expand Down
57 changes: 29 additions & 28 deletions modules/fintezaAnalyticsAdapter.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
# Overview

```
Module Name: Finteza Analytics Adapter
Module Type: Analytics Adapter
Maintainer: renat@finteza.com
```

# Description

The Finteza adapter for integration with Prebid is an analytics tool for publishers who use the Header Bidding technology. The adapter tracks auction opening, offer sending to advertisers, receipt of bids by the publisher and auction winner selection. All tracks are sent to Finteza and enable visual advertiser quality evaluation: how many offers partners accept, what prices they provide, how fast they respond and how often their bids win.

For more information, visit the [official Finteza website](https://www.finteza.com/).

# Test Parameters

```
{
provider: 'finteza',
options: {
id: 'xxxxx', // Website ID (required)
bidRequestTrack: 'Bid Request %BIDDER%',
bidResponseTrack: 'Bid Response %BIDDER%',
bidTimeoutTrack: 'Bid Timeout %BIDDER%',
bidWonTrack: 'Bid Won %BIDDER%'
}
}
```
# Overview

```
Module Name: Finteza Analytics Adapter
Module Type: Analytics Adapter
Maintainer: renat@finteza.com
```

# Description

The Finteza adapter for integration with Prebid is an analytics tool for publishers who use the Header Bidding technology. The adapter tracks auction opening, offer sending to advertisers, receipt of bids by the publisher and auction winner selection. All tracks are sent to Finteza and enable visual advertiser quality evaluation: how many offers partners accept, what prices they provide, how fast they respond and how often their bids win.

For more information, visit the [official Finteza website](https://www.finteza.com/).

# Test Parameters

```
{
provider: 'finteza',
options: {
id: 'xxxxx', // Website ID (required)
bidRequestTrack: 'Bid Request %BIDDER%',
bidResponsePriceTrack: 'Bid Response Price %BIDDER%',
bidResponseTimeTrack: 'Bid Response Time %BIDDER%',
bidTimeoutTrack: 'Bid Timeout %BIDDER%',
bidWonTrack: 'Bid Won %BIDDER%'
}
}
```
35 changes: 23 additions & 12 deletions test/spec/modules/fintezaAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ describe('finteza analytics adapter', function () {
options: {
id: clientId, // Client ID (required)
bidRequestTrack: 'Bid Request %BIDDER%',
bidResponseTrack: 'Bid Response %bidder%',
bidResponseTimeTrack: 'Bid Response Time %bidder%',
bidResponsePriceTrack: 'Bid Response Price %bidder%',
bidTimeoutTrack: 'Bid Timeout %Bidder%',
bidWonTrack: 'Bid Won %BIDDER%',
}
Expand Down Expand Up @@ -111,21 +112,31 @@ describe('finteza analytics adapter', function () {
// Emit the events with the "real" arguments
events.emit(constants.EVENTS.BID_RESPONSE, bidResponse);

expect(requests.length).to.equal(1);
expect(requests.length).to.equal(2);

expect(requests[0].method).to.equal('GET');

const url = parseURL(requests[0].url);
let url = parseURL(requests[0].url);

expect(url.protocol).to.equal('https');
expect(url.hostname).to.equal('content.mql5.com');
expect(url.pathname).to.equal('/tr');
expect(url.search.id).to.equal(clientId);
expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Price ${bidderCode.toLowerCase()}`);
expect(url.search.value).to.equal(String(cpm));
expect(url.search.unit).to.equal('usd');

expect(requests[1].method).to.equal('GET');

url = parseURL(requests[1].url);

expect(url.protocol).to.equal('https');
expect(url.hostname).to.equal('content.mql5.com');
expect(url.pathname).to.equal('/tr');
expect(url.search.id).to.equal(clientId);
expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response ${bidderCode.toLowerCase()}`);
expect(url.search.c1_value).to.equal(String(timeToRespond));
expect(url.search.c1_unit).to.equal('ms');
expect(url.search.c2_value).to.equal(String(cpm));
expect(url.search.c2_unit).to.equal('usd');
expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Time ${bidderCode.toLowerCase()}`);
expect(url.search.value).to.equal(String(timeToRespond));
expect(url.search.unit).to.equal('ms');

sinon.assert.callCount(fntzAnalyticsAdapter.track, 1);
});
Expand Down Expand Up @@ -162,8 +173,8 @@ describe('finteza analytics adapter', function () {
expect(url.pathname).to.equal('/tr');
expect(url.search.id).to.equal(clientId);
expect(decodeURIComponent(url.search.event)).to.equal(`Bid Won ${bidderCode.toUpperCase()}`);
expect(url.search.c1_value).to.equal(String(cpm));
expect(url.search.c1_unit).to.equal('usd');
expect(url.search.value).to.equal(String(cpm));
expect(url.search.unit).to.equal('usd');

sinon.assert.callCount(fntzAnalyticsAdapter.track, 1);
});
Expand Down Expand Up @@ -199,8 +210,8 @@ describe('finteza analytics adapter', function () {
expect(url.pathname).to.equal('/tr');
expect(url.search.id).to.equal(clientId);
expect(decodeURIComponent(url.search.event)).to.equal(`Bid Timeout Bidder789`);
expect(url.search.c1_value).to.equal(String(timeout));
expect(url.search.c1_unit).to.equal('ms');
expect(url.search.value).to.equal(String(timeout));
expect(url.search.unit).to.equal('ms');

sinon.assert.callCount(fntzAnalyticsAdapter.track, 1);
});
Expand Down

0 comments on commit 155b42a

Please sign in to comment.