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

Rvr 2369 add trackable add ad units event #3691

Merged
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
6 changes: 5 additions & 1 deletion src/AnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
EVENTS: {
AUCTION_INIT,
AUCTION_END,
REQUEST_BIDS,
BID_REQUESTED,
BID_TIMEOUT,
BID_RESPONSE,
Expand All @@ -16,7 +17,8 @@ const {
BID_ADJUSTMENT,
BIDDER_DONE,
SET_TARGETING,
AD_RENDER_FAILED
AD_RENDER_FAILED,
ADD_AD_UNITS
}
} = CONSTANTS;

Expand Down Expand Up @@ -99,6 +101,7 @@ export default function AnalyticsAdapter({ url, analyticsType, global, handler }
// Next register event listeners to send data immediately

_handlers = {
[REQUEST_BIDS]: args => this.enqueue({ eventType: REQUEST_BIDS, args }),
[BID_REQUESTED]: args => this.enqueue({ eventType: BID_REQUESTED, args }),
[BID_RESPONSE]: args => this.enqueue({ eventType: BID_RESPONSE, args }),
[NO_BID]: args => this.enqueue({ eventType: NO_BID, args }),
Expand All @@ -109,6 +112,7 @@ export default function AnalyticsAdapter({ url, analyticsType, global, handler }
[SET_TARGETING]: args => this.enqueue({ eventType: SET_TARGETING, args }),
[AUCTION_END]: args => this.enqueue({ eventType: AUCTION_END, args }),
[AD_RENDER_FAILED]: args => this.enqueue({ eventType: AD_RENDER_FAILED, args }),
[ADD_AD_UNITS]: args => this.enqueue({ eventType: ADD_AD_UNITS, args }),
[AUCTION_INIT]: args => {
args.config = typeof config === 'object' ? config.options || {} : {}; // enableAnaltyics configuration object
this.enqueue({ eventType: AUCTION_INIT, args });
Expand Down
24 changes: 24 additions & 0 deletions test/spec/AnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { expect } from 'chai';
import events from 'src/events';
import CONSTANTS from 'src/constants.json';

const REQUEST_BIDS = CONSTANTS.EVENTS.REQUEST_BIDS;
const BID_REQUESTED = CONSTANTS.EVENTS.BID_REQUESTED;
const BID_RESPONSE = CONSTANTS.EVENTS.BID_RESPONSE;
const BID_WON = CONSTANTS.EVENTS.BID_WON;
const BID_TIMEOUT = CONSTANTS.EVENTS.BID_TIMEOUT;
const AD_RENDER_FAILED = CONSTANTS.EVENTS.AD_RENDER_FAILED;
const ADD_AD_UNITS = CONSTANTS.EVENTS.ADD_AD_UNITS;

const AnalyticsAdapter = require('src/AnalyticsAdapter').default;
const config = {
Expand Down Expand Up @@ -86,6 +88,28 @@ FEATURE: Analytics Adapters API
expect(result).to.deep.equal({args: {call: 'adRenderFailed'}, eventType: 'adRenderFailed'});
});

it('SHOULD call global when an addAdUnits event occurs', function () {
const eventType = ADD_AD_UNITS;
const args = { call: 'addAdUnits' };

adapter.enableAnalytics();
events.emit(eventType, args);

let result = JSON.parse(requests[0].requestBody);
expect(result).to.deep.equal({args: {call: 'addAdUnits'}, eventType: 'addAdUnits'});
});

it('SHOULD call global when a requestBids event occurs', function () {
const eventType = REQUEST_BIDS;
const args = { call: 'request' };

adapter.enableAnalytics();
events.emit(eventType, args);

let result = JSON.parse(requests[0].requestBody);
expect(result).to.deep.equal({args: {call: 'request'}, eventType: 'requestBids'});
});

it('SHOULD call global when a bidRequest event occurs', function () {
const eventType = BID_REQUESTED;
const args = { call: 'request' };
Expand Down