[#21035] Allow users to independently enable Waku telemetry and in-ap… (#21168)

This commit is contained in:
flexsurfer 2024-09-16 16:22:18 +02:00 committed by GitHub
parent cdb2370cf3
commit 85b5445296
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 234 additions and 124 deletions

View File

@ -13,17 +13,19 @@
(native-module/logout)))
(rf/defn initialize-app-db
[{{:keys [keycard initials-avatar-font-file biometrics]
:network/keys [type status expensive?]}
[{{:keys [keycard initials-avatar-font-file biometrics]
:network/keys [type status expensive?]
:centralized-metrics/keys [user-confirmed?]}
:db}]
{:db (assoc db/app-db
:network/type type
:network/status status
:network/expensive? expensive?
:initials-avatar-font-file initials-avatar-font-file
:keycard (dissoc keycard :secrets :pin :application-info)
:biometrics biometrics
:syncing nil)})
:centralized-metrics/user-confirmed? user-confirmed?
:network/type type
:network/status status
:network/expensive? expensive?
:initials-avatar-font-file initials-avatar-font-file
:keycard (dissoc keycard :secrets :pin :application-info)
:biometrics biometrics
:syncing nil)})
(rf/defn logout-method
{:events [::logout-method]}

View File

@ -5,7 +5,6 @@
[legacy.status-im.ui.components.list.views :as list]
[quo.core :as quo]
[re-frame.core :as re-frame]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf])
(:require-macros [legacy.status-im.utils.views :as views]))
@ -17,7 +16,6 @@
(defn- normal-mode-settings-data
[{:keys [current-log-level
telemetry-enabled?
light-client-enabled?
store-confirmations-enabled?
current-fleet
@ -60,14 +58,6 @@
:on-press
#(re-frame/dispatch [:open-modal :peers-stats])
:chevron true}
(when (ff/enabled? ::ff/settings.telemetry)
{: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
@ -109,7 +99,6 @@
[]
(views/letsubs [light-client-enabled? [:profile/light-client-enabled?]
store-confirmations-enabled? [:profile/store-confirmations-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?]]
@ -123,7 +112,6 @@
[list/flat-list
{:data (flat-list-data
{:current-log-level current-log-level
:telemetry-enabled? telemetry-enabled?
:light-client-enabled? light-client-enabled?
:store-confirmations-enabled? store-confirmations-enabled?
:current-fleet current-fleet

View File

@ -46,11 +46,14 @@
(let [theme (quo.theme/use-theme)]
[rn/view {:style (style/container container-style)}
[rn/view {:style style/index}
(if (= type :step)
(case type
:step
[step/view
{:in-blur-view? blur?
:customization-color customization-color
:type (if customization-color :complete :neutral)} step-number]
:lock
[icon/icon :i/locked {:color (get-colors theme blur?)}]
[icon/icon :i/bullet {:color (get-colors theme blur?)}])]
[rn/view {:style style/text-container}
(when title

View File

@ -5,9 +5,7 @@
(def container
{:padding-horizontal 12
:padding-top 12
:padding-bottom 14
:flex-direction :row
:justify-content :space-between})
:padding-bottom 14})
(defn left-sub-container
[{:keys [tag description]}]

View File

@ -108,20 +108,25 @@
nil)])
(defn view
[{:keys [title on-press action-props accessibility-label blur? container-style] :as props}]
[{:keys [title on-press action-props accessibility-label blur? container-style content] :as props}]
[rn/pressable
{:style (merge style/container container-style)
:on-press (or on-press (:on-change action-props))
:accessibility-label accessibility-label}
[rn/view {:style (style/left-sub-container props)}
[image-component props]
[rn/view {:style (style/left-container (:image props))}
[text/text
{:weight :medium
:style {:color (when blur? colors/white)}}
title]
[description-component props]
[tag-component props]]]
[rn/view {:style (style/sub-container (:alignment action-props))}
[label-component props]
[action-component props]]])
[rn/view
{:style {:flex-direction :row
:justify-content :space-between}}
[rn/view {:style (style/left-sub-container props)}
[image-component props]
[rn/view {:style (style/left-container (:image props))}
[text/text
{:weight :medium
:style {:color (when blur? colors/white)}}
title]
[description-component props]
[tag-component props]]]
[rn/view {:style (style/sub-container (:alignment action-props))}
[label-component props]
[action-component props]]]
(when content
content)])

View File

@ -17,14 +17,16 @@
[]
(rf/dispatch [:hide-bottom-sheet]))
(defn- toggle-metrics
[enabled?]
(rf/dispatch [:centralized-metrics/toggle-centralized-metrics enabled?]))
(def ^:private will-receive-for-current-points
[:t/number-of-messages-sent
:t/connected-peers
:t/successful-messages-rate
:t/connection-type
:t/os-app-version-bandwidth])
(def ^:private will-receive-points
[:t/ip-address
:t/universally-unique-identifiers-of-device
:t/logs-of-actions-withing-the-app])
(def ^:private will-receive-for-all-points
[:t/action-logs
:t/ip-addresses-uuid])
(def ^:private not-receive-points
[:t/your-profile-information
@ -32,7 +34,7 @@
:t/information-you-input-and-send])
(defn- bullet-points
[{:keys [title points]}]
[{:keys [title points lock?]}]
[rn/view
[quo/text {:weight :semi-bold}
title]
@ -41,37 +43,36 @@
[quo/markdown-list
{:description (i18n/label label)
:blur? true
:type (when lock? :lock)
:container-style style/item-text}])])
(defn- on-share-usage
[]
(toggle-metrics true)
(rf/dispatch [:centralized-metrics/toggle-centralized-metrics true true])
(hide-bottom-sheet))
(defn- on-do-not-share
[]
(toggle-metrics false)
(rf/dispatch [:centralized-metrics/toggle-centralized-metrics false true])
(hide-bottom-sheet))
(declare view)
(defn- on-privacy-policy-press
[settings?]
[]
(rf/dispatch
[:show-bottom-sheet
{:content (fn []
[quo.theme/provider :dark
[privacy/privacy-statement]])
{:content privacy/privacy-statement
:on-close (fn []
(rf/dispatch [:show-bottom-sheet
{:content (fn []
[quo.theme/provider :dark
[view {:settings? settings?}]])
{:content view
:theme :dark
:shell? true}]))
:theme :dark
:shell? true}]))
(defn- privacy-policy-text
[settings?]
[]
[rn/view {:style style/privacy-policy}
[quo/text
[quo/text
@ -81,39 +82,38 @@
[quo/text
{:size :paragraph-2
:weight :bold
:on-press #(on-privacy-policy-press settings?)}
:on-press on-privacy-policy-press}
(i18n/label :t/more-details-in-privacy-policy-2)]]])
(defn view
[{:keys [settings?]}]
[]
(rn/use-mount #(dismiss-keyboard))
[:<>
[quo/drawer-top
{:title (i18n/label :t/help-us-improve-status)
:description (i18n/label :t/collecting-usage-data)}]
[rn/view {:style style/points-wrapper}
[bullet-points
{:title (i18n/label :t/what-we-will-receive)
:points will-receive-points}]
[bullet-points
{:title (i18n/label :t/what-we-wont-receive)
:points not-receive-points}]
(if settings?
[quo/text
{:size :paragraph-2
:style style/info-text}
(i18n/label :t/usage-data-shared-from-all-profiles)]
[quo/text
{:size :paragraph-2
:style style/info-text}
(i18n/label :t/usage-data-shared-from-all-profiles)
(i18n/label :t/sharing-usage-data-can-be-turned-off)])]
[rn/scroll-view
[rn/view {:style style/points-wrapper}
[bullet-points
{:title (i18n/label :t/we-will-receive-from-all-profiles)
:points will-receive-for-all-points}]
[bullet-points
{:title (i18n/label :t/we-will-receive-from-the-current-profile)
:points will-receive-for-current-points}]
[bullet-points
{:title (i18n/label :t/what-we-wont-receive)
:points not-receive-points
:lock? true}]
[quo/text
{:size :paragraph-2
:style style/info-text}
(i18n/label :t/sharing-usage-data-can-be-turned-off)]]]
[quo/bottom-actions
{:actions :two-actions
:blur? true
:button-one-label (i18n/label :t/share-usage-data)
:button-one-label (i18n/label :t/help-us-improve-status)
:button-one-props {:on-press on-share-usage}
:button-two-label (i18n/label :t/not-now)
:button-two-props {:type :grey
:on-press on-do-not-share}}]
[privacy-policy-text settings?]])
[privacy-policy-text]])

View File

@ -7,17 +7,10 @@
[taoensso.timbre :as log]
[utils.re-frame :as rf]))
(def ^:const user-confirmed-key :centralized-metrics/user-confirmed?)
(def ^:const enabled-key :centralized-metrics/enabled?)
(defn show-confirmation-modal?
[db]
(not (user-confirmed-key db)))
(defn push-event?
[db]
(or (not (user-confirmed-key db))
(enabled-key db)))
(or (not (:centralized-metrics/user-confirmed? db))
(:centralized-metrics/enabled? db)))
(defn centralized-metrics-interceptor
[context]
@ -33,17 +26,16 @@
:after centralized-metrics-interceptor))
(rf/reg-event-fx :centralized-metrics/toggle-centralized-metrics
(fn [{:keys [db]} [enabled?]]
(fn [{:keys [db]} [enabled? onboarding?]]
{:fx [[:effects.centralized-metrics/toggle-metrics enabled?]]
:db (assoc db
user-confirmed-key
true
enabled-key
enabled?)}))
:db (-> db
(assoc :centralized-metrics/user-confirmed? true)
(assoc :centralized-metrics/enabled? enabled?)
(assoc :centralized-metrics/onboarding-enabled? (and onboarding? enabled?)))}))
(rf/reg-event-fx :centralized-metrics/check-modal
(fn [{:keys [db]} [modal-view]]
(when (show-confirmation-modal? db)
(when-not (:centralized-metrics/user-confirmed? db)
{:fx [[:dispatch
[:show-bottom-sheet
{:content (fn [] [modal-view])

View File

@ -6,11 +6,6 @@
[status-im.contexts.centralized-metrics.tracking :as tracking]
[test-helpers.unit :as h]))
(deftest show-confirmation-modal-test
(testing "returns true if the user confirmed"
(is (false? (events/show-confirmation-modal? {events/user-confirmed-key true})))
(is (true? (events/show-confirmation-modal? {})))))
(deftest push-event-test
(testing "returns correct boolean value"
(is (true? (events/push-event? {:centralized-metrics/user-confirmed? false})))

View File

@ -47,8 +47,8 @@
(- window-height
(* 2 56) ;; two other list items
(* 2 16) ;; spacing between items
220) ;; extra spacing (top bar)
)
220)) ;; extra spacing (top bar)
(defn- create-profile-option-card
[window-height]

View File

@ -15,7 +15,8 @@
{:key :type
:type :select
:options [{:key :bullet}
{:key :step}]}
{:key :step}
{:key :lock}]}
(preview/customization-color-option)])
(defn view

View File

@ -48,7 +48,8 @@
:profile/profile (merge profile-overview
settings
{:log-level log-level}))
(assoc-in [:activity-center :loading?] true))
(assoc-in [:activity-center :loading?] true)
(dissoc :centralized-metrics/onboarding-enabled?))
pairing-completed?
(dissoc :syncing))
:fx (into [[:json-rpc/call
@ -72,7 +73,10 @@
;; messenger has started and has processed all chats because
;; the whole process can take a handful of seconds.
(when-not (:universal-links/handling db)
[:effects.chat/open-last-chat (:key-uid profile-overview)])]
[:effects.chat/open-last-chat (:key-uid profile-overview)])
(when (:centralized-metrics/onboarding-enabled? db)
[:dispatch [:profile.settings/toggle-telemetry true]])]
(cond
pairing-completed?

View File

@ -87,9 +87,11 @@
: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 "")]
(fn [{:keys [db]} [enable?]]
(let [enable? (if (nil? enable?)
(string/blank? (get-in db [:profile/profile :telemetry-server-url]))
enable?)
new-value (if enable? constants/default-telemetry-server-url "")]
{:dispatch [:profile.settings/profile-update :telemetry-server-url new-value]})))
(rf/reg-event-fx :profile.settings/change-appearance

View File

@ -0,0 +1,115 @@
(ns status-im.contexts.settings.privacy-and-security.share-usage.view
(:require
[quo.core :as quo]
[quo.foundations.colors :as colors]
[quo.theme]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.common.events-helper :as events-helper]
[status-im.common.privacy.view :as privacy]
[status-im.contexts.settings.privacy-and-security.style :as privacy-and-security.style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(def ^:private network-behavior-points
[:t/number-of-messages-sent
:t/connected-peers
:t/successful-messages-rate
:t/connection-type
:t/os-app-version-bandwidth])
(def ^:private app-interactions-points
[:t/action-logs
:t/ip-addresses-uuid])
(def ^:private not-receive-points
[:t/your-profile-information
:t/your-addresses
:t/information-you-input-and-send])
(defn- get-category-data
[{:keys [title description points on-toggle toggle-checked? lock?]}]
{:title title
:description (when description :text)
:description-props (when description {:text description})
:blur? true
:action (when on-toggle :selector)
:action-props (when on-toggle
{:on-change on-toggle
:checked? toggle-checked?})
:content [rn/view {:style {:margin-top 8}}
(for [label points]
^{:key label}
[quo/markdown-list
{:description (i18n/label label)
:blur? true
:type (when lock? :lock)
:container-style {:padding-top 8}}])]})
(defn- on-privacy-policy-press
[]
(rf/dispatch
[:show-bottom-sheet
{:content (fn []
[quo.theme/provider :dark
[privacy/privacy-statement]])
:shell? true}]))
(defn- privacy-policy-text
[]
[quo/text {:style {:text-align :center}}
[quo/text
{:style {:color colors/white-opa-50}
:size :paragraph-2}
(i18n/label :t/more-details-in-privacy-policy-settings-1)]
[quo/text
{:size :paragraph-2
:on-press on-privacy-policy-press}
(i18n/label :t/more-details-in-privacy-policy-2)]])
(defn view
[]
(let [insets (safe-area/get-insets)
telemetry-enabled? (rf/sub [:profile/telemetry-enabled?])
centralized-metrics-enabled? (rf/sub [:centralized-metrics/enabled?])]
[quo/overlay
{:type :shell
:container-style (privacy-and-security.style/page-wrapper (:top insets))}
[quo/page-nav
{:key :header
:background :blur
:icon-name :i/arrow-left
:on-press events-helper/navigate-back}]
[quo/page-top
{:title (i18n/label :t/share-usage-data)
:title-accessibility-label :title-label
:description :text
:description-text (i18n/label :t/collecting-usage-data)}]
[rn/scroll-view {:style {:flex 1}}
[quo/category
{:data [(get-category-data
{:toggle-checked? telemetry-enabled?
:on-toggle #(rf/dispatch [:profile.settings/toggle-telemetry])
:title (i18n/label :t/network-behavior)
:description (i18n/label :t/will-be-shared-from-the-current-profile)
:points network-behavior-points})
(get-category-data {:toggle-checked? centralized-metrics-enabled?
:on-toggle #(rf/dispatch
[:centralized-metrics/toggle-centralized-metrics
(not centralized-metrics-enabled?)])
:title (i18n/label :t/app-interactions)
:description (i18n/label :t/will-be-shared-from-all-profiles)
:points app-interactions-points})]
:blur? true
:list-type :settings}]
[quo/category
{:data [(get-category-data {:title (i18n/label :t/what-we-wont-receive)
:points not-receive-points
:lock? true})]
:blur? true
:list-type :settings}]]
[rn/view
{:align-items :center
:padding-horizontal 20
:padding-bottom (:bottom insets)}
[privacy-policy-text]]]))

View File

@ -6,7 +6,6 @@
[react-native.platform :as platform]
[react-native.safe-area :as safe-area]
[status-im.common.events-helper :as events-helper]
[status-im.common.metrics-confirmation-modal.view :as metrics-modal]
[status-im.contexts.settings.privacy-and-security.profile-picture.view :as profile-picture.view]
[status-im.contexts.settings.privacy-and-security.style :as style]
[status-im.feature-flags :as ff]
@ -25,19 +24,9 @@
:id :preview-privacy
:customization-color customization-color}})
(defn- on-share-usage-data-press
[]
(rf/dispatch
[:show-bottom-sheet
{:content (fn []
[quo.theme/provider :dark
[metrics-modal/view {:settings? true}]])
:shell? true}]))
(defn view
[]
(let [insets (safe-area/get-insets)
centralized-metrics-enabled? (rf/sub [:centralized-metrics/enabled?])
customization-color (rf/sub [:profile/customization-color])
preview-privacy? (rf/sub [:profile/preview-privacy?])
@ -95,13 +84,12 @@
show-profile-pictures-to
open-show-profile-pictures-to-options))
(setting-preview-privacy preview-privacy? customization-color toggle-preview-privacy)
{:title (i18n/label :t/share-usage-data-with-status)
{:title (i18n/label :t/share-usage-data)
:description :text
:description-props {:text (i18n/label :t/from-all-profiles-on-device)}
:blur? true
:action :selector
:action-props {:on-change on-share-usage-data-press
:customization-color customization-color
:checked? centralized-metrics-enabled?}}]
:action :arrow
:action-props {:on-change #(rf/dispatch [:open-modal
:screen/settings.share-usage-data])}}]
:blur? true
:list-type :settings}]]))

