Add a setting to enable telemetry #19811 (#19858)

This commit is contained in:
flexsurfer 2024-05-02 06:31:27 +02:00 committed by GitHub
parent a094d218d5
commit 86c1dbd25d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 38 additions and 38 deletions

View File

@ -16,10 +16,9 @@
(defn- normal-mode-settings-data (defn- normal-mode-settings-data
[{:keys [current-log-level [{:keys [current-log-level
telemetry-enabled?
light-client-enabled? light-client-enabled?
transactions-management-enabled?
current-fleet current-fleet
webview-debug
test-networks-enabled? test-networks-enabled?
is-goerli-enabled? is-goerli-enabled?
peer-syncing-enabled?]}] peer-syncing-enabled?]}]
@ -61,6 +60,14 @@
:on-press :on-press
#(re-frame/dispatch [:open-modal :peers-stats]) #(re-frame/dispatch [:open-modal :peers-stats])
:chevron true} :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 {:size :small
:title (i18n/label :t/light-client-enabled) :title (i18n/label :t/light-client-enabled)
:accessibility-label :light-client-enabled :accessibility-label :light-client-enabled
@ -70,25 +77,6 @@
[:wakuv2.ui/toggle-light-client (not light-client-enabled?)]) [:wakuv2.ui/toggle-light-client (not light-client-enabled?)])
:accessory :switch :accessory :switch
:active light-client-enabled?} :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 {:size :small
:title "Testnet mode" :title "Testnet mode"
:accessibility-label :test-networks-enabled :accessibility-label :test-networks-enabled
@ -126,14 +114,13 @@
(views/defview advanced-settings (views/defview advanced-settings
[] []
(views/letsubs [test-networks-enabled? [:profile/test-networks-enabled?] (views/letsubs [test-networks-enabled? [:profile/test-networks-enabled?]
is-goerli-enabled? [:profile/is-goerli-enabled?] is-goerli-enabled? [:profile/is-goerli-enabled?]
light-client-enabled? [:profile/light-client-enabled?] light-client-enabled? [:profile/light-client-enabled?]
webview-debug [:profile/webview-debug] telemetry-enabled? [:profile/telemetry-enabled?]
transactions-management-enabled? [:wallet-legacy/transactions-management-enabled?] current-log-level [:log-level/current-log-level]
current-log-level [:log-level/current-log-level] current-fleet [:fleets/current-fleet]
current-fleet [:fleets/current-fleet] peer-syncing-enabled? [:profile/peer-syncing-enabled?]]
peer-syncing-enabled? [:profile/peer-syncing-enabled?]]
[:<> [:<>
[quo/page-nav [quo/page-nav
{:type :title {:type :title
@ -143,14 +130,13 @@
:on-press #(rf/dispatch [:navigate-back])}] :on-press #(rf/dispatch [:navigate-back])}]
[list/flat-list [list/flat-list
{:data (flat-list-data {:data (flat-list-data
{:current-log-level current-log-level {:current-log-level current-log-level
:transactions-management-enabled? transactions-management-enabled? :telemetry-enabled? telemetry-enabled?
:light-client-enabled? light-client-enabled? :light-client-enabled? light-client-enabled?
:current-fleet current-fleet :current-fleet current-fleet
:dev-mode? false :dev-mode? false
:webview-debug webview-debug :test-networks-enabled? test-networks-enabled?
:test-networks-enabled? test-networks-enabled? :is-goerli-enabled? is-goerli-enabled?
:is-goerli-enabled? is-goerli-enabled? :peer-syncing-enabled? peer-syncing-enabled?})
:peer-syncing-enabled? peer-syncing-enabled?})
:key-fn (fn [_ i] (str i)) :key-fn (fn [_ i] (str i))
:render-fn render-item}]])) :render-fn render-item}]]))

View File

@ -493,3 +493,5 @@
(def ^:const status-hostname "status.app") (def ^:const status-hostname "status.app")
(def ^:const community-joined-notification-type "communityJoined") (def ^:const community-joined-notification-type "communityJoined")
(def ^:const default-telemetry-server-url "https://telemetry.status.im")

View File

@ -86,6 +86,12 @@
:params [{:enabled new-value}] :params [{:enabled new-value}]
:on-error #(log/error "failed to toggle peer syncing" 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 (rf/reg-event-fx :profile.settings/change-appearance
(fn [_ [theme]] (fn [_ [theme]]
{:fx [[:dispatch [:profile.settings/profile-update :appearance theme]] {:fx [[:dispatch [:profile.settings/profile-update :appearance theme]]

View File

@ -87,6 +87,12 @@
(fn [profile] (fn [profile]
(get-in profile [:wakuv2-config :LightClient]))) (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 (re-frame/reg-sub
:profile/test-networks-enabled? :profile/test-networks-enabled?
:<- [:profile/profile] :<- [:profile/profile]