LINK_CLICK logs an "opened" event

Reducer changes:
* Make the eventLogging reducer queue an "opened" event with the
  requisite supporting data.

Changes:
* Update the Popups EventLogging schema to the latest revision, which
  defines the "opened" action.

Bug: T152225
Change-Id: I9d67daf83815f1c08b6479497c566dfa337de4bc
This commit is contained in:
Sam Smith 2016-12-07 10:56:54 +00:00
parent 5b76fb0276
commit 60b65ad6c4
3 changed files with 40 additions and 1 deletions

View file

@ -37,7 +37,7 @@
]
},
"EventLoggingSchemas": {
"Popups": 15906495
"Popups": 16112163
},
"config": {
"@PopupsBetaFeature": "@var bool: Whether the extension should be enabled as an opt-in beta feature. If true, the BetaFeatures extension must be installed. False by default.",

View file

@ -199,6 +199,15 @@
}
} );
case mw.popups.actionTypes.LINK_CLICK:
return nextState( state, {
event: {
action: 'opened',
linkInteractionToken: state.interaction.token,
totalInteractionTime: Math.round( action.timestamp - state.interaction.started )
}
} );
default:
return state;
}

View file

@ -135,4 +135,34 @@
);
} );
QUnit.test( 'LINK_CLICK should enqueue an "opened" event', function ( assert ) {
var state,
now = mw.now();
state = {
interaction: undefined
};
state = mw.popups.reducers.eventLogging( state, {
type: 'LINK_DWELL',
interactionToken: '0987654321',
timestamp: now
} );
state = mw.popups.reducers.eventLogging( state, {
type: 'LINK_CLICK',
timestamp: now + 250.25
} );
assert.deepEqual(
state.event,
{
action: 'opened',
linkInteractionToken: '0987654321',
totalInteractionTime: 250
},
'The event is enqueued and the totalInteractionProperty is an integer.'
);
} );
}( mediaWiki ) );