From 2e014637a940a32912b7d13aa73011dfa29c0248 Mon Sep 17 00:00:00 2001 From: AlessandroDG Date: Thu, 28 Mar 2019 11:25:58 +0100 Subject: [PATCH] Rvr 2369 prevent duplicate events (#10) ## 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 https://github.com/prebid/Prebid.js/pull/3435 --- modules/rivrAnalyticsAdapter.js | 6 +++--- src/AnalyticsAdapter.js | 4 +--- test/spec/AnalyticsAdapter_spec.js | 12 ------------ 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/modules/rivrAnalyticsAdapter.js b/modules/rivrAnalyticsAdapter.js index b34bfe7fb6d..e1cfa5c70bc 100644 --- a/modules/rivrAnalyticsAdapter.js +++ b/modules/rivrAnalyticsAdapter.js @@ -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'; diff --git a/src/AnalyticsAdapter.js b/src/AnalyticsAdapter.js index 442c873fe4a..5565ba2ed18 100644 --- a/src/AnalyticsAdapter.js +++ b/src/AnalyticsAdapter.js @@ -16,8 +16,7 @@ const { BID_ADJUSTMENT, BIDDER_DONE, SET_TARGETING, - AD_RENDER_FAILED, - ADD_AD_UNITS + AD_RENDER_FAILED } } = CONSTANTS; @@ -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 }); diff --git a/test/spec/AnalyticsAdapter_spec.js b/test/spec/AnalyticsAdapter_spec.js index 2afd9af4cee..39096c0c4a3 100644 --- a/test/spec/AnalyticsAdapter_spec.js +++ b/test/spec/AnalyticsAdapter_spec.js @@ -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 = { @@ -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' };