mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 23:24:39 +00:00
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:
parent
5b76fb0276
commit
60b65ad6c4
|
@ -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.",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 ) );
|
||||
|
|
Loading…
Reference in a new issue