mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-24 07:34:11 +00:00
eventLogging: Log abandon event when user dwells
If the user abandons link A (or preview A) and immediately dwells on link B, then log a "dismissed" or "dwelledButAbandoned" event. In this context, "immediately" means before the ABANDON_END action is dispatched, which, currently, is 300 ms after the ABANDON_START action is dispatched. Bug: T159490 Change-Id: I49f0f5dfb3e6c08844f1794fee8cb6170e93981b
This commit is contained in:
parent
90d54eca64
commit
ae9733b2f0
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.
|
@ -148,7 +148,11 @@ module.exports = function ( state, action ) {
|
|||
started: action.timestamp,
|
||||
|
||||
isUserDwelling: true
|
||||
}
|
||||
},
|
||||
|
||||
// Was the user interacting with another link? If so, then log the
|
||||
// abandoned event.
|
||||
event: state.interaction ? createAbandonEvent( state.interaction ) : undefined
|
||||
} );
|
||||
|
||||
case actionTypes.PREVIEW_DWELL:
|
||||
|
|
|
@ -173,7 +173,8 @@ QUnit.test( 'LINK_DWELL starts an interaction', function ( assert ) {
|
|||
started: action.timestamp,
|
||||
|
||||
isUserDwelling: true
|
||||
}
|
||||
},
|
||||
event: undefined
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
@ -213,6 +214,44 @@ QUnit.test( 'LINK_DWELL doesn\'t start a new interaction under certain condition
|
|||
);
|
||||
} );
|
||||
|
||||
QUnit.test(
|
||||
'LINK_CLICK should enqueue a "dismissed" or "dwelledButAbandoned" event under certain conditions',
|
||||
function ( assert ) {
|
||||
var state,
|
||||
now = Date.now();
|
||||
|
||||
// Read: The user dwells on link A, abandons it, and dwells on link B fewer
|
||||
// than 300 ms after (before the ABANDON_END action is reduced).
|
||||
state = eventLogging( undefined, {
|
||||
type: 'LINK_DWELL',
|
||||
el: this.link,
|
||||
token: '0987654321',
|
||||
timestamp: now
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'ABANDON_START',
|
||||
timestamp: now + 250,
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_DWELL',
|
||||
el: $( '<a>' ),
|
||||
token: '1234567890',
|
||||
timestamp: now + 500
|
||||
} );
|
||||
|
||||
assert.deepEqual(
|
||||
state.event,
|
||||
{
|
||||
linkInteractionToken: '0987654321',
|
||||
totalInteractionTime: 250, // 250 - 0
|
||||
action: 'dwelledButAbandoned'
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test( 'LINK_CLICK should enqueue an "opened" event', function ( assert ) {
|
||||
var state,
|
||||
now = Date.now();
|
||||
|
|
Loading…
Reference in a new issue