From 86c1dbd25d58f6fea569115525b0ff0b257c5935 Mon Sep 17 00:00:00 2001 From: flexsurfer Date: Thu, 2 May 2024 06:31:27 +0200 Subject: [PATCH] Add a setting to enable telemetry #19811 (#19858) --- .../ui/screens/advanced_settings/views.cljs | 62 +++++++------------ src/status_im/constants.cljs | 2 + .../contexts/profile/settings/events.cljs | 6 ++ src/status_im/subs/profile.cljs | 6 ++ 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/legacy/status_im/ui/screens/advanced_settings/views.cljs b/src/legacy/status_im/ui/screens/advanced_settings/views.cljs index 39b532f304..8f44a38b26 100644 --- a/src/legacy/status_im/ui/screens/advanced_settings/views.cljs +++ b/src/legacy/status_im/ui/screens/advanced_settings/views.cljs @@ -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?]}] @@ -61,6 +60,14 @@ :on-press #(re-frame/dispatch [:open-modal :peers-stats]) :chevron true} + {:size :small + :title "Telemetry" + :accessibility-label :telemetry-enabled + :container-margin-bottom 8 + :on-press + #(re-frame/dispatch [:profile.settings/toggle-telemetry]) + :accessory :switch + :active telemetry-enabled?} {:size :small :title (i18n/label :t/light-client-enabled) :accessibility-label :light-client-enabled @@ -70,25 +77,6 @@ [: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 - :container-margin-bottom 8 - :on-press - #(re-frame/dispatch - [:multiaccounts.ui/switch-transactions-management-enabled - (not transactions-management-enabled?)]) - :accessory :switch - :active transactions-management-enabled?} - {:size :small - :title "Webview debug" - :accessibility-label :webview-debug-switch - :container-margin-bottom 8 - :on-press - #(re-frame/dispatch - [:profile.settings/change-webview-debug (not webview-debug)]) - :accessory :switch - :active webview-debug} {:size :small :title "Testnet mode" :accessibility-label :test-networks-enabled @@ -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 @@ -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}]])) diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index c8744f941b..ded6ae10b0 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -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") diff --git a/src/status_im/contexts/profile/settings/events.cljs b/src/status_im/contexts/profile/settings/events.cljs index cccac1f8c6..6126114e72 100644 --- a/src/status_im/contexts/profile/settings/events.cljs +++ b/src/status_im/contexts/profile/settings/events.cljs @@ -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]] diff --git a/src/status_im/subs/profile.cljs b/src/status_im/subs/profile.cljs index fc66578d65..1f38431fd2 100644 --- a/src/status_im/subs/profile.cljs +++ b/src/status_im/subs/profile.cljs @@ -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]