Cherry pick to release branch (#20963)

This commit is contained in:
Jamie Caprani 2024-08-06 15:43:10 +01:00 committed by GitHub
parent 05279c111e
commit 254717971e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 117 additions and 42 deletions

View File

@ -53,4 +53,3 @@
#(rf/dispatch [:profile.login/login-with-biometric-if-available #(rf/dispatch [:profile.login/login-with-biometric-if-available
(get-in db [:profile/login :key-uid])])) (get-in db [:profile/login :key-uid])]))
:shell? true}]]]}))) :shell? true}]]]})))

View File

@ -3,37 +3,61 @@
[legacy.status-im.utils.build :as build] [legacy.status-im.utils.build :as build]
[react-native.platform :as platform])) [react-native.platform :as platform]))
(defn user-journey-event (defn key-value-event
[action] [event-name val-key value]
{:metric {:metric
{:eventName "user-journey" {:eventName event-name
:platform platform/os :platform platform/os
:appVersion build/app-short-version :appVersion build/app-short-version
:eventValue {:action action}}}) :eventValue {val-key value}}})
(defn user-journey-event
[action]
(key-value-event "user-journey" :action action))
(defn navigation-event
[view-id]
(key-value-event "navigation" :viewId view-id))
(def ^:const app-started-event "app-started") (def ^:const app-started-event "app-started")
(def ^:const navigate-to-create-profile-event "navigate-to-create-profile")
(def ^:const communities-tab-clicked "communities-tab-clicked") (def ^:const view-ids-to-track
(def ^:const wallet-tab-clicked "wallet-tab-clicked") #{;; Tabs
(def ^:const chats-tab-clicked "chats-tab-clicked") :communities-stack
:chats-stack
:wallet-stack
;; Onboarding
:screen/onboarding.intro
:screen/onboarding.new-to-status
:screen/onboarding.sync-or-recover-profile
:screen/onboarding.enter-seed-phrase
:screen/onboarding.create-profile
:screen/onboarding.create-profile-password
:screen/onboarding.enable-biometrics
:screen/onboarding.generating-keys
:screen/onboarding.enable-notifications
:screen/onboarding.sign-in-intro
:screen/onboarding.sign-in
:screen/onboarding.syncing-progress
:screen/onboarding.syncing-progress-intro
:screen/onboarding.syncing-results
:screen/onboarding.welcome})
(defn track-view-id-event (defn track-view-id-event
[view-id] [view-id]
(case view-id (when (contains? view-ids-to-track view-id)
:communities-stack (user-journey-event communities-tab-clicked) (navigation-event (name view-id))))
:chats-stack (user-journey-event chats-tab-clicked)
:wallet-stack (user-journey-event wallet-tab-clicked)
nil))
(defn tracked-event (defn tracked-event
[[event-name second-parameter]] [[event-name second-parameter]]
(case event-name (case event-name
:onboarding/navigate-to-create-profile
(user-journey-event navigate-to-create-profile-event)
:profile/get-profiles-overview-success :profile/get-profiles-overview-success
(user-journey-event app-started-event) (user-journey-event app-started-event)
:centralized-metrics/toggle-centralized-metrics
(key-value-event "events.metrics-enabled" :enabled second-parameter)
:set-view-id :set-view-id
(track-view-id-event second-parameter) (track-view-id-event second-parameter)

View File

@ -5,31 +5,75 @@
[react-native.platform :as platform] [react-native.platform :as platform]
[status-im.contexts.centralized-metrics.tracking :as tracking])) [status-im.contexts.centralized-metrics.tracking :as tracking]))
(def platform-os platform/os)
(def app-version build/app-short-version)
(deftest key-value-event-test
(testing "creates correct key-value event"
(let [event-name "test-event"
val-key :test-key
value "test-value"
expected {:metric
{:eventName event-name
:platform platform-os
:appVersion app-version
:eventValue {val-key value}}}]
(is (= expected (tracking/key-value-event event-name val-key value))))))
(deftest user-journey-event-test (deftest user-journey-event-test
(testing "creates correct metric event" (testing "creates correct user journey event"
(let [action "some-action" (let [action "test-action"
expected {:metric {:eventName "user-journey" expected {:metric
:platform platform/os {:eventName "user-journey"
:appVersion build/app-short-version :platform platform-os
:eventValue {:action action}}}] :appVersion app-version
:eventValue {:action action}}}]
(is (= expected (tracking/user-journey-event action)))))) (is (= expected (tracking/user-journey-event action))))))
(deftest navigation-event-test
(testing "creates correct navigation event"
(let [view-id :test-view-id
expected {:metric
{:eventName "navigation"
:platform platform-os
:appVersion app-version
:eventValue {:viewId view-id}}}]
(is (= expected (tracking/navigation-event view-id))))))
(deftest track-view-id-event-test (deftest track-view-id-event-test
(testing "returns correct event for view-id" (testing "returns correct navigation event for view-id"
(is (= (tracking/user-journey-event tracking/communities-tab-clicked) (is (= {:metric
{:eventName "navigation"
:platform platform-os
:appVersion app-version
:eventValue {:viewId "communities-stack"}}}
(tracking/track-view-id-event :communities-stack))) (tracking/track-view-id-event :communities-stack)))
(is (= (tracking/user-journey-event tracking/chats-tab-clicked) (is (= {:metric
(tracking/track-view-id-event :chats-stack))) {:eventName "navigation"
(is (= (tracking/user-journey-event tracking/wallet-tab-clicked) :platform platform-os
(tracking/track-view-id-event :wallet-stack))) :appVersion app-version
:eventValue {:viewId "onboarding.create-profile"}}}
(tracking/track-view-id-event :screen/onboarding.create-profile)))
(is (nil? (tracking/track-view-id-event :unknown-stack))))) (is (nil? (tracking/track-view-id-event :unknown-stack)))))
(deftest tracked-event-test (deftest tracked-event-test
(testing "returns correct event for given inputs" (testing "returns correct event for given inputs"
(is (= (tracking/user-journey-event tracking/navigate-to-create-profile-event) (is (= {:metric
(tracking/tracked-event [:onboarding/navigate-to-create-profile]))) {:eventName "user-journey"
(is (= (tracking/user-journey-event tracking/app-started-event) :platform platform-os
:appVersion app-version
:eventValue {:action tracking/app-started-event}}}
(tracking/tracked-event [:profile/get-profiles-overview-success]))) (tracking/tracked-event [:profile/get-profiles-overview-success])))
(is (= (tracking/track-view-id-event :wallet-stack) (is (= {:metric
{:eventName "events.metrics-enabled"
:platform platform-os
:appVersion app-version
:eventValue {:enabled true}}}
(tracking/tracked-event [:centralized-metrics/toggle-centralized-metrics true])))
(is (= {:metric
{:eventName "navigation"
:platform platform-os
:appVersion app-version
:eventValue {:viewId "wallet-stack"}}}
(tracking/tracked-event [:set-view-id :wallet-stack]))) (tracking/tracked-event [:set-view-id :wallet-stack])))
(is (nil? (tracking/tracked-event [:unknown-event]))))) (is (nil? (tracking/tracked-event [:unknown-event])))))

