Skip to content

Commit

Permalink
Add a setting to enable telemetry #19811
Browse files Browse the repository at this point in the history
  • Loading branch information
flexsurfer committed May 1, 2024
1 parent 6a1fdc5 commit dc75587
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
62 changes: 24 additions & 38 deletions src/legacy/status_im/ui/screens/advanced_settings/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

(defn- normal-mode-settings-data
[{:keys [current-log-level
telemetry-enabled?
light-client-enabled?
transactions-management-enabled?
current-fleet
webview-debug
test-networks-enabled?
is-goerli-enabled?
peer-syncing-enabled?]}]
Expand Down Expand Up @@ -62,33 +61,22 @@
#(re-frame/dispatch [:open-modal :peers-stats])
:chevron true}
{:size :small
:title (i18n/label :t/light-client-enabled)
:accessibility-label :light-client-enabled
:container-margin-bottom 8
:on-press
#(re-frame/dispatch
[:wakuv2.ui/toggle-light-client (not light-client-enabled?)])
:accessory :switch
:active light-client-enabled?}
{:size :small
:title (i18n/label :t/transactions-management-enabled)
:accessibility-label :transactions-management-enabled
:title "Telemetry"
:accessibility-label :telemetry-enabled
:container-margin-bottom 8
:on-press
#(re-frame/dispatch
[:multiaccounts.ui/switch-transactions-management-enabled
(not transactions-management-enabled?)])
#(re-frame/dispatch [:profile.settings/toggle-telemetry])
:accessory :switch
:active transactions-management-enabled?}
:active telemetry-enabled?}
{:size :small
:title "Webview debug"
:accessibility-label :webview-debug-switch
:title (i18n/label :t/light-client-enabled)
:accessibility-label :light-client-enabled
:container-margin-bottom 8
:on-press
#(re-frame/dispatch
[:profile.settings/change-webview-debug (not webview-debug)])
[:wakuv2.ui/toggle-light-client (not light-client-enabled?)])
:accessory :switch
:active webview-debug}
:active light-client-enabled?}
{:size :small
:title "Testnet mode"
:accessibility-label :test-networks-enabled
Expand Down Expand Up @@ -126,14 +114,13 @@

(views/defview advanced-settings
[]
(views/letsubs [test-networks-enabled? [:profile/test-networks-enabled?]
is-goerli-enabled? [:profile/is-goerli-enabled?]
light-client-enabled? [:profile/light-client-enabled?]
webview-debug [:profile/webview-debug]
transactions-management-enabled? [:wallet-legacy/transactions-management-enabled?]
current-log-level [:log-level/current-log-level]
current-fleet [:fleets/current-fleet]
peer-syncing-enabled? [:profile/peer-syncing-enabled?]]
(views/letsubs [test-networks-enabled? [:profile/test-networks-enabled?]
is-goerli-enabled? [:profile/is-goerli-enabled?]
light-client-enabled? [:profile/light-client-enabled?]
telemetry-enabled? [:profile/telemetry-enabled?]
current-log-level [:log-level/current-log-level]
current-fleet [:fleets/current-fleet]
peer-syncing-enabled? [:profile/peer-syncing-enabled?]]
[:<>
[quo/page-nav
{:type :title
Expand All @@ -143,14 +130,13 @@
:on-press #(rf/dispatch [:navigate-back])}]
[list/flat-list
{:data (flat-list-data
{:current-log-level current-log-level
:transactions-management-enabled? transactions-management-enabled?
:light-client-enabled? light-client-enabled?
:current-fleet current-fleet
:dev-mode? false
:webview-debug webview-debug
:test-networks-enabled? test-networks-enabled?
:is-goerli-enabled? is-goerli-enabled?
:peer-syncing-enabled? peer-syncing-enabled?})
{:current-log-level current-log-level
:telemetry-enabled? telemetry-enabled?
:light-client-enabled? light-client-enabled?
:current-fleet current-fleet
:dev-mode? false
:test-networks-enabled? test-networks-enabled?
:is-goerli-enabled? is-goerli-enabled?
:peer-syncing-enabled? peer-syncing-enabled?})
:key-fn (fn [_ i] (str i))
:render-fn render-item}]]))
2 changes: 2 additions & 0 deletions src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,5 @@
(def ^:const status-hostname "status.app")

(def ^:const community-joined-notification-type "communityJoined")

(def ^:const default-telemetry-server-url "https://telemetry.status.im")
6 changes: 6 additions & 0 deletions src/status_im/contexts/profile/settings/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
:params [{:enabled new-value}]
:on-error #(log/error "failed to toggle peer syncing" new-value %)}]]]})))

(rf/reg-event-fx :profile.settings/toggle-telemetry
(fn [{:keys [db]}]
(let [value (get-in db [:profile/profile :telemetry-server-url])
new-value (if (string/blank? value) constants/default-telemetry-server-url "")]
{:dispatch [:profile.settings/profile-update :telemetry-server-url new-value]})))

(rf/reg-event-fx :profile.settings/change-appearance
(fn [_ [theme]]
{:fx [[:dispatch [:profile.settings/profile-update :appearance theme]]
Expand Down
6 changes: 6 additions & 0 deletions src/status_im/subs/profile.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
(fn [profile]
(get-in profile [:wakuv2-config :LightClient])))

(re-frame/reg-sub
:profile/telemetry-enabled?
:<- [:profile/profile]
(fn [profile]
(not (string/blank? (:telemetry-server-url profile)))))

(re-frame/reg-sub
:profile/test-networks-enabled?
:<- [:profile/profile]
Expand Down

0 comments on commit dc75587

Please sign in to comment.