Merge "eventLogging: Add perceivedWait prop to all events"

This commit is contained in:
jenkins-bot 2017-05-25 21:04:45 +00:00 committed by Gerrit Code Review
commit 75436d4c20
4 changed files with 54 additions and 7 deletions

Binary file not shown.

Binary file not shown.

View file

@ -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 );
}

View file

@ -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',