Skip to content

Commit

Permalink
feat: ✏️Update Analytics (#7863)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcayuelas-ledger authored Sep 20, 2024
1 parent e4b6647 commit 0000492
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-gifts-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

Update Analytics
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const INITIAL_STATE = {
walletSync: {
...initialStateWalletSync,
flow: Flow.ManageBackup,
step: Step.ManageBackup,
step: Step.DeleteBackup,
},
};

Expand All @@ -25,15 +25,11 @@ describe("useFlows", () => {
result.current.goToNextScene();
});
expect(result.current.currentStep).toBe(Object.values(steps)[1]);
act(() => {
result.current.goToNextScene();
});
expect(result.current.currentStep).toBe(Object.values(steps)[2]);

act(() => {
result.current.goToPreviousScene();
});
expect(result.current.currentStep).toBe(Object.values(steps)[1]);
expect(result.current.currentStep).toBe(Object.values(steps)[0]);
});

it("should reset Flow and Step", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ export const FlowOptions: Record<
},
[Flow.ManageBackup]: {
steps: {
1: Step.ManageBackup,
2: Step.DeleteBackup,
3: Step.BackupDeleted,
1: Step.DeleteBackup,
2: Step.BackupDeleted,
},
},
[Flow.ManageInstances]: {
Expand Down Expand Up @@ -70,7 +69,6 @@ export const FlowOptions: Record<
*
*/
export const STEPS_WITH_BACK: Step[] = [
Step.ManageBackup,
Step.DeleteBackup,
Step.SynchronizedInstances,
Step.SynchronizeMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { track } from "~/renderer/analytics/segment";
import { Step } from "~/renderer/reducers/walletSync";

export enum AnalyticsPage {
ManageBackup = "Manage Backup",
ConfirmDeleteBackup = "Confirm Delete Backup",
BackupDeleted = "delete backup success",
BackupDeletionError = "Backup Deletion Error",
ConfirmDeleteBackup = "Confirm delete sync",
BackupDeleted = "delete sync success",
BackupDeletionError = "Sync Deletion Error",

ManageInstances = "Manage synchronized instances",
DeviceActionInstance = "Device Action Manage Instance",
Expand All @@ -23,14 +22,14 @@ export enum AnalyticsPage {
SyncMethod = "Choose sync method",
MobileSync = "Sync from a mobile",
DesktopSync = "Sync from a desktop",
KeyCreated = "Backup creation success",
KeyCreated = "Ledger Sync turned on",
KeyUpdated = "Sync apps success",
Loading = "Loading Trustchain",
Loading = "Loading Sync",

SyncWithQR = "Sync with QR code",
PinCode = "Pin code",
PinCodeError = "Pin code error",
UnbackedError = "Trustchain initialization error",
UnbackedError = "Scan attempt with no sync",

SettingsGeneral = "Settings General",
LedgerSyncSettings = "Ledger Sync Settings",
Expand All @@ -52,7 +51,6 @@ type onActionTrack = {
};

export const StepMappedToAnalytics: Record<Step, string> = {
[Step.ManageBackup]: AnalyticsPage.ManageBackup,
[Step.DeleteBackup]: AnalyticsPage.ConfirmDeleteBackup,
[Step.BackupDeleted]: AnalyticsPage.BackupDeleted,
[Step.BackupDeletionError]: AnalyticsPage.BackupDeletionError,
Expand Down Expand Up @@ -92,7 +90,6 @@ export const StepMappedToAnalytics: Record<Step, string> = {

export const StepsOutsideFlow: Step[] = [
Step.LedgerSyncActivated,
Step.ManageBackup,
Step.AutoRemoveInstance,
Step.UnsecuredLedger,
Step.BackupDeletionError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { useTranslation } from "react-i18next";
import { useTheme } from "styled-components";
import ButtonV3 from "~/renderer/components/ButtonV3";
import TrackPage from "~/renderer/analytics/TrackPage";
import { AnalyticsPage } from "../../hooks/useLedgerSyncAnalytics";
import {
AnalyticsFlow,
AnalyticsPage,
useLedgerSyncAnalytics,
} from "../../hooks/useLedgerSyncAnalytics";
import { LogoWrapper } from "../../components/LogoWrapper";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import { openURL } from "~/renderer/linking";
Expand All @@ -21,8 +25,15 @@ export default function CreateOrSynchronizeStep({ goToCreateBackup, goToSync }:
const learnMoreUrl = ledgerSyncFF?.params?.learnMoreLink;
const hasLearnMoreLink = !!learnMoreUrl;

const { onClickTrack } = useLedgerSyncAnalytics();

const onLearnMore = () => {
if (learnMoreUrl) {
onClickTrack({
button: "How does Ledger Sync work",
page: AnalyticsPage.Activation,
flow: AnalyticsFlow,
});
openURL(learnMoreUrl);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ const WalletSyncManage = () => {
const goToSync = () => {
dispatch(setFlow({ flow: Flow.Synchronize, step: Step.SynchronizeWithQRCode }));

onClickTrack({ button: "Synchronize", page: AnalyticsPage.LedgerSyncSettings });
onClickTrack({
button: "Synchronize with another app",
page: AnalyticsPage.LedgerSyncSettings,
});
};

const goToManageBackup = () => {
dispatch(setFlow({ flow: Flow.ManageBackup, step: Step.ManageBackup }));
onClickTrack({ button: "Manage Key", page: AnalyticsPage.LedgerSyncSettings });
dispatch(setFlow({ flow: Flow.ManageBackup, step: Step.DeleteBackup }));
onClickTrack({ button: "Delete sync", page: AnalyticsPage.LedgerSyncSettings });
};

const goToManageInstances = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export default function DeleteBackupStep({ cancel }: DeleteBackupStepProps) {
const { onClickTrack } = useLedgerSyncAnalytics();

const handleDeleteBackup = async () => {
onClickTrack({ button: "delete", page: AnalyticsPage.ConfirmDeleteBackup });
onClickTrack({ button: "yes Delete", page: AnalyticsPage.ConfirmDeleteBackup });
await deleteMutation.mutateAsync();
};

const handleCancel = () => {
onClickTrack({ button: "cancel", page: AnalyticsPage.ConfirmDeleteBackup });
onClickTrack({ button: "Keep", page: AnalyticsPage.ConfirmDeleteBackup });
cancel();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export const DeletionError = ({ error }: Props) => {
onClickTrack({ button: "connect new ledger", page: errorConfig[error].analyticsPage });
};
const goToDelete = () => {
dispatch(setFlow({ flow: Flow.ManageBackup, step: Step.ManageBackup }));
onClickTrack({ button: "delete key", page: errorConfig[error].analyticsPage });
dispatch(setFlow({ flow: Flow.ManageBackup, step: Step.DeleteBackup }));
onClickTrack({ button: "Delete sync", page: errorConfig[error].analyticsPage });
};

const understood = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function UnbackedError() {
const dispatch = useDispatch();
const onClick = () => {
onClickTrack({
button: "Create enctryption key",
button: "Turn on Ledger Sync",
page: AnalyticsPage.UnbackedError,
});
dispatch(setFlow({ flow: Flow.Activation, step: Step.DeviceAction }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function AlreadyCreatedOtherSeedStep() {
const { onClickTrack } = useLedgerSyncAnalytics();

const deleteKey = () => {
dispatch(setFlow({ flow: Flow.ManageBackup, step: Step.ManageBackup }));
dispatch(setFlow({ flow: Flow.ManageBackup, step: Step.DeleteBackup }));
onClickTrack({
button: "Delete sync",
page: AnalyticsPage.AlreadySecuredOtherSeed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export enum Flow {

export enum Step {
//ManageBackup
ManageBackup = "ManageBackup",
DeleteBackup = "DeleteBackup",
BackupDeleted = "BackupDeleted",
BackupDeletionError = "BackupDeletionError",
Expand Down
7 changes: 3 additions & 4 deletions apps/ledger-live-desktop/static/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6517,7 +6517,6 @@
"close": "Close"
},
"manageBackup": {
"title": "Manage your key",
"deleteBackup": {
"title": "Sure you want to delete sync?",
"description": "Your crypto accounts across Ledger Live apps on different phones and computers will stop being in sync. This does not impact your funds in any way. ",
Expand Down Expand Up @@ -6569,9 +6568,9 @@
}
},
"unbackedError": {
"title": "You need to create your encryption key first",
"description": "Please make sure you’ve created an encryption key on one of your Ledger Live apps before continuing your synchronization.",
"cta": "Create your encryption key"
"title": "Sync not detected",
"description": "Turn on Ledger Sync on either this Ledger Live or the one you’re syncing with",
"cta": "Turn on Ledger Sync"
},
"pinCode": {
"title": "Your Ledger Sync code",
Expand Down

0 comments on commit 0000492

Please sign in to comment.