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

Prebid 1.0 adxcg analytics adapter fix for bidtimeout event #1871

Merged
merged 2 commits into from
Nov 27, 2017
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
17 changes: 9 additions & 8 deletions modules/adxcgAnalyticsAdapter.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {ajax} from 'src/ajax';
import adapter from 'src/AnalyticsAdapter';
import adaptermanager from 'src/adaptermanager';
import CONSTANTS from 'src/constants.json';
import * as url from 'src/url';
import * as utils from 'src/utils';

const emptyUrl = '';
const analyticsType = 'endpoint';
const adxcgAnalyticsVersion = 'v1.04';
const adxcgAnalyticsVersion = 'v1.05';

let initOptions;
let auctionTimestamp;
Expand All @@ -22,23 +23,23 @@ var adxcgAnalyticsAdapter = Object.assign(adapter(
}), {
track({eventType, args}) {
if (typeof args !== 'undefined') {
if (eventType === 'bidTimeout') {
events.bidTimeout = args;
} else if (eventType === 'auctionInit') {
if (eventType === CONSTANTS.EVENTS.BID_TIMEOUT) {
events.bidTimeout = [...new Set(args.map(item => item.bidder))];
} else if (eventType === CONSTANTS.EVENTS.AUCTION_INIT) {
events.auctionInit = args;
auctionTimestamp = args.timestamp;
} else if (eventType === 'bidRequested') {
} else if (eventType === CONSTANTS.EVENTS.BID_REQUESTED) {
events.bidRequests.push(args);
} else if (eventType === 'bidResponse') {
} else if (eventType === CONSTANTS.EVENTS.BID_RESPONSE) {
events.bidResponses.push(mapBidResponse(args));
} else if (eventType === 'bidWon') {
} else if (eventType === CONSTANTS.EVENTS.BID_WON) {
send({
bidWon: mapBidResponse(args)
});
}
}

if (eventType === 'auctionEnd') {
if (eventType === CONSTANTS.EVENTS.AUCTION_END) {
send(events);
}
}
Expand Down
31 changes: 30 additions & 1 deletion test/spec/modules/adxcgAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('adxcg analytics adapter', () => {

describe('track', () => {
it('builds and sends auction data', () => {
let auctionTimestamp = 42;
let auctionTimestamp = 1496510254313;
let initOptions = {
publisherId: '42'
};
Expand All @@ -32,6 +32,21 @@ describe('adxcg analytics adapter', () => {
ad: 'adContent'
};

let bidTimeoutArgsV1 = [
{
bidId: '2baa51527bd015',
bidder: 'bidderOne',
adUnitCode: '/19968336/header-bid-tag-0',
auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f'
},
{
bidId: '6fe3b4c2c23092',
bidder: 'bidderTwo',
adUnitCode: '/19968336/header-bid-tag-0',
auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f'
}
];

adaptermanager.registerAnalyticsAdapter({
code: 'adxcg',
adapter: adxcgAnalyticsAdapter
Expand All @@ -42,11 +57,21 @@ describe('adxcg analytics adapter', () => {
options: initOptions
});

// Step 1: Send auction init event
events.emit(constants.EVENTS.AUCTION_INIT, {
timestamp: auctionTimestamp
});

// Step 2: Send bid requested event
events.emit(constants.EVENTS.BID_REQUESTED, bidRequest);

// Step 3: Send bid response event
events.emit(constants.EVENTS.BID_RESPONSE, bidResponse);

// Step 4: Send bid time out event
events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeoutArgsV1);

// Step 5: Send auction end event
events.emit(constants.EVENTS.AUCTION_END, {});

expect(requests.length).to.equal(1);
Expand All @@ -61,8 +86,12 @@ describe('adxcg analytics adapter', () => {
expect(auctionEventData.bidResponses[0]).to.not.have.property('ad');

expect(auctionEventData.initOptions).to.deep.equal(initOptions);

expect(auctionEventData.auctionTimestamp).to.equal(auctionTimestamp);

expect(auctionEventData.bidTimeout).to.deep.equal(['bidderOne', 'bidderTwo']);

// Step 6: Send auction bid won event
events.emit(constants.EVENTS.BID_WON, {
adId: 'adIdData',
ad: 'adContent'
Expand Down