Skip to content

Commit

Permalink
Collect info about which ad units receive bids (prebid#4094)
Browse files Browse the repository at this point in the history
* Livewrapped bid and analytics adapter

* Fixed some tests for browser compatibility

* Fixed some tests for browser compatibility

* Changed analytics adapter code name

* Fix double quote in debug message

* modified how gdpr is being passed

* Added support for Publisher Common ID Module

* Corrections for ttr in analytics

* ANalytics updates

* Auction start time stamp changed

* Detect recovered ad blocked requests
Make it possible to pass dynamic parameters to adapter

* Collect info on ad units receiving any valid bid
  • Loading branch information
bjorn-lw authored and jsnellbaker committed Aug 21, 2019
1 parent 2096980 commit 35e4b2b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
23 changes: 23 additions & 0 deletions modules/livewrappedAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const BID_WON_TIMEOUT = 500;

const cache = {
auctions: {},
bidAdUnits: {}
};

let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE}), {
Expand Down Expand Up @@ -62,6 +63,9 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE
if (!bidResponse.ttr) {
bidResponse.ttr = time - bidResponse.start;
}
if (!cache.bidAdUnits[bidResponse.adUnit]) {
cache.bidAdUnits[bidResponse.adUnit] = {sent: 0, timeStamp: cache.auctions[args.auctionId].timeStamp};
}
break;
case CONSTANTS.EVENTS.BIDDER_DONE:
utils.logInfo('LIVEWRAPPED_BIDDER_DONE:', args);
Expand Down Expand Up @@ -114,6 +118,7 @@ livewrappedAnalyticsAdapter.sendEvents = function() {
responses: getResponses(),
wins: getWins(),
timeouts: getTimeouts(),
bidAdUnits: getbidAdUnits(),
rcv: getAdblockerRecovered()
};

Expand Down Expand Up @@ -229,6 +234,24 @@ function getTimeouts() {
return timeouts;
}

function getbidAdUnits() {
var bidAdUnits = [];

Object.keys(cache.bidAdUnits).forEach(adUnit => {
let bidAdUnit = cache.bidAdUnits[adUnit];
if (!bidAdUnit.sent) {
bidAdUnit.sent = 1;

bidAdUnits.push({
adUnit: adUnit,
timeStamp: bidAdUnit.timeStamp
});
}
});

return bidAdUnits;
}

adapterManager.registerAnalyticsAdapter({
adapter: livewrappedAnalyticsAdapter,
code: 'livewrapped'
Expand Down
10 changes: 10 additions & 0 deletions test/spec/modules/livewrappedAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ const MOCK = {

const ANALYTICS_MESSAGE = {
publisherId: 'CC411485-42BC-4F92-8389-42C503EE38D7',
bidAdUnits: [
{
adUnit: 'panorama_d_1',
timeStamp: 1519149562216
},
{
adUnit: 'box_d_1',
timeStamp: 1519149562216
}
],
requests: [
{
adUnit: 'panorama_d_1',
Expand Down

0 comments on commit 35e4b2b

Please sign in to comment.