diff --git a/resources/dist/index.js b/resources/dist/index.js index 248f955cc..6ec15f982 100644 Binary files a/resources/dist/index.js and b/resources/dist/index.js differ diff --git a/resources/dist/index.js.map b/resources/dist/index.js.map index a85993d54..5bfbb5bf3 100644 Binary files a/resources/dist/index.js.map and b/resources/dist/index.js.map differ diff --git a/src/changeListeners/eventLogging.js b/src/changeListeners/eventLogging.js index 861f2135c..6b2d5b2c9 100644 --- a/src/changeListeners/eventLogging.js +++ b/src/changeListeners/eventLogging.js @@ -57,7 +57,8 @@ module.exports = function ( boundActions, schema, track ) { var eventLogging = state.eventLogging, event = eventLogging.event, token, - key; + hash, + shouldLog = true; if ( !event ) { return; @@ -67,6 +68,8 @@ module.exports = function ( boundActions, schema, track ) { if ( tokenToSeenMap[ token ] === true ) { track( 'counter.PagePreviews.EventLogging.DuplicateToken', 1 ); + + shouldLog = false; } tokenToSeenMap[ token ] = true; @@ -78,14 +81,18 @@ module.exports = function ( boundActions, schema, track ) { // ... // // It's also remarkably easy to implement!!1 - key = fnv1a32( JSON.stringify( event ) ).toString( 16 ); + hash = fnv1a32( JSON.stringify( event ) ).toString( 16 ); // Has the event been seen before? - if ( hashToSeenMap[ key ] === true ) { + if ( hashToSeenMap[ hash ] === true ) { track( 'counter.PagePreviews.EventLogging.DuplicateEvent', 1 ); - } else { - hashToSeenMap[ key ] = true; + shouldLog = false; + } + + hashToSeenMap[ hash ] = true; + + if ( shouldLog ) { schema.log( $.extend( true, {}, eventLogging.baseData, event ) ); } diff --git a/tests/node-qunit/changeListeners/eventLogging.test.js b/tests/node-qunit/changeListeners/eventLogging.test.js index bc02b1cc0..7214a104d 100644 --- a/tests/node-qunit/changeListeners/eventLogging.test.js +++ b/tests/node-qunit/changeListeners/eventLogging.test.js @@ -167,4 +167,9 @@ QUnit.test( 'it should handle duplicate tokens', function ( assert ) { ], 'It should increment the duplicate token counter.' ); + + assert.ok( + this.schema.log.calledOnce, + 'It shouldn\'t log the event with the duplicate token.' + ); } );