From 429ab31cb5575a8fd1a155c6af926cf56106d054 Mon Sep 17 00:00:00 2001 From: David Lynch Date: Thu, 17 Nov 2022 09:39:43 -0600 Subject: [PATCH] Move logging hook registrations for realtime preview into document-ready There were analytics validation errors because events were being logged without a session ID. The session ID is only set on document-ready, as it's fetched from a hidden input on the document. Change-Id: Iaa24d430b780eaad54b78cb0d2ef0670fa2e32b1 --- modules/ext.wikiEditor.js | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/modules/ext.wikiEditor.js b/modules/ext.wikiEditor.js index 6314cfba..e4ac407d 100644 --- a/modules/ext.wikiEditor.js +++ b/modules/ext.wikiEditor.js @@ -233,6 +233,32 @@ logAbort( true, unmodified ); } ); + + // Add logging for Realtime Preview. + mw.hook( 'ext.WikiEditor.realtimepreview.enable' ).add( function () { + logEditFeature( 'preview', 'preview-realtime-on' ); + } ); + mw.hook( 'ext.WikiEditor.realtimepreview.inuse' ).add( function () { + logEditFeature( 'preview', 'preview-realtime-inuse' ); + } ); + mw.hook( 'ext.WikiEditor.realtimepreview.disable' ).add( function () { + logEditFeature( 'preview', 'preview-realtime-off' ); + } ); + mw.hook( 'ext.WikiEditor.realtimepreview.loaded' ).add( function () { + logEditFeature( 'preview', 'preview-realtime-loaded' ); + } ); + mw.hook( 'ext.WikiEditor.realtimepreview.stop' ).add( function () { + logEditFeature( 'preview', 'preview-realtime-error-stopped' ); + } ); + mw.hook( 'ext.WikiEditor.realtimepreview.reloadError' ).add( function () { + logEditFeature( 'preview', 'preview-realtime-reload-error' ); + } ); + mw.hook( 'ext.WikiEditor.realtimepreview.reloadHover' ).add( function () { + logEditFeature( 'preview', 'preview-realtime-reload-hover' ); + } ); + mw.hook( 'ext.WikiEditor.realtimepreview.reloadManual' ).add( function () { + logEditFeature( 'preview', 'preview-realtime-reload-manual' ); + } ); } // The old toolbar is still in place and needs to be removed so there aren't two toolbars @@ -259,30 +285,4 @@ }; - // Add logging for Realtime Preview. - mw.hook( 'ext.WikiEditor.realtimepreview.enable' ).add( function () { - logEditFeature( 'preview', 'preview-realtime-on' ); - } ); - mw.hook( 'ext.WikiEditor.realtimepreview.inuse' ).add( function () { - logEditFeature( 'preview', 'preview-realtime-inuse' ); - } ); - mw.hook( 'ext.WikiEditor.realtimepreview.disable' ).add( function () { - logEditFeature( 'preview', 'preview-realtime-off' ); - } ); - mw.hook( 'ext.WikiEditor.realtimepreview.loaded' ).add( function () { - logEditFeature( 'preview', 'preview-realtime-loaded' ); - } ); - mw.hook( 'ext.WikiEditor.realtimepreview.stop' ).add( function () { - logEditFeature( 'preview', 'preview-realtime-error-stopped' ); - } ); - mw.hook( 'ext.WikiEditor.realtimepreview.reloadError' ).add( function () { - logEditFeature( 'preview', 'preview-realtime-reload-error' ); - } ); - mw.hook( 'ext.WikiEditor.realtimepreview.reloadHover' ).add( function () { - logEditFeature( 'preview', 'preview-realtime-reload-hover' ); - } ); - mw.hook( 'ext.WikiEditor.realtimepreview.reloadManual' ).add( function () { - logEditFeature( 'preview', 'preview-realtime-reload-manual' ); - } ); - }() );