Remove duplicate events filtering

We had instrumentation for over 4 weeks and duplicate events rate
was very low. We want to keep stats so we check the duplicate events
rate but there is no need to filter those.

Bug: T167365
Change-Id: I72585beb21e9db589e45eeace657ef25f432abc9
This commit is contained in:
Piotr Miazga 2017-07-05 19:36:17 +02:00
parent 7e2c79ae0d
commit 426356e822
4 changed files with 29 additions and 13 deletions

Binary file not shown.

Binary file not shown.

View file

@ -28,6 +28,16 @@ function fnv1a32( string ) {
/* eslint-enable no-bitwise */
}
/**
* Check if event is an interaction event
*
* @param {Object} event Event
* @returns {boolean}
*/
function isInteractionEvent( event ) {
return event.linkInteractionToken !== undefined;
}
/**
* Check if token was already used
*
@ -111,21 +121,22 @@ module.exports = function ( boundActions, eventLoggingTracker, statsvTracker ) {
if ( !event ) {
return;
}
if ( isDuplicateToken( tokenToSeenMap, event.linkInteractionToken ) ) {
statsvTracker( 'counter.PagePreviews.EventLogging.DuplicateToken', 1 );
shouldLog = false;
}
if ( isDuplicateEvent( hashToSeenMap, event ) ) {
statsvTracker( 'counter.PagePreviews.EventLogging.DuplicateEvent', 1 );
shouldLog = false;
// We log duplicates only for interaction events
if ( isInteractionEvent( event ) ) {
if ( isDuplicateToken( tokenToSeenMap, event.linkInteractionToken ) ) {
shouldLog = false;
statsvTracker( 'counter.PagePreviews.EventLogging.DuplicateToken', 1 );
}
if ( isDuplicateEvent( hashToSeenMap, event ) ) {
statsvTracker( 'counter.PagePreviews.EventLogging.DuplicateEvent', 1 );
}
}
event = $.extend( true, {}, eventLogging.baseData, event );
if ( shouldLog ) {
eventLoggingTracker( 'event.Popups', event );
}
// Dispatch the eventLogged action even if it was a duplicate so that the
// state tree can be cleared/updated.
boundActions.eventLogged( event );

View file

@ -109,7 +109,6 @@ QUnit.test( 'it should handle duplicate events', function ( assert ) {
this.eventLoggingTracker.calledTwice,
'It shouldn\'t log the event.'
);
// ---
nextState = createState( {
@ -165,7 +164,6 @@ QUnit.test( 'it should handle duplicate tokens', function ( assert ) {
],
'It should increment the duplicate token counter.'
);
assert.ok(
this.eventLoggingTracker.calledOnce,
'It shouldn\'t log the event with the duplicate token.'
@ -174,7 +172,8 @@ QUnit.test( 'it should handle duplicate tokens', function ( assert ) {
QUnit.test( 'it should handle undefined tokens', function ( assert ) {
var state,
state2;
state2,
state3;
state = createState( undefined, {
action: 'pageLoaded'
@ -184,15 +183,21 @@ QUnit.test( 'it should handle undefined tokens', function ( assert ) {
action: 'disabled'
} );
state3 = createState( undefined, {
action: 'disabled'
} );
this.changeListener( undefined, state );
this.changeListener( undefined, state2 );
this.changeListener( undefined, state3 );
assert.ok(
this.statsvTracker.notCalled,
'It shouldn\'t increment the duplicate token counter.'
);
assert.ok(
this.eventLoggingTracker.calledTwice,
this.eventLoggingTracker.calledThrice,
'It should log the event twice.'
);
} );