mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-12 09:18:59 +00:00
Merge "eventLogging: Add perceivedWait prop to all events"
This commit is contained in:
commit
75436d4c20
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.
|
@ -45,6 +45,12 @@ function createEvent( interaction, actionData ) {
|
|||
actionData.pageTitleHover = interaction.title;
|
||||
actionData.namespaceIdHover = interaction.namespaceID;
|
||||
|
||||
// Has the preview been shown?
|
||||
if ( interaction.timeToPreviewShow !== undefined ) {
|
||||
actionData.previewType = interaction.previewType;
|
||||
actionData.perceivedWait = interaction.timeToPreviewShow;
|
||||
}
|
||||
|
||||
return actionData;
|
||||
}
|
||||
|
||||
|
@ -74,13 +80,7 @@ function createClosingEvent( interaction ) {
|
|||
// Has the preview been shown? If so, then, in the context of the
|
||||
// instrumentation, then the preview has been dismissed by the user
|
||||
// rather than the user has abandoned the link.
|
||||
if ( interaction.timeToPreviewShow !== undefined ) {
|
||||
actionData.action = 'dismissed';
|
||||
actionData.previewType = interaction.previewType;
|
||||
actionData.perceivedWait = interaction.timeToPreviewShow;
|
||||
} else {
|
||||
actionData.action = 'dwelledButAbandoned';
|
||||
}
|
||||
actionData.action = interaction.timeToPreviewShow ? 'dismissed' : 'dwelledButAbandoned';
|
||||
|
||||
return createEvent( interaction, actionData );
|
||||
}
|
||||
|
|
|
@ -408,6 +408,53 @@ QUnit.test( 'PREVIEW_SHOW should update the perceived wait time of the interacti
|
|||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'LINK_CLICK should include perceivedWait if the preview has been shown', function ( assert ) {
|
||||
var token = '0987654321',
|
||||
state,
|
||||
now = Date.now();
|
||||
|
||||
state = {
|
||||
interaction: undefined
|
||||
};
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_DWELL',
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceID: 1,
|
||||
token: token,
|
||||
timestamp: now
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'PREVIEW_SHOW',
|
||||
token: token,
|
||||
timestamp: now + 750
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_CLICK',
|
||||
el: this.link,
|
||||
timestamp: now + 1050
|
||||
} );
|
||||
|
||||
assert.deepEqual(
|
||||
state.event,
|
||||
{
|
||||
action: 'opened',
|
||||
pageTitleHover: 'Foo',
|
||||
namespaceIdHover: 1,
|
||||
linkInteractionToken: token,
|
||||
totalInteractionTime: 1050,
|
||||
|
||||
// N.B. that the FETCH_* actions have been skipped.
|
||||
previewType: undefined,
|
||||
perceivedWait: 750
|
||||
},
|
||||
'The prevewType and perceivedWait properties are set if the preview has been shown.'
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( 'FETCH_COMPLETE', function ( assert ) {
|
||||
var model,
|
||||
token = '1234567890',
|
||||
|
|
Loading…
Reference in a new issue