forked from status-im/status-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstabug.cljs
More file actions
55 lines (45 loc) · 1.56 KB
/
instabug.cljs
File metadata and controls
55 lines (45 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(ns status-im.utils.instabug
(:require [taoensso.timbre :as log]
[status-im.utils.config :as config]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def instabug rn-dependencies/instabug)
(defn submit-bug []
(.invokeWithInvocationMode
instabug
(.. instabug
-invocationMode
-newBug)))
(defn request-feature []
(.showFeatureRequests
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 status-im.utils.mixpanel-events for list of trackable events)
(defn track [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
(log/debug str)
(.IBGLog rn-dependencies/instabug str)))
(defn instabug-appender []
{:enabled? true
:async? false
:min-level nil
:rate-limit nil
:output-fn :inherit
:fn (fn [data]
(let [{:keys [level ?ns-str ?err output_]} data]
(log (force output_))))})
(when-not js/goog.DEBUG
(log/merge-config! {:appenders {:instabug (instabug-appender)}}))
(defn init []
(.startWithToken rn-dependencies/instabug
config/instabug-token
(.. rn-dependencies/instabug -invocationEvent -shake))
(.setIntroMessageEnabled rn-dependencies/instabug false))