Ver Fonte

fix: use tags for filter and add user id to the scope

Development errors are collected too to help identity errors earlier
Tienson Qin há 2 anos atrás
pai
commit
d743130d82

+ 5 - 2
src/main/frontend/handler/events.cljs

@@ -62,7 +62,8 @@
             [rum.core :as rum]
             [logseq.graph-parser.config :as gp-config]
             [cljs-bean.core :as bean]
-            ["@sentry/react" :as Sentry]))
+            ["@sentry/react" :as Sentry]
+            [frontend.modules.instrumentation.sentry :as sentry-event]))
 
 ;; TODO: should we move all events here?
 
@@ -87,6 +88,8 @@
         (map? result)
         (do
           (state/set-user-info! result)
+          (when-let [uid (user-handler/user-uuid)]
+            (sentry-event/set-user! uid))
           (let [status (if (user-handler/alpha-or-beta-user?) :welcome :unavailable)]
             (when (and (= status :welcome) (user-handler/logged-in?))
               (when-not (false? (state/enable-sync?)) ; user turns it off
@@ -431,7 +434,7 @@
                        :graph-id graph-uuid
                        :tx-id tx-id)]
     (Sentry/captureException error
-                            (bean/->js {:extra payload}))))
+                             (bean/->js {:tags payload}))))
 
 (defmethod handle :exec-plugin-cmd [[_ {:keys [pid cmd action]}]]
   (commands/exec-plugin-simple-command! pid cmd action))

+ 7 - 3
src/main/frontend/modules/instrumentation/sentry.cljs

@@ -44,6 +44,10 @@
                  event)})
 
 (defn init []
-  (when-not config/dev?
-    (let [config (clj->js config)]
-      (Sentry/init config))))
+  (let [config (clj->js config)]
+    (Sentry/init config)))
+
+(defn set-user!
+  [id]
+  (Sentry/configureScope (fn [scope]
+                           (.setUser scope #js {:id id}))))