diff --git a/source/renderer/app/analytics/index.ts b/source/renderer/app/analytics/index.ts index e0a27fea05..903e452e9f 100644 --- a/source/renderer/app/analytics/index.ts +++ b/source/renderer/app/analytics/index.ts @@ -1,3 +1,3 @@ -export { AnalyticsAcceptanceStatus } from './types'; +export { AnalyticsAcceptanceStatus, EventCategories } from './types'; export type { AnalyticsClient, AnalyticsTracker } from './types'; export { noopAnalyticsTracker } from './NoopAnalyticsTracker'; diff --git a/source/renderer/app/analytics/types.ts b/source/renderer/app/analytics/types.ts index 13f92e2d17..56737d3a6b 100644 --- a/source/renderer/app/analytics/types.ts +++ b/source/renderer/app/analytics/types.ts @@ -13,5 +13,14 @@ export interface AnalyticsTracker { enableTracking(): Promise; disableTracking(): void; sendPageNavigationEvent(pageTitle: string): void; - sendEvent(category: string, name: string, action?: string): void; + sendEvent(category: EventCategories, name: string, action?: string): void; +} + +export enum EventCategories { + WALLETS = 'Wallets', + STAKE_POOLS = 'Stake Pools', + SETTINGS = 'Settings', + LAYOUT = 'Layout', + SYSTEM_MENU = 'System Menu', + VOTING = 'Voting', } diff --git a/source/renderer/app/components/staking/stake-pools/StakePools.tsx b/source/renderer/app/components/staking/stake-pools/StakePools.tsx index ec1a0f2a1c..c1f1af675a 100644 --- a/source/renderer/app/components/staking/stake-pools/StakePools.tsx +++ b/source/renderer/app/components/staking/stake-pools/StakePools.tsx @@ -23,7 +23,7 @@ import { import smashSettingsIcon from '../../../assets/images/smash-settings-ic.inline.svg'; import tinySpinnerIcon from '../../../assets/images/spinner-tiny.inline.svg'; import { getSmashServerNameFromUrl } from '../../../utils/staking'; -import { AnalyticsTracker } from '../../../analytics'; +import { AnalyticsTracker, EventCategories } from '../../../analytics'; const messages = defineMessages({ delegatingListTitle: { @@ -120,7 +120,7 @@ class StakePools extends Component { sendSearchAnalyticsEvent = debounce( () => this.props.analyticsTracker.sendEvent( - 'Stake Pools', + EventCategories.STAKE_POOLS, 'Used stake pools search' ), 5000 @@ -147,7 +147,7 @@ class StakePools extends Component { }); this.props.analyticsTracker.sendEvent( - 'Stake Pools', + EventCategories.STAKE_POOLS, 'Changed view to grid view' ); }; @@ -159,7 +159,7 @@ class StakePools extends Component { }); this.props.analyticsTracker.sendEvent( - 'Stake Pools', + EventCategories.STAKE_POOLS, 'Changed view to grid rewards view' ); }; @@ -171,7 +171,7 @@ class StakePools extends Component { }); this.props.analyticsTracker.sendEvent( - 'Stake Pools', + EventCategories.STAKE_POOLS, 'Changed view to list view' ); }; diff --git a/source/renderer/app/components/wallet/WalletSendForm.tsx b/source/renderer/app/components/wallet/WalletSendForm.tsx index 68b4cc9c67..fd3e0d1bc8 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.tsx +++ b/source/renderer/app/components/wallet/WalletSendForm.tsx @@ -41,7 +41,7 @@ import { DiscreetWalletAmount } from '../../features/discreet-mode'; import WalletTokenPicker from './tokens/wallet-token-picker/WalletTokenPicker'; import { ClearButton } from './widgets/ClearButton'; import { Divider } from './widgets/Divider'; -import { AnalyticsTracker } from '../../analytics'; +import { AnalyticsTracker, EventCategories } from '../../analytics'; messages.fieldIsRequired = globalMessages.fieldIsRequired; type AdaInputState = 'restored' | 'updated' | 'reset' | 'none'; @@ -709,7 +709,7 @@ class WalletSendForm extends Component { this.removeAssetFields(uniqueId); await this.calculateTransactionFee(true); this.props.analyticsTracker.sendEvent( - 'Wallets', + EventCategories.WALLETS, 'Removed token from transaction' ); } @@ -1170,7 +1170,7 @@ class WalletSendForm extends Component { onTokenPickerDialogClose(); checked.forEach(this.addAssetRow); this.props.analyticsTracker.sendEvent( - 'Wallets', + EventCategories.WALLETS, 'Added token to transaction' ); }} diff --git a/source/renderer/app/components/wallet/transactions/WalletTransactionsList.tsx b/source/renderer/app/components/wallet/transactions/WalletTransactionsList.tsx index 214b657ffa..c9c2862988 100644 --- a/source/renderer/app/components/wallet/transactions/WalletTransactionsList.tsx +++ b/source/renderer/app/components/wallet/transactions/WalletTransactionsList.tsx @@ -16,7 +16,7 @@ import { SimpleTransactionList } from './render-strategies/SimpleTransactionList import { TransactionInfo, TransactionsGroup } from './types'; import type { Row } from './types'; import { getNonZeroAssetTokens } from '../../../utils/assets'; -import { AnalyticsTracker } from '../../../analytics'; +import { AnalyticsTracker, EventCategories } from '../../../analytics'; const messages = defineMessages({ today: { @@ -206,7 +206,7 @@ class WalletTransactionsList extends Component { if (this.props.onShowMoreTransactions) { this.props.onShowMoreTransactions(walletId); this.props.analyticsTracker.sendEvent( - 'Wallet Details', + EventCategories.WALLETS, 'Clicked Show More Transactions button' ); } diff --git a/source/renderer/app/features/discreet-mode/feature.ts b/source/renderer/app/features/discreet-mode/feature.ts index 4f429009fd..987f48e267 100644 --- a/source/renderer/app/features/discreet-mode/feature.ts +++ b/source/renderer/app/features/discreet-mode/feature.ts @@ -5,7 +5,7 @@ import { DiscreetModeApi } from './api'; import { SENSITIVE_DATA_SYMBOL } from './config'; import { defaultReplacer } from './replacers/defaultReplacer'; import type { ReplacerFn } from './types'; -import { AnalyticsTracker } from '../../analytics'; +import { AnalyticsTracker, EventCategories } from '../../analytics'; export class DiscreetMode extends Feature { constructor( @@ -52,7 +52,7 @@ export class DiscreetMode extends Feature { toggleDiscreetMode = () => { this.isDiscreetMode = !this.isDiscreetMode; this.analyticsTracker.sendEvent( - 'Settings', + EventCategories.SETTINGS, this.isDiscreetMode ? 'Turned on discreet mode' : 'Turned off discreet mode' @@ -67,7 +67,7 @@ export class DiscreetMode extends Feature { this.openInDiscreetMode = nextSetting; }); this.analyticsTracker.sendEvent( - 'Settings', + EventCategories.SETTINGS, this.isDiscreetMode ? 'Turned on discreet mode by default' : 'Turned off discreet mode by default' diff --git a/source/renderer/app/stores/AppStore.ts b/source/renderer/app/stores/AppStore.ts index 969a126a61..04d90bd00a 100644 --- a/source/renderer/app/stores/AppStore.ts +++ b/source/renderer/app/stores/AppStore.ts @@ -15,6 +15,7 @@ import { getGPUStatusChannel } from '../ipc/get-gpu-status.ipc'; import { generateFileNameWithTimestamp } from '../../../common/utils/files'; import type { GpuStatus } from '../types/gpuStatus'; import type { ApplicationDialog } from '../types/applicationDialogTypes'; +import { EventCategories } from '../analytics'; export default class AppStore extends Store { @observable @@ -89,7 +90,7 @@ export default class AppStore extends Store { this.newsFeedIsOpen = !this.newsFeedIsOpen; if (this.newsFeedIsOpen) { - this._sendAnalyticsEvent('Topbar', 'Opened newsfeed'); + this.analytics.sendEvent(EventCategories.LAYOUT, 'Opened newsfeed'); } }; @action @@ -118,21 +119,27 @@ export default class AppStore extends Store { case DIALOGS.ABOUT: // @ts-ignore ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message this._updateActiveDialog(DIALOGS.ABOUT); - this._sendAnalyticsEvent('System menu', 'Showed about dialog'); + this.analytics.sendEvent( + EventCategories.SYSTEM_MENU, + 'Showed about dialog' + ); break; case DIALOGS.DAEDALUS_DIAGNOSTICS: // @ts-ignore ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message this._updateActiveDialog(DIALOGS.DAEDALUS_DIAGNOSTICS); - this._sendAnalyticsEvent('System menu', 'Showed diagnostics dialog'); + this.analytics.sendEvent( + EventCategories.SYSTEM_MENU, + 'Showed diagnostics dialog' + ); break; case DIALOGS.TOGGLE_RTS_FLAGS_MODE: // @ts-ignore ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message this._updateActiveDialog(DIALOGS.TOGGLE_RTS_FLAGS_MODE); - this._sendAnalyticsEvent( - 'System menu', + this.analytics.sendEvent( + EventCategories.SYSTEM_MENU, 'Showed toggle RTS flags dialog' ); break; @@ -140,15 +147,18 @@ export default class AppStore extends Store { case DIALOGS.ITN_REWARDS_REDEMPTION: // @ts-ignore ts-migrate(2554) FIXME: Expected 1 arguments, but got 0. this.actions.staking.onRedeemStart.trigger(); - this._sendAnalyticsEvent( - 'System menu', + this.analytics.sendEvent( + EventCategories.SYSTEM_MENU, 'Showed ITN rewards redemption dialog' ); break; case NOTIFICATIONS.DOWNLOAD_LOGS: this._downloadLogs(); - this._sendAnalyticsEvent('System menu', 'Downloaded logs'); + this.analytics.sendEvent( + EventCategories.SYSTEM_MENU, + 'Downloaded logs' + ); break; case PAGES.SETTINGS: @@ -247,8 +257,4 @@ export default class AppStore extends Store { _setIsDownloadingLogs = (isDownloadNotificationVisible: boolean) => { this.isDownloadNotificationVisible = isDownloadNotificationVisible; }; - - _sendAnalyticsEvent = (category: string, actionName: string) => { - this.analytics.sendEvent(category, actionName); - }; } diff --git a/source/renderer/app/stores/AssetsStore.ts b/source/renderer/app/stores/AssetsStore.ts index a1f9c4e615..721cbd6588 100644 --- a/source/renderer/app/stores/AssetsStore.ts +++ b/source/renderer/app/stores/AssetsStore.ts @@ -6,6 +6,7 @@ import Asset from '../domains/Asset'; import { ROUTES } from '../routes-config'; import { ellipsis } from '../utils/strings'; import type { GetAssetsResponse, AssetToken } from '../api/assets/types'; +import { EventCategories } from '../analytics'; type WalletId = string; export default class AssetsStore extends Store { @@ -108,7 +109,10 @@ export default class AssetsStore extends Store { decimals, }); - this.analytics.sendEvent('Wallets', 'Changed native token settings'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Changed native token settings' + ); }; @action _onEditedAssetUnset = () => { @@ -197,7 +201,7 @@ export default class AssetsStore extends Store { await this.favoritesRequest.execute(); this.analytics.sendEvent( - 'Wallets', + EventCategories.WALLETS, !isFavorite ? 'Added token from favorites' : 'Removed token from favorites' diff --git a/source/renderer/app/stores/CurrencyStore.ts b/source/renderer/app/stores/CurrencyStore.ts index 0cab997980..cbdaddb31a 100644 --- a/source/renderer/app/stores/CurrencyStore.ts +++ b/source/renderer/app/stores/CurrencyStore.ts @@ -7,6 +7,7 @@ import { getCurrencyFromCode, } from '../config/currencyConfig'; import type { Currency, LocalizedCurrency } from '../types/currencyTypes'; +import { EventCategories } from '../analytics'; export default class CurrencyStore extends Store { @observable @@ -128,7 +129,11 @@ export default class CurrencyStore extends Store { await this.api.localStorage.setCurrencySelected(selected.code); } - this.analytics.sendEvent('Settings', 'Changed currency', code); + this.analytics.sendEvent( + EventCategories.SETTINGS, + 'Changed currency', + code + ); }; @action _toggleCurrencyIsActive = () => { @@ -136,7 +141,7 @@ export default class CurrencyStore extends Store { this.api.localStorage.setCurrencyIsActive(this.isActive); this.analytics.sendEvent( - 'Settings', + EventCategories.SETTINGS, `Turned ${ this.isActive ? 'on' : 'off' } displaying ada balances in other currency` diff --git a/source/renderer/app/stores/HardwareWalletsStore.ts b/source/renderer/app/stores/HardwareWalletsStore.ts index aabc4e8b29..0cb2c9f490 100644 --- a/source/renderer/app/stores/HardwareWalletsStore.ts +++ b/source/renderer/app/stores/HardwareWalletsStore.ts @@ -101,6 +101,7 @@ import type { TrezorWitness, } from '../../../common/types/hardware-wallets.types'; import { logger } from '../utils/logging'; +import { EventCategories } from '../analytics'; export type TxSignRequestTypes = { coinSelection: CoinSelectionsResponse; @@ -526,7 +527,7 @@ export default class HardwareWalletsStore extends Store { ); this.analytics.sendEvent( - 'Wallets', + EventCategories.WALLETS, 'Transaction made', 'Hardware wallet' ); @@ -1472,7 +1473,7 @@ export default class HardwareWalletsStore extends Store { } this.analytics.sendEvent( - 'Wallets', + EventCategories.WALLETS, 'Verified wallet address with hardware wallet' ); } else { diff --git a/source/renderer/app/stores/NetworkStatusStore.ts b/source/renderer/app/stores/NetworkStatusStore.ts index 3eb504abd3..3c14077ec0 100644 --- a/source/renderer/app/stores/NetworkStatusStore.ts +++ b/source/renderer/app/stores/NetworkStatusStore.ts @@ -42,6 +42,7 @@ import type { CheckDiskSpaceResponse } from '../../../common/types/no-disk-space import { TlsCertificateNotValidError } from '../api/nodes/errors'; import { openLocalDirectoryChannel } from '../ipc/open-local-directory'; import { toggleRTSFlagsModeChannel } from '../ipc/toggleRTSFlagsModeChannel'; +import { EventCategories } from '../analytics'; // DEFINE CONSTANTS ------------------------- const NETWORK_STATUS = { @@ -432,7 +433,7 @@ export default class NetworkStatusStore extends Store { // DEFINE ACTIONS @action _toggleRTSFlagsMode = async () => { this.analytics.sendEvent( - 'Settings', + EventCategories.SETTINGS, `RTS flags ${this.isRTSFlagsModeEnabled ? 'disabled' : 'enabled'}` ); await toggleRTSFlagsModeChannel.send(); diff --git a/source/renderer/app/stores/ProfileStore.ts b/source/renderer/app/stores/ProfileStore.ts index 2787f5368a..2cbddd7f30 100644 --- a/source/renderer/app/stores/ProfileStore.ts +++ b/source/renderer/app/stores/ProfileStore.ts @@ -41,7 +41,7 @@ import { TIME_OPTIONS, } from '../config/profileConfig'; import { buildSystemInfo } from '../utils/buildSystemInfo'; -import { AnalyticsAcceptanceStatus } from '../analytics/types'; +import { AnalyticsAcceptanceStatus, EventCategories } from '../analytics/types'; export default class ProfileStore extends Store { @observable @@ -370,7 +370,11 @@ export default class ProfileStore extends Store { this.stores.wallets.refreshWalletsData(); } - this.analytics.sendEvent('Settings', 'Changed user settings', param); + this.analytics.sendEvent( + EventCategories.SETTINGS, + 'Changed user settings', + param + ); }; _updateTheme = async ({ theme }: { theme: string }) => { // @ts-ignore ts-migrate(1320) FIXME: Type of 'await' operand must either be a valid pro... Remove this comment to see the full error message @@ -378,7 +382,7 @@ export default class ProfileStore extends Store { // @ts-ignore ts-migrate(1320) FIXME: Type of 'await' operand must either be a valid pro... Remove this comment to see the full error message await this.getThemeRequest.execute(); - this.analytics.sendEvent('Settings', 'Changed theme', theme); + this.analytics.sendEvent(EventCategories.SETTINGS, 'Changed theme', theme); }; _acceptTermsOfUse = async () => { // @ts-ignore ts-migrate(1320) FIXME: Type of 'await' operand must either be a valid pro... Remove this comment to see the full error message diff --git a/source/renderer/app/stores/SidebarStore.ts b/source/renderer/app/stores/SidebarStore.ts index 59fe6879db..1310ca29c2 100644 --- a/source/renderer/app/stores/SidebarStore.ts +++ b/source/renderer/app/stores/SidebarStore.ts @@ -10,6 +10,7 @@ import type { import { WalletSortBy, WalletSortOrder } from '../types/sidebarTypes'; import { changeWalletSorting, sortWallets } from '../utils/walletSorting'; import Store from './lib/Store'; +import { EventCategories } from '../analytics'; export default class SidebarStore extends Store { @observable @@ -98,7 +99,10 @@ export default class SidebarStore extends Store { currentSortBy: this.walletSortConfig.sortBy, }); - this._sendAnalyticsEvent('Changed wallet sorting settings'); + this.analytics.sendEvent( + EventCategories.LAYOUT, + 'Changed wallet sorting settings' + ); }; @action onSearchValueUpdated = (searchValue: string) => { @@ -178,17 +182,17 @@ export default class SidebarStore extends Store { @action _showSubMenus = () => { this.isShowingSubMenus = true; - this._sendAnalyticsEvent('Toggled submenu'); + this.analytics.sendEvent(EventCategories.LAYOUT, 'Toggled submenu'); }; @action _hideSubMenus = () => { this.isShowingSubMenus = false; - this._sendAnalyticsEvent('Toggled submenu'); + this.analytics.sendEvent(EventCategories.LAYOUT, 'Toggled submenu'); }; @action _toggleSubMenus = () => { this.isShowingSubMenus = !this.isShowingSubMenus; - this._sendAnalyticsEvent('Toggled submenu'); + this.analytics.sendEvent(EventCategories.LAYOUT, 'Toggled submenu'); }; _syncSidebarRouteWithRouter = () => { const route = this.stores.app.currentRoute; @@ -205,10 +209,7 @@ export default class SidebarStore extends Store { this._configureCategories(); } }; - _sendAnalyticsEvent = (action: string) => { - this.analytics.sendEvent('Layout', action); - }; _sendSearchAnalyticsEvent = debounce(() => { - this._sendAnalyticsEvent('Used wallet search'); + this.analytics.sendEvent(EventCategories.LAYOUT, 'Used wallet search'); }, 5000); } diff --git a/source/renderer/app/stores/StakingStore.ts b/source/renderer/app/stores/StakingStore.ts index 53438b2981..14ecb68d07 100644 --- a/source/renderer/app/stores/StakingStore.ts +++ b/source/renderer/app/stores/StakingStore.ts @@ -36,6 +36,7 @@ import { showSaveDialogChannel } from '../ipc/show-file-dialog-channels'; import { generateFileNameWithTimestamp } from '../../../common/utils/files'; import type { RedeemItnRewardsStep } from '../types/stakingTypes'; import type { CsvFileContent } from '../../../common/types/csv-request.types'; +import { EventCategories } from '../analytics'; export default class StakingStore extends Store { @observable @@ -229,7 +230,10 @@ export default class StakingStore extends Store { }; _sendStakePoolsSliderUsedAnalyticsEvent = debounce(() => { - this.analytics.sendEvent('Stake Pools', 'Used stake pools amount slider'); + this.analytics.sendEvent( + EventCategories.STAKE_POOLS, + 'Used stake pools amount slider' + ); }, 5000); @action @@ -273,7 +277,10 @@ export default class StakingStore extends Store { // Update // @ts-ignore ts-migrate(2339) FIXME: Property 'api' does not exist on type 'StakingStor... Remove this comment to see the full error message await this.api.localStorage.setSmashServer(smashServerUrl); - this.analytics.sendEvent('Settings', 'Changed SMASH server'); + this.analytics.sendEvent( + EventCategories.SETTINGS, + 'Changed SMASH server' + ); } catch (error) { runInAction(() => { this.smashServerUrlError = error; @@ -395,7 +402,7 @@ export default class StakingStore extends Store { const wallet = this.stores.wallets.getWalletById(walletId); this.analytics.sendEvent( - 'Stake Pools', + EventCategories.STAKE_POOLS, wallet.isDelegating ? 'Redelegated a wallet' : 'Delegated a wallet' ); } catch (error) { @@ -522,7 +529,10 @@ export default class StakingStore extends Store { }); // @ts-ignore ts-migrate(2339) FIXME: Property 'actions' does not exist on type 'Staking... Remove this comment to see the full error message this.actions.staking.requestCSVFileSuccess.trigger(); - this.analytics.sendEvent('Stake Pools', 'Exported rewards as CSV'); + this.analytics.sendEvent( + EventCategories.STAKE_POOLS, + 'Exported rewards as CSV' + ); }; calculateDelegationFee = async ( delegationFeeRequest: GetDelegationFeeRequest diff --git a/source/renderer/app/stores/TransactionsStore.ts b/source/renderer/app/stores/TransactionsStore.ts index 829d05e086..ab480dd3b0 100644 --- a/source/renderer/app/stores/TransactionsStore.ts +++ b/source/renderer/app/stores/TransactionsStore.ts @@ -28,6 +28,7 @@ import { isTransactionInFilterRange, } from '../utils/transaction'; import type { ApiTokens } from '../api/assets/types'; +import { EventCategories } from '../analytics'; const INITIAL_SEARCH_LIMIT = null; // 'null' value stands for 'load all' @@ -368,7 +369,10 @@ export default class TransactionsStore extends Store { ...filterOptions, }; - this.analytics.sendEvent('Wallets', 'Set transaction filters'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Set transaction filters' + ); return true; }; @action @@ -407,7 +411,10 @@ export default class TransactionsStore extends Store { }); if (success) { actions.transactions.requestCSVFileSuccess.trigger(); - this.analytics.sendEvent('Wallets', 'Exported transactions as CSV'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Exported transactions as CSV' + ); } }; @action diff --git a/source/renderer/app/stores/UiDialogsStore.ts b/source/renderer/app/stores/UiDialogsStore.ts index db7c1aa22b..064cb8dc87 100644 --- a/source/renderer/app/stores/UiDialogsStore.ts +++ b/source/renderer/app/stores/UiDialogsStore.ts @@ -4,6 +4,7 @@ import Store from './lib/Store'; import WalletReceiveDialog from '../components/wallet/receive/WalletReceiveDialog'; import AssetSettingsDialog from '../components/assets/AssetSettingsDialog'; import DelegationSetupWizardDialog from '../components/staking/delegation-setup-wizard/DelegationSetupWizardDialog'; +import { EventCategories } from '../analytics'; export default class UiDialogsStore extends Store { @observable @@ -62,18 +63,21 @@ export default class UiDialogsStore extends Store { switch (dialog) { case WalletReceiveDialog: this.analytics.sendEvent( - 'Wallets', + EventCategories.WALLETS, 'Opened share wallet address modal' ); break; case AssetSettingsDialog: - this.analytics.sendEvent('Wallets', 'Opened native token settings'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Opened native token settings' + ); break; case DelegationSetupWizardDialog: this.analytics.sendEvent( - 'Stake Pools', + EventCategories.STAKE_POOLS, 'Opened delegate wallet dialog' ); break; diff --git a/source/renderer/app/stores/VotingStore.ts b/source/renderer/app/stores/VotingStore.ts index 834adf9946..2b35664fae 100644 --- a/source/renderer/app/stores/VotingStore.ts +++ b/source/renderer/app/stores/VotingStore.ts @@ -22,6 +22,7 @@ import type { VotingMetadataType, } from '../api/transactions/types'; import type { CatalystFund } from '../api/voting/types'; +import { EventCategories } from '../analytics'; export type VotingRegistrationKeyType = { bytes: (...args: Array) => any; @@ -406,7 +407,7 @@ export default class VotingStore extends Store { this._setQrCode(formattedArrayBufferToHexString(encrypt)); this._nextRegistrationStep(); - this.analytics.sendEvent('Voting', 'Registered for voting'); + this.analytics.sendEvent(EventCategories.VOTING, 'Registered for voting'); }; _saveAsPDF = async () => { const { qrCode, selectedWalletId } = this; diff --git a/source/renderer/app/stores/WalletMigrationStore.ts b/source/renderer/app/stores/WalletMigrationStore.ts index 057ee165c7..ee07ac5f5a 100644 --- a/source/renderer/app/stores/WalletMigrationStore.ts +++ b/source/renderer/app/stores/WalletMigrationStore.ts @@ -29,6 +29,7 @@ import { import { IMPORT_WALLET_STEPS } from '../config/walletRestoreConfig'; import { IS_AUTOMATIC_WALLET_MIGRATION_ENABLED } from '../config/walletsConfig'; import type { ImportWalletStep } from '../types/walletRestoreTypes'; +import { EventCategories } from '../analytics'; export type WalletMigrationStatus = | 'unstarted' @@ -312,7 +313,10 @@ export default class WalletMigrationStore extends Store { this.isRestorationRunning = false; }); - this.analytics.sendEvent('Wallets', 'Restored legacy wallet(s)'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Restored legacy wallet(s)' + ); }; @action _restoreWallet = async (exportedWallet: ExportedByronWallet) => { diff --git a/source/renderer/app/stores/WalletSettingsStore.ts b/source/renderer/app/stores/WalletSettingsStore.ts index f63b4a2d40..68b8f5ae2f 100644 --- a/source/renderer/app/stores/WalletSettingsStore.ts +++ b/source/renderer/app/stores/WalletSettingsStore.ts @@ -11,6 +11,7 @@ import type { WalletExportToFileParams } from '../actions/wallet-settings-action import type { WalletUtxos } from '../api/wallets/types'; import type { WalletLocalData } from '../api/utils/localStorage'; import { RECOVERY_PHRASE_VERIFICATION_STATUSES } from '../config/walletRecoveryPhraseVerificationConfig'; +import { EventCategories } from '../analytics'; export default class WalletSettingsStore extends Store { @observable @@ -157,7 +158,7 @@ export default class WalletSettingsStore extends Store { this.updateSpendingPasswordRequest.reset(); this.stores.wallets.refreshWalletsData(); this.analytics.sendEvent( - 'Wallet Settings', + EventCategories.WALLETS, 'Changed wallet settings', 'password' ); @@ -195,7 +196,7 @@ export default class WalletSettingsStore extends Store { this.updateWalletRequest.reset(); this.stores.wallets.refreshWalletsData(); this.analytics.sendEvent( - 'Wallet Settings', + EventCategories.WALLETS, 'Changed wallet settings', field ); @@ -289,7 +290,10 @@ export default class WalletSettingsStore extends Store { const isCorrect = walletId === activeWalletId; const nextStep = isCorrect ? 3 : 4; - this.analytics.sendEvent('Wallets', 'Verified recovery phrase'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Verified recovery phrase' + ); if (isCorrect) { const recoveryPhraseVerificationDate = new Date(); diff --git a/source/renderer/app/stores/WalletsStore.ts b/source/renderer/app/stores/WalletsStore.ts index b7ebf5a38f..7032203c81 100644 --- a/source/renderer/app/stores/WalletsStore.ts +++ b/source/renderer/app/stores/WalletsStore.ts @@ -57,6 +57,7 @@ import type { HardwareWalletExtendedPublicKeyResponse, } from '../../../common/types/hardware-wallets.types'; import { NetworkMagics } from '../../../common/types/cardano-node.types'; +import { EventCategories } from '../analytics'; /* eslint-disable consistent-return */ /** @@ -365,7 +366,10 @@ export default class WalletsStore extends Store { runInAction('update account public key', () => { this.activePublicKey = accountPublicKey; }); - this.analytics.sendEvent('Wallets', 'Reveal wallet public key'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Reveal wallet public key' + ); } catch (error) { throw error; } @@ -398,7 +402,10 @@ export default class WalletsStore extends Store { runInAction('update ICO public key', () => { this.icoPublicKey = icoPublicKey; }); - this.analytics.sendEvent('Wallets', 'Reveal wallet public key'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Reveal wallet public key' + ); } catch (error) { throw error; } @@ -467,7 +474,7 @@ export default class WalletsStore extends Store { this.refreshWalletsData(); this.analytics.sendEvent( - 'Wallets', + EventCategories.WALLETS, 'Restored a software wallet', this.walletKind ); @@ -626,7 +633,10 @@ export default class WalletsStore extends Store { this.goToWalletRoute(wallet.id); this.refreshWalletsData(); this.actions.dialogs.closeActiveDialog.trigger(); - this.analytics.sendEvent('Wallets', 'Created a new hardware wallet'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Created a new hardware wallet' + ); } } catch (error) { throw error; @@ -647,7 +657,10 @@ export default class WalletsStore extends Store { this.actions.dialogs.closeActiveDialog.trigger(); this.goToWalletRoute(wallet.id); this.refreshWalletsData(); - this.analytics.sendEvent('Wallets', 'Created a new software wallet'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Created a new software wallet' + ); } }; _deleteWallet = async (params: { walletId: string; isLegacy: boolean }) => { @@ -692,7 +705,7 @@ export default class WalletsStore extends Store { }); this.analytics.sendEvent( - 'Wallets', + EventCategories.WALLETS, 'Wallet deleted', walletToDelete.isHardwareWallet ? 'Hardware wallet' : 'Software wallet' ); @@ -833,7 +846,11 @@ export default class WalletsStore extends Store { assets: formattedAssets, hasAssetsRemainingAfterTransaction, }); - this.analytics.sendEvent('Wallets', 'Transaction made', 'Software wallet'); + this.analytics.sendEvent( + EventCategories.WALLETS, + 'Transaction made', + 'Software wallet' + ); this.refreshWalletsData(); this.actions.dialogs.closeActiveDialog.trigger(); this.sendMoneyRequest.reset(); @@ -1526,7 +1543,7 @@ export default class WalletsStore extends Store { walletAddress, }); this.analytics.sendEvent( - 'Wallets', + EventCategories.WALLETS, 'Saved wallet address as PDF', 'Software wallet' ); @@ -1551,7 +1568,7 @@ export default class WalletsStore extends Store { walletAddress, }); this.analytics.sendEvent( - 'Wallets', + EventCategories.WALLETS, 'Saved wallet address as QR code', 'Software wallet' );