Skip to content

Commit 9dc200f

Browse files
committed
Bug reporting and logs sharing improvements
1 parent 9035954 commit 9dc200f

File tree

4 files changed

+101
-64
lines changed

4 files changed

+101
-64
lines changed

src/status_im/utils/error_handler.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@
6060
{:title "Error"
6161
:content (.-message e)
6262
:confirm-button-text (i18n/label :t/send-logs)
63-
:on-accept #(re-frame/dispatch [:logging.ui/send-logs-pressed])})))))))
63+
:on-accept #(re-frame/dispatch [:logging.ui/send-logs-pressed :email])})))))))

src/status_im/utils/logging/core.cljs

Lines changed: 95 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
[status-im.utils.datetime :as datetime]
1212
[clojure.string :as string]
1313
[status-im.utils.config :as config]
14+
[status-im.ui.components.react :as react]
1415
["react-native-mail" :default react-native-mail]))
1516

1617
(def report-email "[email protected]")
@@ -54,53 +55,6 @@
5455
{:db (assoc-in db [:multiaccount :log-level] log-level)
5556
:logs/set-level log-level}))
5657

57-
(fx/defn send-logs
58-
{:events [:logging.ui/send-logs-pressed]}
59-
[{:keys [db]}]
60-
;; TODO: Add message explaining db export
61-
(let [db-json (types/clj->json (select-keys db [:app-state
62-
:current-chat-id
63-
:network
64-
:network-status
65-
:peers-count
66-
:peers-summary
67-
:sync-state
68-
:view-id
69-
:chat/cooldown-enabled?
70-
:chat/cooldowns
71-
:chat/last-outgoing-message-sent-at
72-
:chat/spam-messages-frequency
73-
:chats/loading?
74-
:dimensions/window]))]
75-
{:logs/archive-logs [db-json ::send-email]}))
76-
77-
(fx/defn show-client-error
78-
{:events [:show-client-error]}
79-
[_]
80-
{:utils/show-popup {:title (i18n/label :t/cant-report-bug)
81-
:content (i18n/label :t/mail-should-be-configured)}})
82-
83-
(fx/defn show-logs-dialog
84-
{:events [:shake-event]}
85-
[{:keys [db]}]
86-
(when-not (:logging/dialog-shown? db)
87-
{:db
88-
(assoc db :logging/dialog-shown? true)
89-
:utils/show-confirmation
90-
{:title (i18n/label :t/send-logs)
91-
:content (i18n/label :t/send-logs-to
92-
{:email report-email})
93-
:confirm-button-text (i18n/label :t/send-logs)
94-
:on-accept #(re-frame/dispatch
95-
[:logging.ui/send-logs-pressed])
96-
:on-cancel #(re-frame/dispatch
97-
[:logging/dialog-canceled])}}))
98-
99-
(fx/defn dialog-closed
100-
{:events [:logging/dialog-canceled]}
101-
[{:keys [db]}]
102-
{:db (dissoc db :logging/dialog-shown?)})
103-
10458
(defn email-body
10559
"logs attached"
10660
[{:keys [:web3-node-version :mailserver/current-id
@@ -139,13 +93,10 @@
13993
(datetime/timestamp->long-date
14094
(datetime/now))]))))
14195

142-
(re-frame/reg-fx
143-
:email/send
144-
;; https://github.com/chirag04/react-native-mail#example
145-
(fn [[opts callback]]
146-
(.mail react-native-mail
147-
(clj->js opts)
148-
callback)))
96+
(fx/defn dialog-closed
97+
{:events [:logging/dialog-canceled]}
98+
[{:keys [db]}]
99+
{:db (dissoc db :logging/dialog-shown?)})
149100

150101
(fx/defn send-email
151102
[_ opts callback]
@@ -158,12 +109,96 @@
158109
cofx
159110
(dialog-closed)
160111
(send-email
161-
{:subject "Error report"
162-
:recipients [report-email]
163-
:body (email-body db)
164-
:attachments [{:uri archive-uri
165-
:type "zip"
166-
:name "status_logs.zip"}]}
112+
(cond-> {:subject "Error report"
113+
:recipients [report-email]
114+
:body (email-body db)}
115+
116+
(not (nil? archive-uri))
117+
(assoc :attachments [{:uri archive-uri
118+
:type "zip"
119+
:name "status_logs.zip"}]))
167120
(fn [event]
168121
(when (= event "not_available")
169122
(re-frame/dispatch [:show-client-error]))))))
123+
124+
(defn logs-enabled? [db]
125+
(not (string/blank? (get-in db [:multiaccount :log-level]))))
126+
127+
(fx/defn send-logs
128+
{:events [:logging.ui/send-logs-pressed]}
129+
[{:keys [db] :as cofx} transport]
130+
(if (logs-enabled? db)
131+
;; TODO: Add message explaining db export
132+
(let [db-json (types/clj->json (select-keys db [:app-state
133+
:current-chat-id
134+
:network
135+
:network-status
136+
:peers-count
137+
:peers-summary
138+
:sync-state
139+
:view-id
140+
:chat/cooldown-enabled?
141+
:chat/cooldowns
142+
:chat/last-outgoing-message-sent-at
143+
:chat/spam-messages-frequency
144+
:chats/loading?
145+
:dimensions/window]))]
146+
{:logs/archive-logs [db-json (if (= transport :email)
147+
::send-email
148+
::share-logs-file)]})
149+
(send-email-event cofx nil)))
150+
151+
(fx/defn show-client-error
152+
{:events [:show-client-error]}
153+
[_]
154+
{:utils/show-popup {:title (i18n/label :t/cant-report-bug)
155+
:content (i18n/label :t/mail-should-be-configured)}})
156+
157+
(fx/defn show-logs-dialog
158+
{:events [:shake-event]}
159+
[{:keys [db]}]
160+
(when-not (:logging/dialog-shown? db)
161+
{:db
162+
(assoc db :logging/dialog-shown? true)
163+
:utils/show-confirmation
164+
(cond-> {:title (i18n/label :t/send-logs)
165+
:content (i18n/label :t/send-logs-to
166+
{:email report-email})
167+
:confirm-button-text (i18n/label :t/send-logs)
168+
:on-accept #(re-frame/dispatch
169+
[:logging.ui/send-logs-pressed :email])
170+
:on-cancel #(re-frame/dispatch
171+
[:logging/dialog-canceled])}
172+
173+
(and #_platform/ios? (logs-enabled? db))
174+
(assoc :extra-options [{:text (i18n/label :t/share-logs)
175+
:onPress #(re-frame/dispatch
176+
[:logging.ui/send-logs-pressed :sharing])
177+
:style "default"}]))}))
178+
179+
(re-frame/reg-fx
180+
:email/send
181+
;; https://github.com/chirag04/react-native-mail#example
182+
(fn [[opts callback]]
183+
(.mail react-native-mail (clj->js opts) callback)))
184+
185+
(re-frame/reg-fx
186+
::share-archive
187+
(fn [opts]
188+
(.share ^js react/sharing (clj->js opts))))
189+
190+
(fx/defn share-archive
191+
[_ opts]
192+
{::share-archive opts})
193+
194+
(fx/defn share-logs-file
195+
{:events [::share-logs-file]}
196+
[{:keys [db] :as cofx} archive-uri]
197+
(fx/merge
198+
cofx
199+
(dialog-closed)
200+
(share-archive
201+
{:title "Archived logs"
202+
:url archive-uri
203+
:message archive-uri})))
204+

src/status_im/utils/utils.cljs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@
5353

5454
(re-frame/reg-fx
5555
:utils/show-confirmation
56-
(fn [{:keys [title content confirm-button-text on-accept on-cancel cancel-button-text]}]
56+
(fn [{:keys [title content confirm-button-text on-accept on-cancel cancel-button-text extra-options]}]
5757
(show-confirmation {:title title
5858
:content content
5959
:confirm-button-text confirm-button-text
6060
:cancel-button-text cancel-button-text
6161
:on-accept on-accept
62-
:on-cancel on-cancel})))
62+
:on-cancel on-cancel
63+
:extra-options extra-options})))
6364

6465
(defn show-question
6566
([title content on-accept]

translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@
10741074
"removed": "removed",
10751075
"repeat-pin": "Repeat new 6-digit passcode",
10761076
"repeat-puk": "Repeat new 12-digit PUK",
1077-
"report-bug-email-template": "1. Issue Description\n(Describe the feature you would like, or briefly summarise the bug and what you did, what you expected to happen, and what actually happens. Sections below)\n\n\n2. Steps to reproduce\n(Describe how we can replicate the bug step by step.)\n-Open Status\n-...\n-Step 3, etc.\n\n\n3. Expected behavior\n(Describe what you expected to happen.)\n\n\n4. Actual behavior\n(Describe what actually happened.)\n\n\n5. Attach screenshots that can demo the problem, please\n",
1077+
"report-bug-email-template": "1. Issue Description\n(Describe the feature you would like, or briefly summarise the bug and what you did, what you expected to happen, and what actually happens. Sections below)\n\n\n2. Steps to reproduce\n(Describe how we can replicate the bug step by step.)\n-Open Status\n-...\n-Step 3, etc.\n\n\n3. Attach screenshots that can demo the problem, please\n",
10781078
"request-transaction": "Request transaction",
10791079
"required-field": "Required field",
10801080
"resend-message": "Resend",
@@ -1130,6 +1130,7 @@
11301130
"share-public-chat-text": "Check out this public chat on the Status app: {{link}}",
11311131
"sharing-copied-to-clipboard": "Copied",
11321132
"sharing-copy-to-clipboard": "Copy",
1133+
"share-logs": "Share logs",
11331134
"sharing-share": "Share",
11341135
"show-less": "Show less",
11351136
"show-more": "Show more",

0 commit comments

Comments
 (0)