Send user events to Instabug
This commit is contained in:
parent
35983aa3d6
commit
a3f942b26c
|
@ -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))))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue