Phuedx has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/325927 )
Change subject: LINK_CLICK logs an "opened" event ...................................................................... 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 --- M extension.json M resources/ext.popups/reducers.js M tests/qunit/ext.popups/reducers.eventLogging.test.js 3 files changed, 40 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups refs/changes/27/325927/1 diff --git a/extension.json b/extension.json index 562a1f9..141c9af 100644 --- a/extension.json +++ b/extension.json @@ -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.", diff --git a/resources/ext.popups/reducers.js b/resources/ext.popups/reducers.js index e9dfa8b..7f710a3 100644 --- a/resources/ext.popups/reducers.js +++ b/resources/ext.popups/reducers.js @@ -193,6 +193,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; } diff --git a/tests/qunit/ext.popups/reducers.eventLogging.test.js b/tests/qunit/ext.popups/reducers.eventLogging.test.js index 61fa547..d114140 100644 --- a/tests/qunit/ext.popups/reducers.eventLogging.test.js +++ b/tests/qunit/ext.popups/reducers.eventLogging.test.js @@ -134,4 +134,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 ) ); -- To view, visit https://gerrit.wikimedia.org/r/325927 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9d67daf83815f1c08b6479497c566dfa337de4bc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Popups Gerrit-Branch: mpga Gerrit-Owner: Phuedx <samsm...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits