Skip to content

Commit

Permalink
🔍 feat(lld): track Ledger keyring activation/deactivation on LLM (#8320)
Browse files Browse the repository at this point in the history
* feat(llm): track "ledgersync_activated" events

* feat(llm): track "ledgersync_deactivated" events

* fix(llm): track the events without the function from "~/analytics"

* chore: update change log

* chore(llm): move the tracking events strings in an enum

* chore(llm): rename Analytics/constants to Analytics/enums
  • Loading branch information
thesan authored Nov 8, 2024
1 parent 2e9d6fd commit 4cd70ed
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-seas-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

Track users creating, joining, and leaving Ledger keyrings on LLM
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum AnalyticsEvents {
LedgerSyncActivated = "ledgersync_activated",
LedgerSyncDeactivated = "ledgersync_deactivated",
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { TrustchainResult, TrustchainResultType } from "@ledgerhq/ledger-key-rin
import { useCallback, useRef } from "react";
import { Device } from "@ledgerhq/live-common/hw/actions/types";
import { useNavigation } from "@react-navigation/native";
import { AnalyticsEvents } from "~/newArch/features/Analytics/enums";
import { track } from "~/analytics";
import { WalletSyncNavigatorStackParamList } from "~/components/RootNavigator/types/WalletSyncNavigator";
import { StackNavigatorNavigation } from "~/components/RootNavigator/types/helpers";
import { ScreenName } from "~/const";
Expand All @@ -34,6 +36,7 @@ export function useAddMember({ device }: { device: Device | null }): DrawerProps
const transitionToNextScreen = useCallback(
(trustchainResult: TrustchainResult) => {
dispatch(setTrustchain(trustchainResult.trustchain));
track(AnalyticsEvents.LedgerSyncActivated);
navigation.navigate(ScreenName.WalletSyncLoading, {
created: trustchainResult.type === TrustchainResultType.created,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
memberCredentialsSelector,
} from "@ledgerhq/ledger-key-ring-protocol/store";
import { useMutation } from "@tanstack/react-query";
import { AnalyticsEvents } from "~/newArch/features/Analytics/enums";
import { track } from "~/analytics";
import { QueryKey } from "./type.hooks";
import { useCloudSyncSDK } from "./useWatchWalletSync";
import { walletSyncUpdate } from "@ledgerhq/live-wallet/store";
Expand All @@ -31,6 +33,7 @@ export function useDestroyTrustchain() {
mutationKey: [QueryKey.destroyTrustchain, trustchain],
onSuccess: () => {
dispatch(resetTrustchainStore());
track(AnalyticsEvents.LedgerSyncDeactivated);
dispatch(walletSyncUpdate(null, 0));
setCurrentStep(Steps.Activation);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
import { setTrustchain, resetTrustchainStore } from "@ledgerhq/ledger-key-ring-protocol/store";
import { TrustchainEjected } from "@ledgerhq/ledger-key-ring-protocol/errors";
import { log } from "@ledgerhq/logs";
import { AnalyticsEvents } from "~/newArch/features/Analytics/enums";
import { track } from "~/analytics";

export function useOnTrustchainRefreshNeeded(
trustchainSdk: TrustchainSDK,
Expand All @@ -24,6 +26,7 @@ export function useOnTrustchainRefreshNeeded(
} catch (e) {
if (e instanceof TrustchainEjected) {
dispatch(resetTrustchainStore());
track(AnalyticsEvents.LedgerSyncDeactivated);
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
memberCredentialsSelector,
setTrustchain,
} from "@ledgerhq/ledger-key-ring-protocol/store";
import { AnalyticsEvents } from "~/newArch/features/Analytics/enums";
import { track } from "~/analytics";
import { useTrustchainSdk } from "./useTrustchainSdk";
import { Options, Steps } from "../types/Activation";
import { useNavigation } from "@react-navigation/native";
Expand Down Expand Up @@ -74,6 +76,7 @@ export function useQRCodeHost({ currentOption }: Props) {
onSuccess: newTrustchain => {
if (newTrustchain) {
dispatch(setTrustchain(newTrustchain));
if (!trustchain) track(AnalyticsEvents.LedgerSyncActivated);
}
queryClient.invalidateQueries({ queryKey: [QueryKey.getMembers] });
navigation.navigate(NavigatorName.WalletSync, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
import { setTrustchain, trustchainSelector } from "@ledgerhq/ledger-key-ring-protocol/store";
import { useDispatch, useSelector } from "react-redux";
import { useNavigation } from "@react-navigation/native";
import { AnalyticsEvents } from "~/newArch/features/Analytics/enums";
import { track } from "~/analytics";
import { Steps } from "../types/Activation";
import { NavigatorName, ScreenName } from "~/const";
import { useInstanceName } from "./useInstanceName";
Expand Down Expand Up @@ -70,6 +72,7 @@ export const useSyncWithQrCode = () => {
});
if (newTrustchain) {
dispatch(setTrustchain(newTrustchain));
if (!trustchain) track(AnalyticsEvents.LedgerSyncActivated);
}
onSyncFinished();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
} from "@ledgerhq/ledger-key-ring-protocol/errors";
import { ErrorType } from "./type.hooks";
import { StackActions, useNavigation } from "@react-navigation/native";
import { AnalyticsEvents } from "~/newArch/features/Analytics/enums";
import { track } from "~/analytics";
import { useTrustchainSdk } from "./useTrustchainSdk";
import { useRestoreTrustchain } from "./useRestoreTrustchain";
import { NavigatorName, ScreenName } from "~/const";
Expand All @@ -19,6 +21,7 @@ export const useLifeCycle = () => {

function reset() {
dispatch(resetTrustchainStore());
track(AnalyticsEvents.LedgerSyncDeactivated);
const routeName = NavigatorName.WalletSync;
const screen = ScreenName.WalletSyncActivationInit;
navigation.dispatch(StackActions.replace(routeName, { screen }));
Expand Down

0 comments on commit 4cd70ed

Please sign in to comment.