Skip to content
Merged
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
27 changes: 15 additions & 12 deletions modules/openxAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ function removeads(info) {

let openxAdapter = Object.assign(adapter({ urlParam, analyticsType }), {
track({ eventType, args }) {

if (!checkInitOptions()) {
send(eventType, {}, null);
return;
Expand All @@ -245,19 +246,18 @@ let openxAdapter = Object.assign(adapter({ urlParam, analyticsType }), {
info.ad = '';
}

let auctionId = info.auctionId;
// utils.logInfo('OX: Got auctionId', auctionId);
// on bid timeout events, the info is an array of bids
let auctionId = eventType === CONSTANTS.EVENTS.BID_TIMEOUT
? info[0].auctionId
: info.auctionId;

if (eventType === auctionInitConst) {
eventStack[auctionId] = { options: {}, events: [] };
// utils.logInfo('OX: Event Stack updated after AuctionInit', eventStack);
}
else if (eventType === bidWonConst) { // && auctionStatus[auctionId] !== 'started'
} else if (eventType === bidWonConst) {
pushEvent(eventType, info, auctionId);
// utils.logInfo('OX: Bid won called for', auctionId);
return;
}
else if (eventType === auctionEndConst) {
} else if (eventType === auctionEndConst) {
pushEvent(eventType, removeads(info), auctionId);
// utils.logInfo('OX: Auction end called for', auctionId);
updateSessionId();
Expand All @@ -279,8 +279,7 @@ let openxAdapter = Object.assign(adapter({ urlParam, analyticsType }), {
// utils.logInfo('OX: Deleted Auction Info for auctionId', auctionId);
}, AUCTION_END_WAIT_TIME);
}
}
else if (eventType === bidTimeoutConst) {
} else if (eventType === bidTimeoutConst) {
// utils.logInfo('SA: Bid Timedout for', auctionId);
pushEvent(eventType, info, auctionId);
}
Expand Down Expand Up @@ -485,13 +484,11 @@ function send(eventType, eventStack, auctionId) {
utils.logError('OX: Invalid data format');
delete eventStack[auctionId];
// utils.logInfo('OX: Deleted Auction Info for auctionId', auctionId);
return;
}
} else {
utils.logError('OX: Invalid data format');
delete eventStack[auctionId];
// utils.logInfo('OX: Deleted Auction Info for auctionId', auctionId);
return;
}
}
function pushEvent(eventType, args, auctionId) {
Expand All @@ -504,7 +501,13 @@ function pushEvent(eventType, args, auctionId) {
}
} else {
if (isValidEvent(eventType, args.adUnitCode)) {
eventStack[auctionId].events.push({ eventType: eventType, args: args });
if (eventType === CONSTANTS.EVENTS.BID_TIMEOUT) {
// convert object to array
let timedOutBids = utils._map(args, timedOutBid => timedOutBid);
eventStack[auctionId].events.push({ eventType: eventType, args: timedOutBids });
} else {
eventStack[auctionId].events.push({ eventType: eventType, args: args });
}
}
}
}
Expand Down