mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 23:24:39 +00:00
eventLogging: Discard events with duplicate tokens
I6a38a261 made the eventLogging change listener count and discard duplicate events and count duplicate tokens. While we isolate the issue(s) that lead to duplication (reuse, likely) of tokens, make the eventLogging change listener discard events with duplicate tokens as well. Bug: T161769 Bug: T163198 Change-Id: I0dbb16c37814d39d7aec35c8fb7cc7309704c550
This commit is contained in:
parent
d6424cb59d
commit
c44fddf8cd
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map
vendored
BIN
resources/dist/index.js.map
vendored
Binary file not shown.
|
@ -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 ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -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.'
|
||||
);
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue