From a3f942b26cd6c91dda6ff8240e7955b674c2dced Mon Sep 17 00:00:00 2001 From: Dmitry Novotochinov Date: Thu, 3 May 2018 16:01:44 +0300 Subject: [PATCH] Send user events to Instabug --- .../ui/screens/currency_settings/events.cljs | 10 ++--- src/status_im/ui/screens/wallet/views.cljs | 32 +++++++-------- src/status_im/utils/handlers.cljs | 5 +-- src/status_im/utils/instabug.cljs | 40 +++++-------------- 4 files changed, 32 insertions(+), 55 deletions(-) diff --git a/src/status_im/ui/screens/currency_settings/events.cljs b/src/status_im/ui/screens/currency_settings/events.cljs index 69eb8d28be..a3b4644714 100644 --- a/src/status_im/ui/screens/currency_settings/events.cljs +++ b/src/status_im/ui/screens/currency_settings/events.cljs @@ -3,8 +3,8 @@ [status-im.utils.handlers :as handlers])) (handlers/register-handler-fx - :wallet.settings/set-currency - (fn [{:keys [db] :as cofx} [_ currency]] - (let [settings (get-in db [:account/account :settings]) - new-settings (assoc-in settings [:wallet :currency] currency)] - (accounts/update-settings new-settings cofx)))) + :wallet.settings/set-currency + (fn [{:keys [db] :as cofx} [_ currency]] + (let [settings (get-in db [:account/account :settings]) + new-settings (assoc-in settings [:wallet :currency] currency)] + (accounts/update-settings new-settings cofx)))) diff --git a/src/status_im/ui/screens/wallet/views.cljs b/src/status_im/ui/screens/wallet/views.cljs index 04842b69c8..0c36340c82 100644 --- a/src/status_im/ui/screens/wallet/views.cljs +++ b/src/status_im/ui/screens/wallet/views.cljs @@ -50,24 +50,24 @@ (defn- render-asset [currency] (fn [{:keys [symbol icon decimals amount]}] - (let [asset-value (re-frame/subscribe [:asset-value symbol (-> currency :code keyword)])] - [react/view {:style styles/asset-item-container} - [list/item - [list/item-image icon] - [react/view {:style styles/asset-item-value-container} - [react/text {:style styles/asset-item-value - :number-of-lines 1 - :ellipsize-mode :tail - :accessibility-label (str (-> symbol name clojure.string/lower-case) "-asset-value-text")} - (wallet.utils/format-amount amount decimals)] - [react/text {:style styles/asset-item-currency + (let [asset-value (re-frame/subscribe [:asset-value symbol (-> currency :code keyword)])] + [react/view {:style styles/asset-item-container} + [list/item + [list/item-image icon] + [react/view {:style styles/asset-item-value-container} + [react/text {:style styles/asset-item-value + :number-of-lines 1 + :ellipsize-mode :tail + :accessibility-label (str (-> symbol name clojure.string/lower-case) "-asset-value-text")} + (wallet.utils/format-amount amount decimals)] + [react/text {:style styles/asset-item-currency + :uppercase? true + :number-of-lines 1} + (clojure.core/name symbol)]] + [react/text {:style styles/asset-item-price :uppercase? true :number-of-lines 1} - (clojure.core/name symbol)]] - [react/text {:style styles/asset-item-price - :uppercase? true - :number-of-lines 1} - (if @asset-value (str (:symbol currency) @asset-value) "...")]]]))) + (if @asset-value (str (:symbol currency) @asset-value) "...")]]]))) (defn- asset-section [assets currency] [react/view styles/asset-section diff --git a/src/status_im/utils/handlers.cljs b/src/status_im/utils/handlers.cljs index 786a29e9ef..b653fd3158 100644 --- a/src/status_im/utils/handlers.cljs +++ b/src/status_im/utils/handlers.cljs @@ -101,9 +101,8 @@ anon-id (:device-UUID new-db)] (doseq [{:keys [label properties]} (mixpanel/matching-events new-db event mixpanel/event-by-trigger)] - (mixpanel/track anon-id label properties offline?)) - (when (= :send-current-message (first event)) - (instabug/maybe-show-survey new-db))))) + (mixpanel/track anon-id label properties offline?) + (instabug/track label properties))))) context))) (defn register-handler diff --git a/src/status_im/utils/instabug.cljs b/src/status_im/utils/instabug.cljs index 6441bbe61e..041f3ca9d1 100644 --- a/src/status_im/utils/instabug.cljs +++ b/src/status_im/utils/instabug.cljs @@ -5,40 +5,18 @@ (def instabug rn-dependencies/instabug) +(defn- prepare-event-name [event {:keys [target]}] + (str event " " target)) + ;; `event` is an event name, e.g. "Tap" ;; `properties` is a map of event details or nil, e.g. {:target :send-current-message} -;; (see mixpanel_events.edn for list of trackable events) - -(def survey-triggers - [{:event :send-current-message :count 4 :token "UqtvIKgVDUTo4l_sDS-fwA"} - {:event :send-current-message :count 29 :token "Hr9Dk3krPK7PPxuDbHAmXg"}]) - -;; 2018-05-07 12:00:00 -(def survey-enabled-timestamp 1525694400000) - -(defn maybe-show-survey [db] - (when config/instabug-surveys-enabled? - (let [sent-messages (->> db - :chats - (filter (fn [[chat-name _]] (not= "console" chat-name))) - (map second) - (mapcat (comp vals :messages)) - (filter :outgoing)) - sent-messages-count (count sent-messages) - sent-messages-after-ts-count (->> sent-messages - (filter #(> (:ts %) survey-enabled-timestamp)) - count) - {:keys [token]} (first (filter (fn [{:keys [count]}] - (or - (= count sent-messages-count) - (= count sent-messages-after-ts-count))) - survey-triggers))] - (when token - (.showSurveyWithToken instabug token))))) - +;; (see status-im.utils.mixpanel-events for list of trackable events) (defn track [event properties] - ;; NOTE(dmitryn) disabled until Instabug fix User Events - #_(.logUserEventWithNameAndParams instabug event properties)) + (when (= event "Tap") + (let [event-name (prepare-event-name event properties)] + (try + (.logUserEventWithName instabug event-name) + (catch :default _ nil))))) (defn log [str] (if js/goog.DEBUG