View File

@ -16,8 +16,6 @@
;; feature and we want both clients in sync. We keep the code because it
;; works and we may re-enable it by default.
::profile-pictures-visibility (enabled-in-env? :FLAG_PROFILE_PICTURES_VISIBILITY_ENABLED)
::settings.telemetry (enabled-in-env? :FLAG_TELEMETRY_ENABLED)
::settings.import-all-keypairs (enabled-in-env?
:FLAG_WALLET_SETTINGS_IMPORT_ALL_KEYPAIRS)
::shell.jump-to (enabled-in-env? :ENABLE_JUMP_TO)

View File

@ -60,6 +60,7 @@
[status-im.contexts.profile.settings.view :as settings]
[status-im.contexts.settings.language-and-currency.currency.view :as settings.currency-selection]
[status-im.contexts.settings.language-and-currency.view :as settings.language-and-currency]
[status-im.contexts.settings.privacy-and-security.share-usage.view :as settings.share-usage]
[status-im.contexts.settings.privacy-and-security.view :as settings.privacy-and-security]
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.encrypted-qr.view
:as encrypted-keypair-qr]
@ -646,6 +647,10 @@
:options options/transparent-modal-screen-options
:component settings.privacy-and-security/view}
{:name :screen/settings.share-usage-data
:options options/transparent-modal-screen-options
:component settings.share-usage/view}
{:name :screen/settings.language-and-currency
:options options/transparent-modal-screen-options
:component settings.language-and-currency/view}

