mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-25 06:46:37 +00:00
Show user survey when N amount of messages sent
It's a temporary solution until Instabug fix User Events API
This commit is contained in:
parent
c95bc11d52
commit
62af757fa1
1
.env
1
.env
@ -18,3 +18,4 @@ DEFAULT_NETWORK=mainnet_rpc
|
||||
TESTFAIRY_TOKEN=969f6c921cb435cea1d41d1ea3f5b247d6026d55
|
||||
INSTABUG_TOKEN=758630ed52864cbad9c5eeeac596c60c
|
||||
DEBUG_WEBVIEW=1
|
||||
INSTABUG_SURVEYS=1
|
||||
|
1
.env.e2e
1
.env.e2e
@ -17,3 +17,4 @@ POW_TIME=1
|
||||
DEFAULT_NETWORK=testnet_rpc
|
||||
INSTABUG_TOKEN=758630ed52864cbad9c5eeeac596c60c
|
||||
DEBUG_WEBVIEW=1
|
||||
INSTABUG_SURVEYS=0
|
||||
|
@ -18,3 +18,4 @@ POW_TIME=1
|
||||
DEFAULT_NETWORK=mainnet_rpc
|
||||
INSTABUG_TOKEN=758630ed52864cbad9c5eeeac596c60c
|
||||
DEBUG_WEBVIEW=1
|
||||
INSTABUG_SURVEYS=1
|
||||
|
@ -18,3 +18,4 @@ POW_TIME=1
|
||||
DEFAULT_NETWORK=testnet_rpc
|
||||
INSTABUG_TOKEN=758630ed52864cbad9c5eeeac596c60c
|
||||
DEBUG_WEBVIEW=0
|
||||
INSTABUG_SURVEYS=1
|
||||
|
@ -42,7 +42,7 @@
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.handlers-macro :as handlers-macro]
|
||||
[status-im.utils.http :as http]
|
||||
[status-im.utils.instabug :as inst]
|
||||
[status-im.utils.instabug :as instabug]
|
||||
[status-im.utils.mixpanel :as mixpanel]
|
||||
[status-im.utils.platform :as platform]
|
||||
[status-im.utils.types :as types]
|
||||
@ -348,7 +348,7 @@
|
||||
:signal-event
|
||||
(fn [_ [_ event-str]]
|
||||
(log/debug :event-str event-str)
|
||||
(inst/log (str "Signal event: " event-str))
|
||||
(instabug/log (str "Signal event: " event-str))
|
||||
(let [{:keys [type event]} (types/json->clj event-str)
|
||||
to-dispatch (case type
|
||||
"sign-request.queued" [:sign-request-queued event]
|
||||
|
@ -37,6 +37,7 @@
|
||||
(def default-network (get-config :DEFAULT_NETWORK))
|
||||
(def testfairy-token (get-config :TESTFAIRY_TOKEN))
|
||||
(def instabug-token (get-config :INSTABUG_TOKEN))
|
||||
(def instabug-surveys-enabled? (get-config :INSTABUG_SURVEYS))
|
||||
|
||||
(def pow-target (js/parseFloat (get-config :POW_TARGET "0.002")))
|
||||
(def pow-time (js/parseInt (get-config :POW_TIME "1")))
|
||||
|
@ -4,6 +4,7 @@
|
||||
[re-frame.core :refer [reg-event-db reg-event-fx] :as re-frame]
|
||||
[re-frame.interceptor :refer [->interceptor get-coeffect get-effect]]
|
||||
[status-im.utils.ethereum.core :as ethereum]
|
||||
[status-im.utils.instabug :as instabug]
|
||||
[status-im.utils.mixpanel :as mixpanel]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
@ -100,7 +101,9 @@
|
||||
anon-id (ethereum/sha3 current-account-id)]
|
||||
(doseq [{:keys [label properties]}
|
||||
(mixpanel/matching-events event mixpanel/event-by-trigger)]
|
||||
(mixpanel/track anon-id label properties offline?)))))
|
||||
(mixpanel/track anon-id label properties offline?))
|
||||
(when (= :send-current-message (first event))
|
||||
(instabug/maybe-show-survey new-db)))))
|
||||
context)))
|
||||
|
||||
(defn register-handler
|
||||
|
@ -3,6 +3,43 @@
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.react-native.js-dependencies :as rn-dependencies]))
|
||||
|
||||
(def instabug rn-dependencies/instabug)
|
||||
|
||||
;; `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)))))
|
||||
|
||||
(defn track [event properties]
|
||||
;; NOTE(dmitryn) disabled until Instabug fix User Events
|
||||
#_(.logUserEventWithNameAndParams instabug event properties))
|
||||
|
||||
(defn log [str]
|
||||
(if js/goog.DEBUG
|
||||
(log/debug str)
|
||||
|
Loading…
x
Reference in New Issue
Block a user