diff --git a/.changeset/chilled-timers-remember.md b/.changeset/chilled-timers-remember.md index 1f08be686633..e2555daf8003 100644 --- a/.changeset/chilled-timers-remember.md +++ b/.changeset/chilled-timers-remember.md @@ -2,4 +2,4 @@ "ledger-live-desktop": patch --- -LLD - Add modelIdList user property and event property +LLD - Add modelIdList user property and event property. The list will be: [ "nanoX", "stax", "nanoS"] diff --git a/apps/ledger-live-desktop/src/renderer/actions/settings.ts b/apps/ledger-live-desktop/src/renderer/actions/settings.ts index 6e8365cb8110..0126aee54eb3 100644 --- a/apps/ledger-live-desktop/src/renderer/actions/settings.ts +++ b/apps/ledger-live-desktop/src/renderer/actions/settings.ts @@ -283,9 +283,9 @@ export const setLastSeenDevice = ({ deviceInfo }: { deviceInfo: DeviceInfo }) => }, }); -export const addNewDevice = ({ seenDevice }: { seenDevice: DeviceModelInfo }) => ({ - type: "ADD_SEEN_DEVICE", - payload: seenDevice, +export const addNewDeviceModel = ({ deviceModelId }: { deviceModelId: DeviceModelId }) => ({ + type: "ADD_NEW_DEVICE_MODEL", + payload: deviceModelId, }); export const setDeepLinkUrl = (url?: string | null) => ({ type: "SET_DEEPLINK_URL", diff --git a/apps/ledger-live-desktop/src/renderer/analytics/segment.ts b/apps/ledger-live-desktop/src/renderer/analytics/segment.ts index a5376729dce6..3259fa635c26 100644 --- a/apps/ledger-live-desktop/src/renderer/analytics/segment.ts +++ b/apps/ledger-live-desktop/src/renderer/analytics/segment.ts @@ -11,7 +11,7 @@ import { lastSeenDeviceSelector, localeSelector, languageSelector, - seenDevicesSelector, + devicesModelListSelector, } from "~/renderer/reducers/settings"; import { State } from "~/renderer/reducers"; import { AccountLike, idsToLanguage } from "@ledgerhq/types-live"; @@ -51,7 +51,7 @@ const extraProperties = (store: ReduxStore) => { const region = (localeSelector(state).split("-")[1] || "").toUpperCase() || null; const systemLocale = getParsedSystemLocale(); const device = lastSeenDeviceSelector(state); - const devices = seenDevicesSelector(state); + const devices = devicesModelListSelector(state); const accounts = accountsSelector(state); const deviceInfo = device ? { @@ -100,7 +100,7 @@ const extraProperties = (store: ReduxStore) => { blockchainsWithNftsOwned, hasGenesisPass, hasInfinityPass, - modelIdList: devices.map(d => d.modelId), + modelIdList: devices, ...deviceInfo, }; }; diff --git a/apps/ledger-live-desktop/src/renderer/components/DeviceAction/index.tsx b/apps/ledger-live-desktop/src/renderer/components/DeviceAction/index.tsx index bca4ecc61950..8770416b59a8 100644 --- a/apps/ledger-live-desktop/src/renderer/components/DeviceAction/index.tsx +++ b/apps/ledger-live-desktop/src/renderer/components/DeviceAction/index.tsx @@ -16,7 +16,7 @@ import { getCurrentDevice } from "~/renderer/reducers/devices"; import { setPreferredDeviceModel, setLastSeenDeviceInfo, - addNewDevice, + addNewDeviceModel, } from "~/renderer/actions/settings"; import { preferredDeviceModelSelector } from "~/renderer/reducers/settings"; import { DeviceModelId } from "@ledgerhq/devices"; @@ -245,7 +245,7 @@ export const DeviceActionDefaultRendering = ({ apps: [], }; dispatch(setLastSeenDeviceInfo({ lastSeenDevice, latestFirmware })); - dispatch(addNewDevice({ seenDevice: lastSeenDevice })); + dispatch(addNewDeviceModel({ deviceModelId: lastSeenDevice.modelId })); } }, [dispatch, device, deviceInfo, latestFirmware]); diff --git a/apps/ledger-live-desktop/src/renderer/reducers/settings.ts b/apps/ledger-live-desktop/src/renderer/reducers/settings.ts index 4b039fc84712..c71f6066c27b 100644 --- a/apps/ledger-live-desktop/src/renderer/reducers/settings.ts +++ b/apps/ledger-live-desktop/src/renderer/reducers/settings.ts @@ -32,7 +32,7 @@ export type SettingsState = { preferredDeviceModel: DeviceModelId; hasInstalledApps: boolean; lastSeenDevice: DeviceModelInfo | undefined | null; - seenDevices: DeviceModelInfo[]; + devicesModelList: DeviceModelId[]; latestFirmware: FirmwareUpdateContext | null; language: string | undefined | null; theme: string | undefined | null; @@ -142,7 +142,7 @@ const INITIAL_STATE: SettingsState = { hasInstalledApps: true, carouselVisibility: 0, lastSeenDevice: null, - seenDevices: [], + devicesModelList: [], lastSeenCustomImage: { size: 0, hash: "", @@ -192,7 +192,7 @@ type HandlersPayloads = { latestFirmware: FirmwareUpdateContext; }; LAST_SEEN_DEVICE: DeviceModelInfo; - ADD_SEEN_DEVICE: DeviceModelInfo; + ADD_NEW_DEVICE_MODEL: DeviceModelId; SET_DEEPLINK_URL: string | null | undefined; SET_FIRST_TIME_LEND: never; SET_SWAP_SELECTABLE_CURRENCIES: string[]; @@ -310,10 +310,11 @@ const handlers: SettingsHandlers = { : undefined, }), - ADD_SEEN_DEVICE: (state, { payload }) => ({ + ADD_NEW_DEVICE_MODEL: (state, { payload }) => ({ ...state, - seenDevices: Array.from(new Set(state.seenDevices.concat(payload))), + devicesModelList: [...new Set(state.devicesModelList.concat(payload))], }), + SET_DEEPLINK_URL: (state, { payload: deepLinkUrl }) => ({ ...state, deepLinkUrl, @@ -668,7 +669,8 @@ export const lastSeenDeviceSelector = (state: State): DeviceModelInfo | null | u } return state.settings.lastSeenDevice; }; -export const seenDevicesSelector = (state: State): DeviceModelInfo[] => state.settings.seenDevices; +export const devicesModelListSelector = (state: State): DeviceModelId[] => + state.settings.devicesModelList; export const latestFirmwareSelector = (state: State) => state.settings.latestFirmware; export const swapHasAcceptedIPSharingSelector = (state: State) => state.settings.swap.hasAcceptedIPSharing; diff --git a/apps/ledger-live-desktop/src/renderer/screens/manager/AppsList/index.tsx b/apps/ledger-live-desktop/src/renderer/screens/manager/AppsList/index.tsx index 37b309ae7903..85d5cfd8e956 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/manager/AppsList/index.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/manager/AppsList/index.tsx @@ -20,7 +20,7 @@ import AppDepsInstallModal from "./AppDepsInstallModal"; import AppDepsUnInstallModal from "./AppDepsUnInstallModal"; import ErrorModal from "~/renderer/modals/ErrorModal/index"; import { - addNewDevice, + addNewDeviceModel, clearLastSeenCustomImage, setHasInstalledApps, setLastSeenDeviceInfo, @@ -149,7 +149,7 @@ const AppsList = ({ latestFirmware: firmware, }), ); - reduxDispatch(addNewDevice({ seenDevice: lastSeenDevice })); + reduxDispatch(addNewDeviceModel({ deviceModelId: lastSeenDevice.modelId })); }, [device, state.installed, deviceInfo, reduxDispatch, firmware]); useEffect(() => {