Skip to content

Commit

Permalink
Rvr 2369 prevent duplicate events (#10)
Browse files Browse the repository at this point in the history
## Type of change
- [x] Refactoring (no functional changes, no api changes)

## Description of change

Refactor rivrAnalyticsAdapter.js events handling.


## History

* RVR-2087 - update adapterManager dependency

* RVR-2369 - Update package-lock.json

* RVR-2369 - Revert changes in main Analytics adapter

It will be handled in a separate PR

* RVR-2369 - Use relative import paths

Needed for prebid#3435
  • Loading branch information
AlessandroDG authored Mar 28, 2019
1 parent 5703176 commit 2e01463
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
6 changes: 3 additions & 3 deletions modules/rivrAnalyticsAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ajax} from 'src/ajax';
import adapter from 'src/AnalyticsAdapter';
import {ajax} from '../src/ajax';
import adapter from '../src/AnalyticsAdapter';
import adapterManager from '../src/adapterManager';
import * as utils from 'src/utils';
import * as utils from '../src/utils';

const analyticsType = 'endpoint';

Expand Down
4 changes: 1 addition & 3 deletions src/AnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const {
BID_ADJUSTMENT,
BIDDER_DONE,
SET_TARGETING,
AD_RENDER_FAILED,
ADD_AD_UNITS
AD_RENDER_FAILED
}
} = CONSTANTS;

Expand Down Expand Up @@ -110,7 +109,6 @@ 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
12 changes: 0 additions & 12 deletions test/spec/AnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ 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 @@ -87,17 +86,6 @@ 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 bidRequest event occurs', function () {
const eventType = BID_REQUESTED;
const args = { call: 'request' };
Expand Down

0 comments on commit 2e01463

Please sign in to comment.