Tienson Qin 4 лет назад
Родитель
Сommit
c41247e200
2 измененных файлов с 16 добавлено и 3 удалено
  1. 3 1
      src/main/frontend/components/editor.cljs
  2. 13 2
      src/main/frontend/handler.cljs

+ 3 - 1
src/main/frontend/components/editor.cljs

@@ -72,7 +72,9 @@
                                    (not (contains? #{"Date picker" "Template" "Deadline" "Scheduled" "Upload an image"} command))))]
                                    (not (contains? #{"Date picker" "Template" "Deadline" "Scheduled" "Upload an image"} command))))]
               (editor-handler/insert-command! id command-steps
               (editor-handler/insert-command! id command-steps
                                               format
                                               format
-                                              {:restore? restore-slash?}))))
+                                              {:restore? restore-slash?})
+              (state/pub-event! [:instrument {:type :editor/command-triggered
+                                              :payload {:command command}}]))))
         :class
         :class
         "black"}))))
         "black"}))))
 
 

+ 13 - 2
src/main/frontend/handler.cljs

@@ -62,10 +62,20 @@
                             (* 60 1000)))
                             (* 60 1000)))
                 (let [total (srs/get-srs-cards-total)]
                 (let [total (srs/get-srs-cards-total)]
                   (state/set-state! :srs/cards-due-count total)
                   (state/set-state! :srs/cards-due-count total)
-                  (reset! cards-last-check-time (util/time-ms))))))]
+                  (reset! cards-last-check-time (util/time-ms))
+                  ))))]
     (f)
     (f)
     (js/setInterval f 5000)))
     (js/setInterval f 5000)))
 
 
+(defn- instrument!
+  []
+  (let [total (srs/get-srs-cards-total)]
+    (state/set-state! :srs/cards-due-count total)
+    (state/pub-event! [:instrument {:type :flashcards/count
+                                    :payload {:total (or total 0)}}])
+    (state/pub-event! [:instrument {:type :blocks/count
+                                    :payload {:total (db/blocks-count)}}])))
+
 (defn store-schema!
 (defn store-schema!
   []
   []
   (storage/set :db-schema (assoc db-schema/schema
   (storage/set :db-schema (assoc db-schema/schema
@@ -235,7 +245,8 @@
       (enable-datalog-console))
       (enable-datalog-console))
     (when (util/electron?)
     (when (util/electron?)
       (el/listen!))
       (el/listen!))
-    (mobile/init!)))
+    (mobile/init!)
+    (js/setTimeout instrument! (* 60 1000))))
 
 
 (defn stop! []
 (defn stop! []
   (prn "stop!"))
   (prn "stop!"))