View File

@ -34,6 +34,7 @@
"account-title": "Account",
"accounts": "Accounts",
"accounts-count": "{{count}} accounts",
"action-logs": "Logs of actions, including button presses and screen visits",
"actions": "Actions",
"active-members": "Active members",
"active-online": "Online",
@ -131,6 +132,7 @@
"anyone": "Anyone",
"app-commit": "App commit",
"app-connections": "App connections",
"app-interactions": "App interactions",
"appearance": "Appearance",
"apply": "Apply",
"apply-changes": "Apply changes",
@ -466,11 +468,13 @@
"connect-with-users": "Connect with users",
"connected": "Connected",
"connected-dapps": "Connected dApps",
"connected-peers": "Connected and discovered peers",
"connected-to": "Connected to",
"connecting": "Connecting...",
"connecting-requires-login": "Connecting to another network requires login",
"connection-request": "Connection Request",
"connection-status": "Connection status",
"connection-type": "Type of connection to peers",
"connection-with-the-card-lost": "Connection with the card\n has been lost",
"connection-with-the-card-lost-setup-text": "To resume the setup hold the card to\n the back of your phone and maintain\n card to phone contact",
"connection-with-the-card-lost-text": "To proceed hold the card to the back of your phone",
@ -1260,6 +1264,7 @@
"invite-warning": "This promotion is only valid for users of an Android device, who aren't residents of US. Friend needs to confirm referral within 7 days",
"invited": "invited",
"ip-address": "IP address",
"ip-addresses-uuid": "IP addresses and UUID",
"italic": "Italic",
"jan": "Jan",
"join": "Join",
@ -1579,6 +1584,7 @@
"more": "more",
"more-details-in-privacy-policy-1": "For more details refer to our ",
"more-details-in-privacy-policy-2": "Privacy Policy",
"more-details-in-privacy-policy-settings-1": "For details on this and other potential limited data processing by Status, see our ",
"move-and-reset": "Move and Reset",
"move-keystore-file": "Move keystore file",
"move-keystore-file-to-keycard": "Move keystore file to keycard?",
@ -1624,6 +1630,7 @@
"need-help": "Need help?",
"negative": "Negative",
"network": "Network",
"network-behavior": "Network behavior",
"network-chain": "Network chain",
"network-fee": "Network fee",
"network-id": "Network ID",
@ -1742,6 +1749,7 @@
"notify": "Notify",
"nov": "Nov",
"now": "Now",
"number-of-messages-sent": "Number of messages sent to you",
"oct": "Oct",
"off": "Off",
"off-status-tree": "Off Status tree",
@ -1800,6 +1808,7 @@
"origin": "Origin",
"origin-desc": "Origin is where your key pair (your private and public key) comes from. You can generate a new key pair or import an existing private key.",
"origin-header": "Origin",
"os-app-version-bandwidth": "OS, app version and bandwidth usage",
"outgoing": "Outgoing",
"outgoing-transaction": "Outgoing transaction",
"overview": "Overview",
@ -2363,6 +2372,7 @@
"submit-bug": "Submit a bug",
"success": "Success",
"successful-connection": "Successful Connection",
"successful-messages-rate": "Rate of successfully sent messages",
"suggested-min-tip": "Suggested min. tip",
"suggested-price-limit": "Suggested price limit",
"sun": "Sun",
@ -2713,6 +2723,8 @@
"wc-how-to-use-status-app": "How to use the Status app including privacy and security",
"wc-new-tos-based-on-principles-prefix": "New Terms of Use designed based on our",
"we": "We",
"we-will-receive-from-all-profiles": "We will receive from all profiles:",
"we-will-receive-from-the-current-profile": "We will receive from the current profile:",
"web-view-error": "Unable to load page",
"websites": "Websites",
"webview-camera-permission-requests": "Webview camera permission requests",
@ -2738,6 +2750,8 @@
"who-are-you-looking-for": "Who are you looking for ?",
"wifi-and-mobile-data": "Wi-Fi and mobile data",
"wifi-only": "Wi-Fi only",
"will-be-shared-from-all-profiles": "Will be shared from all profiles on device",
"will-be-shared-from-the-current-profile": "Will be shared from the current profile",
"with-full-encryption": "With full metadata privacy and e2e encryption",
"word-count": "Word count",
"word-n": "Word #{{number}}",