Skip to content

Commit

Permalink
Marfeel 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmrf committed May 21, 2018
1 parent 849fdf1 commit 9ff521c
Show file tree
Hide file tree
Showing 4 changed files with 6,082 additions and 818 deletions.
13 changes: 13 additions & 0 deletions modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
"appnexusBidAdapter",
"rubiconBidAdapter",
"ixBidAdapter",
"pulsepointBidAdapter",
"sovrnBidAdapter",
"openxBidAdapter",
"pubmaticBidAdapter",
"smartadserverBidAdapter",
"prebidServerBidAdapter",

"marfeelAnalyticsAdapter"
]
54 changes: 54 additions & 0 deletions modules/marfeelAnalyticsAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import adapter from 'src/AnalyticsAdapter';
import CONSTANTS from 'src/constants.json';
import adaptermanager from 'src/adaptermanager';
import includes from 'core-js/library/fn/array/includes';

const utils = require('src/utils');

const url = '//pa.rxthdr.com/analytic';
const analyticsType = 'endpoint';

let AUCTION_INIT = CONSTANTS.EVENTS.AUCTION_INIT;
let AUCTION_END = CONSTANTS.EVENTS.AUCTION_END;
let BID_WON = CONSTANTS.EVENTS.BID_WON;
let BID_RESPONSE = CONSTANTS.EVENTS.BID_RESPONSE;
let auctions = {};

function auctionEnd(auction, {timedOut}) {
if (timedOut) auction.timedOut = true;

window.mrfpb && window.mrfpb.trackAuction(auction)
}

function registerWinner(auction, args) {
window.mrfpb && window.mrfpb.trackAuctionWinner(auction, args)
}

function registerBidResponse(currentAuction, bid) {
currentAuction.bidders = currentAuction.bidders || [];
currentAuction.bidders.push(bid)
}

let marfeelAnalyticsAdapter = Object.assign(adapter({url, analyticsType}),
{
track({eventType, args}) {
if (args) args.requestId = args.auctionId; // BackwardsCompatibility
if (eventType === AUCTION_INIT) {
auctions[args.auctionId] = args;
} else if (eventType === BID_RESPONSE) {
registerBidResponse(auctions[args.auctionId], args);
} else if (eventType === BID_WON) {
registerWinner(auctions[args.auctionId], args);
} else if (eventType === AUCTION_END) {
auctionEnd(auctions[args.auctionId], args);
}
},

});

adaptermanager.registerAnalyticsAdapter({
adapter: marfeelAnalyticsAdapter,
code: 'marfeel'
});

export default marfeelAnalyticsAdapter;
Loading

0 comments on commit 9ff521c

Please sign in to comment.