From d3bb79e7f5efd207a200048324b561a3ebd64b07 Mon Sep 17 00:00:00 2001 From: Petr Knetl Date: Fri, 30 Jan 2026 14:06:53 +0100 Subject: [PATCH] refactor(suite-native): asset_sync analytics event --- .../analytics/src/events/AssetsSyncEvent.ts | 38 +++++++++++++++++++ suite-native/analytics/src/events/index.ts | 2 + suite-native/analytics/src/types.ts | 15 -------- .../AccountImportConfirmFormScreen.tsx | 6 +-- 4 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 suite-native/analytics/src/events/AssetsSyncEvent.ts diff --git a/suite-native/analytics/src/events/AssetsSyncEvent.ts b/suite-native/analytics/src/events/AssetsSyncEvent.ts new file mode 100644 index 0000000000..90b616cce8 --- /dev/null +++ b/suite-native/analytics/src/events/AssetsSyncEvent.ts @@ -0,0 +1,38 @@ +import { AttributeDef, EventDef } from '@suite-common/analytics'; +import { NetworkSymbol } from '@suite-common/wallet-config'; +import { TokenAddress, TokenSymbol } from '@suite-common/wallet-types'; + +import { EventType } from '../constants'; + +type Attributes = { + assetSymbol: AttributeDef; + tokenSymbols?: AttributeDef; + tokenAddresses?: AttributeDef; +}; + +export const assetsSyncEvent: EventDef = { + name: EventType.AssetsSync, + descriptionTrigger: 'User imports an asset to their portfolio.', + changelog: [ + { version: '23.4.1', notes: 'added' }, + { version: '24.3.1', notes: '"tokenAddresses" attribute added' }, + ], + + attributes: { + assetSymbol: { + changelog: [{ version: '23.4.1', notes: 'added' }], + description: 'The symbol of the synced asset', + }, + tokenSymbols: { + changelog: [ + { version: '23.4.1', notes: 'added' }, + { version: '24.3.1', notes: 'renamed from "tokenSymbol" to "tokenSymbols"' }, + ], + description: 'The symbols of the synced tokens', + }, + tokenAddresses: { + changelog: [{ version: '24.3.1', notes: 'added' }], + description: 'The addresses of the synced tokens', + }, + }, +}; diff --git a/suite-native/analytics/src/events/index.ts b/suite-native/analytics/src/events/index.ts index d933bd3c1d..cdc230ae6e 100644 --- a/suite-native/analytics/src/events/index.ts +++ b/suite-native/analytics/src/events/index.ts @@ -1,6 +1,8 @@ export { appReadyEvent } from './AppReadyEvent'; export { assetDetailEvent } from './assetDetailEvent'; +export { assetsSyncEvent } from './AssetsSyncEvent'; export { earnNavigateEvent } from './earnNavigateEvent'; export { earnStakeTilePressedEvent } from './earnStakeTilePressedEvent'; export { onboardingCompletedEvent } from './OnboardingCompletedEvent'; +export { screenChangeEvent } from './ScreenChangeEvent'; export { settingsChangeCoinBackendEvent } from './settingsChangeCoinBackendEvent'; diff --git a/suite-native/analytics/src/types.ts b/suite-native/analytics/src/types.ts index a9c5732fb3..4dbb52e069 100644 --- a/suite-native/analytics/src/types.ts +++ b/suite-native/analytics/src/types.ts @@ -29,21 +29,6 @@ export type CountryChangeAction = 'submitDefault' | 'submitCustom' | 'cancel'; /** @deprecated use `AnalyticsNativeEvents` */ export type SuiteNativeLegacyAnalyticsEvents = - | { - type: EventType.AssetsSync; - payload: { - assetSymbol: NetworkSymbol; - tokenSymbols?: TokenSymbol[]; - tokenAddresses?: TokenAddress[]; - }; - } - | { - type: EventType.ScreenChange; - payload: { - previousScreen: string; - currentScreen: string; - }; - } | { type: EventType.WatchPortfolioTimeframeChange; payload: { diff --git a/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx b/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx index 989930f9cf..8b5ec7fe4a 100644 --- a/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx +++ b/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx @@ -27,7 +27,7 @@ import { StackToStackCompositeNavigationProps, useNavigateToInitialScreen, } from '@suite-native/navigation'; -import { useLegacyAnalytics } from '@suite-native/services'; +import { useAnalytics } from '@suite-native/services'; import { AccountInfo, TokenInfo } from '@trezor/connect'; import { importAccountThunk } from '../accountsImportThunks'; @@ -52,7 +52,7 @@ export const AccountImportConfirmFormScreen = ({ accountInfo, }: AccountImportConfirmFormScreenProps) => { const dispatch = useDispatch(); - const legacyAnalytics = useLegacyAnalytics(); + const analytics = useAnalytics(); const navigation = useNavigation(); const navigateToInitialScreen = useNavigateToInitialScreen(); const showImportError = useShowImportError(symbol, navigation); @@ -84,7 +84,7 @@ export const AccountImportConfirmFormScreen = ({ }), ).unwrap(); - legacyAnalytics.report({ + analytics.report({ type: EventType.AssetsSync, payload: { assetSymbol: symbol,