refactor(suite-native): asset_sync analytics event

This commit is contained in:
Petr Knetl
2026-01-30 14:06:53 +01:00
committed by Petr Knetl
parent 932b13cfc4
commit d3bb79e7f5
4 changed files with 43 additions and 18 deletions

View File

@@ -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<NetworkSymbol>;
tokenSymbols?: AttributeDef<TokenSymbol[]>;
tokenAddresses?: AttributeDef<TokenAddress[]>;
};
export const assetsSyncEvent: EventDef<Attributes, EventType.AssetsSync> = {
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',
},
},
};

View File

@@ -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';

View File

@@ -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: {

View File

@@ -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<NavigationProp>();
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,