From 55ee800e18b8ac81857a001837673e6aaf52e824 Mon Sep 17 00:00:00 2001 From: Sean Hagstrom Date: Thu, 12 Dec 2024 09:21:09 -0800 Subject: [PATCH] feature: add keycard metric events (#21794) This change adds some metrics events for tracking when keycard users have reached an unavailable feature, when keycard users have successfully logged in, and when keycard users have succeeded or failed to migrate to keycard. --- .../centralized_metrics/tracking.cljs | 8 ++++++- .../actions/request_to_join/view.cljs | 3 ++- .../contexts/communities/overview/view.cljs | 3 ++- .../keycard/feature_unavailable/events.cljs | 21 ++++++++++++++++--- .../keycard/feature_unavailable/view.cljs | 9 ++++---- .../contexts/profile/login/events.cljs | 7 +++++-- .../settings/screens/password/view.cljs | 4 +++- .../syncing/syncing_devices_list/view.cljs | 6 ++++-- .../wallet/common/account_switcher/view.cljs | 3 ++- .../events/session_proposals.cljs | 4 +++- 10 files changed, 50 insertions(+), 18 deletions(-) diff --git a/src/status_im/contexts/centralized_metrics/tracking.cljs b/src/status_im/contexts/centralized_metrics/tracking.cljs index c1d00bcd54..ac0d9102c4 100644 --- a/src/status_im/contexts/centralized_metrics/tracking.cljs +++ b/src/status_im/contexts/centralized_metrics/tracking.cljs @@ -53,7 +53,13 @@ (conj (navigation-event (name view-id))) (= :screen/onboarding.syncing-results view-id) - (conj (key-value-event "onboarding-completed"))))) + (conj (key-value-event "onboarding-completed")) + + (= :screen/keycard.migrate.success view-id) + (conj (key-value-event "keycard-migration-succeeded")) + + (= :screen/keycard.migrate.fail view-id) + (conj (key-value-event "keycard-migration-failed"))))) (defn navigated-to-collectibles-tab-event [location] diff --git a/src/status_im/contexts/communities/actions/request_to_join/view.cljs b/src/status_im/contexts/communities/actions/request_to_join/view.cljs index 41f4feb401..50860b8432 100644 --- a/src/status_im/contexts/communities/actions/request_to_join/view.cljs +++ b/src/status_im/contexts/communities/actions/request_to_join/view.cljs @@ -30,7 +30,8 @@ {:keys [color name images]} (rf/sub [:communities/community id]) keycard? (rf/sub [:keycard/keycard-profile?]) keycard-feature-unavailable (rn/use-callback - #(rf/dispatch [:keycard/feature-unavailable-show]))] + #(rf/dispatch [:keycard/feature-unavailable-show + {:feature-name :community.request-to-join}]))] [rn/safe-area-view {:flex 1} [gesture/scroll-view {:style style/container} [rn/view style/page-container diff --git a/src/status_im/contexts/communities/overview/view.cljs b/src/status_im/contexts/communities/overview/view.cljs index 8fb4275ed1..1f295eafa0 100644 --- a/src/status_im/contexts/communities/overview/view.cljs +++ b/src/status_im/contexts/communities/overview/view.cljs @@ -147,7 +147,8 @@ [:show-bottom-sheet {:content token-gated-communities-info}]) keycard? (rf/sub [:keycard/keycard-profile?]) keycard-feature-unavailable (rn/use-callback - #(rf/dispatch [:keycard/feature-unavailable-show]))] + #(rf/dispatch [:keycard/feature-unavailable-show + {:feature-name :community.request-to-join}]))] (cond networks-not-supported? diff --git a/src/status_im/contexts/keycard/feature_unavailable/events.cljs b/src/status_im/contexts/keycard/feature_unavailable/events.cljs index 48dc7752b8..4193b2d3f2 100644 --- a/src/status_im/contexts/keycard/feature_unavailable/events.cljs +++ b/src/status_im/contexts/keycard/feature_unavailable/events.cljs @@ -1,12 +1,27 @@ (ns status-im.contexts.keycard.feature-unavailable.events (:require + [status-im.constants :as constants] [status-im.contexts.keycard.feature-unavailable.view :as feature-unavailable] [utils.re-frame :as rf])) +(rf/reg-event-fx + :keycard/feature-unavailable-upvote + (fn [_ [{:keys [feature-name]}]] + {:fx [[:dispatch [:open-url constants/mobile-upvote-link]] + [:dispatch + [:centralized-metrics/track + :metric/feature-unavailable-upvote + {:feature-name feature-name}]]]})) + (rf/reg-event-fx :keycard/feature-unavailable-show - (fn [_ [options]] + (fn [_ [{:keys [feature-name theme] :as options}]] {:fx [[:dispatch [:show-bottom-sheet - {:theme (:theme options) - :content feature-unavailable/view}]]]})) + {:theme theme + :content (fn [] + (feature-unavailable/view options))}]] + [:dispatch + [:centralized-metrics/track + :metric/feature-unavailable + {:feature-name feature-name}]]]})) diff --git a/src/status_im/contexts/keycard/feature_unavailable/view.cljs b/src/status_im/contexts/keycard/feature_unavailable/view.cljs index a0dec7d5e4..f549e22580 100644 --- a/src/status_im/contexts/keycard/feature_unavailable/view.cljs +++ b/src/status_im/contexts/keycard/feature_unavailable/view.cljs @@ -1,16 +1,15 @@ (ns status-im.contexts.keycard.feature-unavailable.view (:require [quo.core :as quo] - [status-im.constants :as constants] [utils.i18n :as i18n] [utils.re-frame :as rf])) (defn on-upvote - [] - (rf/dispatch [:open-url constants/mobile-upvote-link])) + [feature-name] + (rf/dispatch [:keycard/feature-unavailable-upvote {:feature-name feature-name}])) (defn view - [] + [{:keys [feature-name]}] [:<> [quo/drawer-top {:title (i18n/label :t/feature-unavailable) @@ -24,5 +23,5 @@ [quo/text {:style {:text-decoration-line :underline} :size :paragraph-2 - :on-press on-upvote} + :on-press #(on-upvote feature-name)} (i18n/label :t/upvote-it)]]]]) diff --git a/src/status_im/contexts/profile/login/events.cljs b/src/status_im/contexts/profile/login/events.cljs index 87c2555c11..c29f2ec5af 100644 --- a/src/status_im/contexts/profile/login/events.cljs +++ b/src/status_im/contexts/profile/login/events.cljs @@ -47,7 +47,8 @@ settings {:log-level log-level})) (assoc-in [:activity-center :loading?] true) - (dissoc :centralized-metrics/onboarding-enabled?))] + (dissoc :centralized-metrics/onboarding-enabled?)) + keycard? (get-in new-db [:profile/profile :keycard-pairing])] {:db (cond-> new-db pairing-completed? (dissoc :syncing)) :fx (into [[:json-rpc/call @@ -75,8 +76,10 @@ [:effects.chat/open-last-chat (:key-uid profile-overview)]) (when (:centralized-metrics/onboarding-enabled? db) - [:dispatch [:profile.settings/toggle-telemetry true]])] + [:dispatch [:profile.settings/toggle-telemetry true]]) + (when keycard? + [:dispatch [:centralized-metrics/track :metric/keycard-login]])] (cond pairing-completed? [[:dispatch [:update-theme-and-init-root :screen/onboarding.syncing-results]]] diff --git a/src/status_im/contexts/profile/settings/screens/password/view.cljs b/src/status_im/contexts/profile/settings/screens/password/view.cljs index 6988dc52c5..e2bb756955 100644 --- a/src/status_im/contexts/profile/settings/screens/password/view.cljs +++ b/src/status_im/contexts/profile/settings/screens/password/view.cljs @@ -10,7 +10,9 @@ [button-label theme keycard-profile?] (fn [] (if keycard-profile? - (rf/dispatch [:keycard/feature-unavailable-show {:theme :dark}]) + (rf/dispatch [:keycard/feature-unavailable-show + {:theme :dark + :feature-name :settings.enable-biometrics}]) (rf/dispatch [:standard-auth/authorize-with-password {:blur? true diff --git a/src/status_im/contexts/syncing/syncing_devices_list/view.cljs b/src/status_im/contexts/syncing/syncing_devices_list/view.cljs index 74fb9219d4..305e4c7446 100644 --- a/src/status_im/contexts/syncing/syncing_devices_list/view.cljs +++ b/src/status_im/contexts/syncing/syncing_devices_list/view.cljs @@ -41,8 +41,10 @@ other-devices) keycard? (rf/sub [:keycard/keycard-profile?]) keycard-feature-unavailable (rn/use-callback - #(rf/dispatch [:keycard/feature-unavailable-show - {:theme :dark}]))] + #(rf/dispatch + [:keycard/feature-unavailable-show + {:theme :dark + :feature-name :settings.setup-syncing}]))] [quo/overlay {:type :shell :top-inset? true} [quo/page-nav {:type :no-title diff --git a/src/status_im/contexts/wallet/common/account_switcher/view.cljs b/src/status_im/contexts/wallet/common/account_switcher/view.cljs index fe5c5612b2..a063ae7543 100644 --- a/src/status_im/contexts/wallet/common/account_switcher/view.cljs +++ b/src/status_im/contexts/wallet/common/account_switcher/view.cljs @@ -48,7 +48,8 @@ {:icon-name :i/dapps :on-press #(rf/dispatch (if keycard? - [:keycard/feature-unavailable-show] + [:keycard/feature-unavailable-show + {:feature-name :wallet.show-connected-dapps}] [:navigate-to :screen/wallet.connected-dapps]))}) (when-not sending-collectible? {:content-type :account-switcher diff --git a/src/status_im/contexts/wallet/wallet_connect/events/session_proposals.cljs b/src/status_im/contexts/wallet/wallet_connect/events/session_proposals.cljs index 09b790e79f..01dc8ab803 100644 --- a/src/status_im/contexts/wallet/wallet_connect/events/session_proposals.cljs +++ b/src/status_im/contexts/wallet/wallet_connect/events/session_proposals.cljs @@ -36,7 +36,9 @@ (cond keycard? - {:fx [[:dispatch [:keycard/feature-unavailable-show]]]} + {:fx [[:dispatch + [:keycard/feature-unavailable-show + {:feature-name :wallet.scan-dapp-connection}]]]} (or (not valid-wc-uri?) (not version-supported?)