View File

@ -21,12 +21,13 @@
:label (i18n/label :t/add-account) :label (i18n/label :t/add-account)
:sub-label (i18n/label :t/add-account-description) :sub-label (i18n/label :t/add-account-description)
:on-press #(rf/dispatch [:navigate-to :screen/wallet.create-account])} :on-press #(rf/dispatch [:navigate-to :screen/wallet.create-account])}
{:icon :i/reveal (when (ff/enabled? ::ff/wallet.add-watched-address)
:accessibility-label :add-a-contact {:icon :i/reveal
:label (i18n/label :t/add-address-to-watch) :accessibility-label :add-a-contact
:sub-label (i18n/label :t/add-address-to-watch-description) :label (i18n/label :t/add-address-to-watch)
:on-press #(rf/dispatch [:navigate-to :screen/wallet.add-address-to-watch]) :sub-label (i18n/label :t/add-address-to-watch-description)
:add-divider? true}]]]) :on-press #(rf/dispatch [:navigate-to :screen/wallet.add-address-to-watch])
:add-divider? true})]]])
(defn- new-account-card-data (defn- new-account-card-data
[] []

View File

@ -205,7 +205,7 @@
{:db (cond-> db {:db (cond-> db
:always (update-in [:wallet :ui :send] :always (update-in [:wallet :ui :send]
#(-> % #(-> %
(dissoc :collectible) (dissoc :collectible :tx-type)
(assoc :token-not-supported-in-receiver-networks? (assoc :token-not-supported-in-receiver-networks?
unsupported-token?))) unsupported-token?)))
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol) token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol)
@ -217,6 +217,11 @@
entry-point (assoc-in [:wallet :ui :send :entry-point] entry-point)) entry-point (assoc-in [:wallet :ui :send :entry-point] entry-point))
:fx [[:dispatch [:wallet/clean-suggested-routes]] :fx [[:dispatch [:wallet/clean-suggested-routes]]
[:dispatch [:dispatch
;; ^:flush-dom allows us to make sure the re-frame DB state is always synced
;; before the navigation occurs, so the new screen is always rendered with
;; the DB state set by this event. By adding the metadata we are omitting
;; a 1-frame blink when the screen is mounted.
^:flush-dom
[:wallet/wizard-navigate-forward [:wallet/wizard-navigate-forward
{:current-screen stack-id {:current-screen stack-id
:start-flow? start-flow? :start-flow? start-flow?

View File

@ -22,6 +22,7 @@
:FLAG_WALLET_SETTINGS_IMPORT_ALL_KEYPAIRS) :FLAG_WALLET_SETTINGS_IMPORT_ALL_KEYPAIRS)
::shell.jump-to (enabled-in-env? :ENABLE_JUMP_TO) ::shell.jump-to (enabled-in-env? :ENABLE_JUMP_TO)
::wallet.add-watched-address (enabled-in-env? :FLAG_ADD_WATCHED_ADDRESS)
::wallet.advanced-sending (enabled-in-env? :FLAG_ADVANCED_SENDING) ::wallet.advanced-sending (enabled-in-env? :FLAG_ADVANCED_SENDING)
::wallet.assets-modal-hide (enabled-in-env? :FLAG_ASSETS_MODAL_HIDE) ::wallet.assets-modal-hide (enabled-in-env? :FLAG_ASSETS_MODAL_HIDE)
::wallet.assets-modal-manage-tokens (enabled-in-env? :FLAG_ASSETS_MODAL_MANAGE_TOKENS) ::wallet.assets-modal-manage-tokens (enabled-in-env? :FLAG_ASSETS_MODAL_MANAGE_TOKENS)

View File

@ -4,6 +4,6 @@
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "release/0.182.x", "version": "release/0.182.x",
"commit-sha1": "7e87fd0d059539abc0f9525b4347e5926783b762", "commit-sha1": "8ff95326c49b06b4bc0bbf01a4dea1dab96945a5",
"src-sha256": "0i9jij2vkh055m522x1ivv80b5q0qbq3rbh9m6xhah31jx5kwnwh" "src-sha256": "1nwa21n6r831b28qcl7n4fx5v0qmrihiazzirsxca3x0xw3x4caj"
} }

View File

@ -240,6 +240,7 @@ class TestWalletOneDevice(MultipleSharedDeviceTestCase):
self.errors.verify_no_errors() self.errors.verify_no_errors()
@marks.testrail_id(727232) @marks.testrail_id(727232)
@marks.skip("The feature is disabled in https://github.com/status-im/status-mobile/pull/20955")
@marks.xfail(reason="Missing networks in account address, https://github.com/status-im/status-mobile/issues/20166") @marks.xfail(reason="Missing networks in account address, https://github.com/status-im/status-mobile/issues/20166")
def test_wallet_add_remove_watch_only_account(self): def test_wallet_add_remove_watch_only_account(self):
self.wallet_view.just_fyi("Adding new watch only account") self.wallet_view.just_fyi("Adding new watch only account")