Просмотр исходного кода

Merge pull request #10797 from overleaf/td-editor-toggle-analytics

Add analytics for switching editor

GitOrigin-RevId: 7b44e53105e8669e97cb9c4821dfbc830faff779
Tim Down 3 лет назад
Родитель
Сommit
fa67c3fcff

+ 5 - 2
services/web/frontend/js/features/source-editor/components/editor-switch.tsx

@@ -1,6 +1,7 @@
 import { memo, useCallback } from 'react'
 import useScopeValue from '../../../shared/hooks/use-scope-value'
 import Tooltip from '../../../shared/components/tooltip'
+import { sendMB } from '../../../infrastructure/event-tracking'
 
 function Badge() {
   const content = (
@@ -43,9 +44,9 @@ function EditorSwitch() {
 
   const handleChange = useCallback(
     event => {
-      const choice = event.target.value
+      const editorType = event.target.value
 
-      switch (choice) {
+      switch (editorType) {
         case 'ace':
           setRichText(false)
           setNewSourceEditor(false)
@@ -60,6 +61,8 @@ function EditorSwitch() {
           setRichText(true)
           break
       }
+
+      sendMB('editor-switch-change', { editorType })
     },
     [setRichText, setNewSourceEditor]
   )