diff --git a/UnstoppableWallet/UnstoppableWallet/Models/Stats.swift b/UnstoppableWallet/UnstoppableWallet/Models/Stats.swift index 0ed18a22d1..d07ba103ae 100644 --- a/UnstoppableWallet/UnstoppableWallet/Models/Stats.swift +++ b/UnstoppableWallet/UnstoppableWallet/Models/Stats.swift @@ -21,6 +21,7 @@ enum StatPage: String { case blockchainSettingsBtc = "blockchain_settings_btc" case blockchainSettingsEvm = "blockchain_settings_evm" case blockchainSettingsEvmAdd = "blockchain_settings_evm_add" + case cexWithdrawConfirmation = "cex_withdraw_confirmation" case cloudBackup = "cloud_backup" case coinAnalytics = "coin_analytics" case coinAnalyticsActiveAddresses = "coin_analytics_active_addresses" @@ -42,10 +43,13 @@ enum StatPage: String { case coinRankHolders = "coin_rank_holders" case coinRankRevenue = "coin_rank_revenue" case coinRankTxCount = "coin_rank_tx_count" + case contactAddToExisting = "contact_add_to_existing" + case contactNew = "contact_new" case contacts case contactUs = "contact_us" case donate case donateAddressList = "donate_address_list" + case doubleSpend = "double_spend" case evmAddress = "evm_address" case evmPrivateKey = "evm_private_key" case exportFull = "export_full" @@ -96,10 +100,12 @@ enum StatPage: String { case receive case receiveTokenList = "receive_token_list" case recoveryPhrase = "recovery_phrase" + case resend case restoreSelect = "restore_select" case scanQrCode = "scan_qr_code" case security case send + case sendConfirmation = "send_confirmation" case sendTokenList = "send_token_list" case settings case swap @@ -122,9 +128,16 @@ enum StatPage: String { } enum StatSection: String { + case addressFrom = "address_from" + case addressRecipient = "address_recipient" + case addressSpender = "address_spender" + case addressTo = "address_to" + case input case popular case recent case searchResults = "search_results" + case status + case timeLock = "time_lock" case topGainers = "top_gainers" case topLosers = "top_losers" case topPlatforms = "top_platforms" @@ -156,6 +169,7 @@ enum StatEvent { case openCoin(coinUid: String) case openPlatform(chainUid: String) case openReceive(token: Token) + case openResend(chainUid: String, type: String) case openSend(token: Token) case openTokenInfo(token: Token) case openTokenPage(element: WalletModule.Element) @@ -167,7 +181,7 @@ enum StatEvent { case scanQr(entity: StatEntity) case select(entity: StatEntity) case setAmount - case share + case share(entity: StatEntity) case switchBtcSource(chainUid: String, type: BtcRestoreMode) case switchChartPeriod(period: StatPeriod) case switchEvmSource(chainUid: String, name: String) @@ -182,6 +196,7 @@ enum StatEvent { case toggleConversionCoin case toggleHidden case toggleIndicators(shown: Bool) + case togglePrice case toggleSortDirection case toggleTvlField case watchWallet(walletType: String) @@ -203,7 +218,7 @@ enum StatEvent { case .exportFull: return "export_full" case .importFull: return "import_full" case .importWallet: return "import_wallet" - case .open, .openCategory, .openCoin, .openPlatform, .openReceive, .openSend, .openTokenPage, + case .open, .openCategory, .openCoin, .openPlatform, .openReceive, .openResend, .openSend, .openTokenPage, .openBlockchainSettingsBtc, .openBlockchainSettingsEvm, .openBlockchainSettingsEvmAdd: return "open_page" case .openTokenInfo: return "open_token_info" case .paste: return "paste" @@ -229,6 +244,7 @@ enum StatEvent { case .toggleConversionCoin: return "toggle_conversion_coin" case .toggleHidden: return "toggle_hidden" case .toggleIndicators: return "toggle_indicators" + case .togglePrice: return "toggle_price" case .toggleSortDirection: return "toggle_sort_direction" case .toggleTvlField: return "toggle_tvl_field" case .watchWallet: return "watch_wallet" @@ -259,6 +275,7 @@ enum StatEvent { case let .openCoin(coinUid): return [.page: StatPage.coinPage.rawValue, .coinUid: coinUid] case let .openPlatform(chainUid): return [.page: StatPage.topPlatform.rawValue, .chainUid: chainUid] case let .openReceive(token): return params(token: token).merging([.page: StatPage.receive.rawValue]) { $1 } + case let .openResend(chainUid, type): return [.page: StatPage.resend.rawValue, .chainUid: chainUid, .type: type] case let .openSend(token): return params(token: token).merging([.page: StatPage.send.rawValue]) { $1 } case let .openTokenPage(element): var params: [StatParam: Any] = [.page: StatPage.tokenPage.rawValue] @@ -272,6 +289,7 @@ enum StatEvent { case let .removeFromWatchlist(coinUid): return [.coinUid: coinUid] case let .scanQr(entity): return [.entity: entity.rawValue] case let .select(entity): return [.entity: entity.rawValue] + case let .share(entity): return [.entity: entity.rawValue] case let .switchBtcSource(chainUid, type): return [.chainUid: chainUid, .type: type.rawValue] case let .switchChartPeriod(period): return [.period: period.rawValue] case let .switchEvmSource(chainUid, name): return [.chainUid: chainUid, .type: name] @@ -375,6 +393,7 @@ enum StatEntity: String { case receiveAddress = "receive_address" case recoveryPhrase = "recovery_phrase" case token + case transactionId = "transaction_id" case wallet case walletName = "wallet_name" } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Cex/CexWithdrawConfirm/CexWithdrawConfirmViewController.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Cex/CexWithdrawConfirm/CexWithdrawConfirmViewController.swift index 5bc429f51b..a689b5921a 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Cex/CexWithdrawConfirm/CexWithdrawConfirmViewController.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Cex/CexWithdrawConfirm/CexWithdrawConfirmViewController.swift @@ -124,14 +124,14 @@ extension CexWithdrawConfirmViewController: SectionsDataSource { switch viewItem { case let .amount(title, iconUrl, iconPlaceholderImageName, coinAmount, currencyAmount, type): return CellComponent.amountRow(tableView: tableView, rowInfo: rowInfo, title: title, imageUrl: iconUrl, placeholderImageName: iconPlaceholderImageName, coinAmount: coinAmount, currencyAmount: currencyAmount, type: type) - case let .address(title, value, contactAddress): + case let .address(title, value, contactAddress, statSection): var onAddToContact: (() -> Void)? = nil if let contactAddress { onAddToContact = { [weak self] in - ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self) + ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self, statPage: .cexWithdrawConfirmation, statSection: statSection) } } - return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: title, value: value, valueTitle: nil, onAddToContact: onAddToContact) + return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: title, value: value, valueTitle: nil, statPage: .cexWithdrawConfirmation, statSection: statSection, onAddToContact: onAddToContact) case let .value(title, value, type): return CellComponent.valueRow(tableView: tableView, rowInfo: rowInfo, iconName: nil, title: title, value: value, type: type) case let .feeValue(title, coinAmount, currencyAmount): diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Cex/CexWithdrawConfirm/CexWithdrawConfirmViewModel.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Cex/CexWithdrawConfirm/CexWithdrawConfirmViewModel.swift index 50f1b3b48a..2901d99db6 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Cex/CexWithdrawConfirm/CexWithdrawConfirmViewModel.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Cex/CexWithdrawConfirm/CexWithdrawConfirmViewModel.swift @@ -78,7 +78,8 @@ class CexWithdrawConfirmViewModel { .address( title: "send.confirmation.to".localized, value: service.address, - contactAddress: contactData?.contactAddress + contactAddress: contactData?.contactAddress, + statSection: .addressTo ), ] @@ -111,7 +112,7 @@ extension CexWithdrawConfirmViewModel { enum ViewItem { case amount(title: String, iconUrl: String?, iconPlaceholderImageName: String, coinAmount: String, currencyAmount: String?, type: AmountType) - case address(title: String, value: String, contactAddress: ContactAddress?) + case address(title: String, value: String, contactAddress: ContactAddress?, statSection: StatSection) case value(title: String, value: String, type: ValueType) case feeValue(title: String, coinAmount: String, currencyAmount: String?) } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/ContactBook/ContactBookList/ContactBookModule.swift b/UnstoppableWallet/UnstoppableWallet/Modules/ContactBook/ContactBookList/ContactBookModule.swift index 6b7eab61a8..919ec5ccae 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/ContactBook/ContactBookList/ContactBookModule.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/ContactBook/ContactBookList/ContactBookModule.swift @@ -10,19 +10,23 @@ protocol ContactBookSelectorDelegate: AnyObject { } enum ContactBookModule { - private static func showAddContact(mode: ContactBookModule.AddContactMode, contactAddress: ContactAddress) -> UIViewController? { + private static func showAddContact(mode: ContactBookModule.AddContactMode, contactAddress: ContactAddress, statPage: StatPage, statSection: StatSection? = nil) -> UIViewController? { switch mode { case .new: guard let module = ContactBookContactModule.viewController(mode: .add(contactAddress)) else { return nil } + stat(page: statPage, section: statSection, event: .open(page: .contactNew)) + return module case .exist: guard let module = ContactBookModule.viewController(mode: .addToContact(contactAddress), presented: true) else { return nil } + stat(page: statPage, section: statSection, event: .open(page: .contactAddToExisting)) + return module } } @@ -59,16 +63,16 @@ extension ContactBookModule { } } - static func showAddition(contactAddress: ContactAddress, parentViewController: UIViewController?) { + static func showAddition(contactAddress: ContactAddress, parentViewController: UIViewController?, statPage: StatPage, statSection: StatSection? = nil) { // if all contacts has address for blockchain just show add-new controller - if App.shared.contactManager.all?.isEmpty ?? true, let controller = showAddContact(mode: .new, contactAddress: contactAddress) { + if App.shared.contactManager.all?.isEmpty ?? true, let controller = showAddContact(mode: .new, contactAddress: contactAddress, statPage: statPage, statSection: statSection) { parentViewController?.present(controller, animated: true) return } // show alert and choose make new contact or add to existed let alertController = ContactBookModule.chooseAddContactMode(resultAfterClose: true) { [weak parentViewController] mode in - guard let controller = showAddContact(mode: mode, contactAddress: contactAddress) else { + guard let controller = showAddContact(mode: mode, contactAddress: contactAddress, statPage: statPage, statSection: statSection) else { return } parentViewController?.present(controller, animated: true) diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/ResendBitcoin/ResendBitcoinViewController.swift b/UnstoppableWallet/UnstoppableWallet/Modules/ResendBitcoin/ResendBitcoinViewController.swift index 8c174587f7..dc197218be 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/ResendBitcoin/ResendBitcoinViewController.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/ResendBitcoin/ResendBitcoinViewController.swift @@ -111,14 +111,14 @@ class ResendBitcoinViewController: KeyboardAwareViewController, SectionsDataSour switch viewItem { case let .amount(title, token, coinAmount, currencyAmount, type): return CellComponent.amountRow(tableView: tableView, rowInfo: rowInfo, title: title, subtitle: token.fullBadge, imageUrl: token.coin.imageUrl, placeholderImageName: token.placeholderImageName, coinAmount: coinAmount, currencyAmount: currencyAmount, type: type) - case let .address(title, value, valueTitle, contactAddress): + case let .address(title, value, valueTitle, contactAddress, statSection): var onAddToContact: (() -> Void)? = nil if let contactAddress { onAddToContact = { [weak self] in - ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self) + ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self, statPage: .resend, statSection: statSection) } } - return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: title, value: value, valueTitle: valueTitle, onAddToContact: onAddToContact) + return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: title, value: value, valueTitle: valueTitle, statPage: .resend, statSection: statSection, onAddToContact: onAddToContact) case let .value(iconName, title, value, type): return CellComponent.valueRow(tableView: tableView, rowInfo: rowInfo, iconName: iconName, title: title, value: value, type: type) case let .fee(title, coinValue, currencyValue): diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/ResendBitcoin/ResendBitcoinViewModel.swift b/UnstoppableWallet/UnstoppableWallet/Modules/ResendBitcoin/ResendBitcoinViewModel.swift index 2f0d584006..9a30bc303b 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/ResendBitcoin/ResendBitcoinViewModel.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/ResendBitcoin/ResendBitcoinViewModel.swift @@ -78,7 +78,8 @@ class ResendBitcoinViewModel { title: item.sentToSelf ? "send.confirmation.own".localized : "send.confirmation.to".localized, value: item.receiver.raw, valueTitle: item.receiver.title, - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressTo ) ) if let contactName = contactData.name { @@ -210,7 +211,7 @@ extension ResendBitcoinViewModel { extension ResendBitcoinViewModel { enum ViewItem { case amount(title: String, token: Token, coinAmount: String, currencyAmount: String?, type: AmountType) - case address(title: String, value: String, valueTitle: String?, contactAddress: ContactAddress?) + case address(title: String, value: String, valueTitle: String?, contactAddress: ContactAddress?, statSection: StatSection) case value(iconName: String?, title: String, value: String, type: ValueType) case fee(title: String, coinAmount: String, currencyAmount: String?) } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Send/Confirmation/SendConfirmationViewController.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Send/Confirmation/SendConfirmationViewController.swift index 8360a23d34..050e0644ce 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Send/Confirmation/SendConfirmationViewController.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Send/Confirmation/SendConfirmationViewController.swift @@ -85,14 +85,14 @@ class SendConfirmationViewController: ThemeViewController, SectionsDataSource { switch viewItem { case let .amount(title, token, coinAmount, currencyAmount, type): return CellComponent.amountRow(tableView: tableView, rowInfo: rowInfo, title: title, subtitle: token.fullBadge, imageUrl: token.coin.imageUrl, placeholderImageName: token.placeholderImageName, coinAmount: coinAmount, currencyAmount: currencyAmount, type: type) - case let .address(title, value, valueTitle, contactAddress): + case let .address(title, value, valueTitle, contactAddress, statSection): var onAddToContact: (() -> Void)? = nil if let contactAddress { onAddToContact = { [weak self] in - ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self) + ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self, statPage: .sendConfirmation, statSection: statSection) } } - return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: title, value: value, valueTitle: valueTitle, onAddToContact: onAddToContact) + return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: title, value: value, valueTitle: valueTitle, statPage: .sendConfirmation, statSection: statSection, onAddToContact: onAddToContact) case let .value(iconName, title, value, type): return CellComponent.valueRow(tableView: tableView, rowInfo: rowInfo, iconName: iconName, title: title, value: value, type: type) } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Send/Confirmation/SendConfirmationViewModel.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Send/Confirmation/SendConfirmationViewModel.swift index 163e13202d..7b473eeda4 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Send/Confirmation/SendConfirmationViewModel.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Send/Confirmation/SendConfirmationViewModel.swift @@ -56,7 +56,8 @@ class SendConfirmationViewModel { title: "send.confirmation.to".localized, value: item.receiver.raw, valueTitle: item.receiver.title, - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressTo ) ) if let contactName = contactData.name { @@ -163,7 +164,7 @@ extension SendConfirmationViewModel { extension SendConfirmationViewModel { enum ViewItem { case amount(title: String, token: Token, coinAmount: String, currencyAmount: String?, type: AmountType) - case address(title: String, value: String, valueTitle: String?, contactAddress: ContactAddress?) + case address(title: String, value: String, valueTitle: String?, contactAddress: ContactAddress?, statSection: StatSection) case value(iconName: String?, title: String, value: String, type: ValueType) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/SendEvm/Confirmation/SendEvmConfirmationModule.swift b/UnstoppableWallet/UnstoppableWallet/Modules/SendEvm/Confirmation/SendEvmConfirmationModule.swift index ef33a6db12..ab424ebc61 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/SendEvm/Confirmation/SendEvmConfirmationModule.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/SendEvm/Confirmation/SendEvmConfirmationModule.swift @@ -181,7 +181,7 @@ extension SendEvmConfirmationModule { } } -enum ResendTransactionType { - case speedUp +enum ResendTransactionType: String { + case speedUp = "speed_up" case cancel } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/SendEvmTransaction/SendEvmTransactionViewController.swift b/UnstoppableWallet/UnstoppableWallet/Modules/SendEvmTransaction/SendEvmTransactionViewController.swift index 3e45b3844e..05d4a56f89 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/SendEvmTransaction/SendEvmTransactionViewController.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/SendEvmTransaction/SendEvmTransactionViewController.swift @@ -158,18 +158,18 @@ class SendEvmTransactionViewController: ThemeViewController { return CellComponent.nftAmountRow(tableView: tableView, rowInfo: rowInfo, iconUrl: iconUrl, iconPlaceholderImageName: iconPlaceholderImageName, nftAmount: nftAmount, type: type, onTapOpenNft: nil) case let .doubleAmount(title, coinValue, currencyValue): return CellComponent.doubleAmountRow(tableView: tableView, rowInfo: rowInfo, title: title, coinValue: coinValue, currencyValue: currencyValue) - case let .address(title, value, valueTitle, contactAddress): + case let .address(title, value, valueTitle, contactAddress, statSection): var onAddToContact: (() -> Void)? = nil if let contactAddress { onAddToContact = { [weak self] in - ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self) + ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self, statPage: .send, statSection: statSection) } } - return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: title, value: value, valueTitle: valueTitle, onAddToContact: onAddToContact) + return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: title, value: value, valueTitle: valueTitle, statPage: .send, statSection: statSection, onAddToContact: onAddToContact) case let .value(title, value, type): return CellComponent.valueRow(tableView: tableView, rowInfo: rowInfo, iconName: nil, title: title, value: value, type: type) case let .input(value): - return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: "Input", value: value, valueTitle: nil) + return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: "Input", value: value, valueTitle: nil, statPage: .send, statSection: .input) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/SendEvmTransaction/SendEvmTransactionViewModel.swift b/UnstoppableWallet/UnstoppableWallet/Modules/SendEvmTransaction/SendEvmTransactionViewModel.swift index 9853f6537d..7da1b9bfe3 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/SendEvmTransaction/SendEvmTransactionViewModel.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/SendEvmTransaction/SendEvmTransactionViewModel.swift @@ -286,7 +286,8 @@ class SendEvmTransactionViewModel { title: "send.confirmation.to".localized, value: toValue, valueTitle: sendInfo?.domain ?? evmLabelManager.addressLabel(address: toValue), - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressTo ), ] @@ -324,7 +325,8 @@ class SendEvmTransactionViewModel { title: "send.confirmation.to".localized, value: addressValue, valueTitle: addressTitle, - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressTo ) ) if let contactName = contactData.name { @@ -356,7 +358,8 @@ class SendEvmTransactionViewModel { title: "send.confirmation.to".localized, value: addressValue, valueTitle: addressTitle, - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressTo ) ) if let contactName = contactData.name { @@ -402,7 +405,8 @@ class SendEvmTransactionViewModel { title: "approve.confirmation.spender".localized, value: addressValue, valueTitle: addressTitle, - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressSpender ), ] @@ -474,7 +478,8 @@ class SendEvmTransactionViewModel { title: "swap.advanced_settings.recipient_address".localized, value: addressValue, valueTitle: addressTitle, - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressRecipient ) ) if let contactName = contactData.name { @@ -620,7 +625,8 @@ class SendEvmTransactionViewModel { title: "swap.advanced_settings.recipient_address".localized, value: addressValue, valueTitle: addressTitle, - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressRecipient ) ) if let contactName = contactData.name { @@ -646,7 +652,8 @@ class SendEvmTransactionViewModel { title: "send.confirmation.to".localized, value: toValue, valueTitle: evmLabelManager.addressLabel(address: toValue), - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressTo ), ] @@ -731,7 +738,7 @@ extension SendEvmTransactionViewModel { case amount(title: String, token: MarketKit.Token, coinAmount: String, currencyAmount: String?, type: AmountType) case nftAmount(iconUrl: String?, iconPlaceholderImageName: String, nftAmount: String, type: AmountType) case doubleAmount(title: String, coinAmount: String, currencyAmount: String?) - case address(title: String, value: String, valueTitle: String?, contactAddress: ContactAddress?) + case address(title: String, value: String, valueTitle: String?, contactAddress: ContactAddress?, statSection: StatSection) case value(title: String, value: String, type: ValueType) case input(value: String) } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/SendTron/Confirmation/SendTronConfirmationViewController.swift b/UnstoppableWallet/UnstoppableWallet/Modules/SendTron/Confirmation/SendTronConfirmationViewController.swift index 4618385a8d..3f6e21e4a3 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/SendTron/Confirmation/SendTronConfirmationViewController.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/SendTron/Confirmation/SendTronConfirmationViewController.swift @@ -138,14 +138,14 @@ class SendTronConfirmationViewController: ThemeViewController { switch viewItem { case let .amount(title, token, coinAmount, currencyAmount, type): return CellComponent.amountRow(tableView: tableView, rowInfo: rowInfo, title: title, subtitle: token.fullBadge, imageUrl: token.coin.imageUrl, placeholderImageName: token.placeholderImageName, coinAmount: coinAmount, currencyAmount: currencyAmount, type: type) - case let .address(title, value, valueTitle, contactAddress): + case let .address(title, value, valueTitle, contactAddress, statSection): var onAddToContact: (() -> Void)? = nil if let contactAddress { onAddToContact = { [weak self] in - ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self) + ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self, statPage: .send, statSection: statSection) } } - return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: title, value: value, valueTitle: valueTitle, onAddToContact: onAddToContact) + return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: title, value: value, valueTitle: valueTitle, statPage: .send, statSection: statSection, onAddToContact: onAddToContact) case let .value(title, value, type): return CellComponent.valueRow(tableView: tableView, rowInfo: rowInfo, iconName: nil, title: title, value: value, type: type) case let .warning(text, title, info): diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/SendTron/Confirmation/SendTronConfirmationViewModel.swift b/UnstoppableWallet/UnstoppableWallet/Modules/SendTron/Confirmation/SendTronConfirmationViewModel.swift index bf64aae69b..fc89cdf593 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/SendTron/Confirmation/SendTronConfirmationViewModel.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/SendTron/Confirmation/SendTronConfirmationViewModel.swift @@ -241,7 +241,8 @@ class SendTronConfirmationViewModel { title: "send.confirmation.to".localized, value: toValue, valueTitle: evmLabelManager.addressLabel(address: toValue), - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressTo ), ] @@ -275,7 +276,8 @@ class SendTronConfirmationViewModel { title: "send.confirmation.to".localized, value: addressValue, valueTitle: addressTitle, - contactAddress: contactData.contactAddress + contactAddress: contactData.contactAddress, + statSection: .addressTo ) ) if let contactName = contactData.name { @@ -331,7 +333,7 @@ extension SendTronConfirmationViewModel { enum ViewItem { case amount(title: String, token: MarketKit.Token, coinAmount: String, currencyAmount: String?, type: AmountType) - case address(title: String, value: String, valueTitle: String?, contactAddress: ContactAddress?) + case address(title: String, value: String, valueTitle: String?, contactAddress: ContactAddress?, statSection: StatSection) case value(title: String, value: String, type: ValueType) case warning(text: String, title: String, info: String) } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupAppViewModel.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupAppViewModel.swift index 4ccd8da1d7..0d12ce176b 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupAppViewModel.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupAppViewModel.swift @@ -277,8 +277,8 @@ extension BackupAppViewModel { var statPage: StatPage { switch destination { - case .cloud: return .exportFullToCloud - default: return .exportFullToFiles + case .cloud: return .exportFullToCloud + default: return .exportFullToFiles } } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupPassword/BackupPasswordView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupPassword/BackupPasswordView.swift index 619f8d07e1..f3734d8f69 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupPassword/BackupPasswordView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupPassword/BackupPasswordView.swift @@ -70,7 +70,7 @@ struct BackupPasswordView: View { let completion: UIActivityViewController.CompletionWithItemsHandler = { _, success, _, error in if success { stat(page: .exportFullToFiles, event: .exportFull) - + onDismiss?() showDone() } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupType/BackupTypeView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupType/BackupTypeView.swift index dab13f53b0..e4d85938cd 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupType/BackupTypeView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/Backup/BackupType/BackupTypeView.swift @@ -79,7 +79,7 @@ struct BackupTypeView: View { let statPage = viewModel.statPage if isAvailable.wrappedValue { NavigationRow( - destination: { + destination: { BackupListView(viewModel: viewModel, onDismiss: onDismiss) .modifier(FirstAppear { stat(page: .exportFull, event: .open(page: statPage)) }) }, diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/BackupManagerLegacy/BackupManagerViewController.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/BackupManagerLegacy/BackupManagerViewController.swift index 1075207d18..8184d16a29 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/BackupManagerLegacy/BackupManagerViewController.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/BackupApp/BackupManagerLegacy/BackupManagerViewController.swift @@ -74,8 +74,8 @@ class BackupManagerViewController: ThemeViewController { private func onCreate() { let viewController = BackupTypeView { [weak self] in - (self?.presentedViewController ?? self)?.dismiss(animated: true) - }.toNavigationViewController() + (self?.presentedViewController ?? self)?.dismiss(animated: true) + }.toNavigationViewController() stat(page: .backupManager, event: .open(page: .exportFull)) present(viewController, animated: true) diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewController.swift b/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewController.swift index 2932afb0ff..92f98236ee 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewController.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewController.swift @@ -76,16 +76,22 @@ class TransactionInfoViewController: ThemeViewController { private func openStatusInfo() { present(InfoModule.transactionStatusInfo, animated: true) + + stat(page: .transactionInfo, section: .status, event: .open(page: .info)) } private func openResend(type: ResendTransactionType) { do { - if adapter is BaseEvmAdapter { + if let evmAdapter = adapter as? BaseEvmAdapter { let viewController = try SendEvmConfirmationModule.resendViewController(adapter: adapter, type: type, transactionHash: viewModel.transactionHash) present(ThemeNavigationController(rootViewController: viewController), animated: true) - } else if adapter is BitcoinBaseAdapter, let transactionRecord = viewModel.transactionRecord as? BitcoinTransactionRecord { + + stat(page: .transactionInfo, event: .openResend(chainUid: evmAdapter.evmKitWrapper.blockchainType.uid, type: type.rawValue)) + } else if let btcAdapter = adapter as? BitcoinBaseAdapter, let transactionRecord = viewModel.transactionRecord as? BitcoinTransactionRecord { let viewController = try ResendBitcoinModule.resendViewController(adapter: adapter, type: type, transactionRecord: transactionRecord) present(ThemeNavigationController(rootViewController: viewController), animated: true) + + stat(page: .transactionInfo, event: .openResend(chainUid: btcAdapter.token.blockchainType.uid, type: type.rawValue)) } } catch { HudHelper.instance.show(banner: .error(string: error.localizedDescription)) @@ -98,6 +104,7 @@ class TransactionInfoViewController: ThemeViewController { } present(module, animated: true) + stat(page: .transactionInfo, event: .openCoin(coinUid: coinUid)) } @@ -106,10 +113,6 @@ class TransactionInfoViewController: ThemeViewController { present(ThemeNavigationController(rootViewController: module), animated: true) } - private func togglePrice() { - viewModel.togglePrice() - } - private func statusRow(rowInfo: RowInfo, status: TransactionStatus) -> RowProtocol { let hash: String var value: String @@ -210,40 +213,40 @@ class TransactionInfoViewController: ThemeViewController { var onAddToContact: (() -> Void)? = nil if let contactAddress { onAddToContact = { [weak self] in - ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self) + ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self, statPage: .transactionInfo, statSection: .addressFrom) } } - return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: "tx_info.from_hash".localized, value: value, valueTitle: valueTitle, onAddToContact: onAddToContact) + return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: "tx_info.from_hash".localized, value: value, valueTitle: valueTitle, statPage: .transactionInfo, statSection: .addressFrom, onAddToContact: onAddToContact) } private func toRow(rowInfo: RowInfo, value: String, valueTitle: String?, contactAddress: ContactAddress?) -> RowProtocol { var onAddToContact: (() -> Void)? = nil if let contactAddress { onAddToContact = { [weak self] in - ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self) + ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self, statPage: .transactionInfo, statSection: .addressTo) } } - return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: "tx_info.to_hash".localized, value: value, valueTitle: valueTitle, onAddToContact: onAddToContact) + return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: "tx_info.to_hash".localized, value: value, valueTitle: valueTitle, statPage: .transactionInfo, statSection: .addressTo, onAddToContact: onAddToContact) } private func spenderRow(rowInfo: RowInfo, value: String, valueTitle: String?, contactAddress: ContactAddress?) -> RowProtocol { var onAddToContact: (() -> Void)? = nil if let contactAddress { onAddToContact = { [weak self] in - ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self) + ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self, statPage: .transactionInfo, statSection: .addressSpender) } } - return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: "tx_info.spender".localized, value: value, valueTitle: valueTitle, onAddToContact: onAddToContact) + return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: "tx_info.spender".localized, value: value, valueTitle: valueTitle, statPage: .transactionInfo, statSection: .addressSpender, onAddToContact: onAddToContact) } private func recipientRow(rowInfo: RowInfo, value: String, valueTitle: String?, contactAddress: ContactAddress?) -> RowProtocol { var onAddToContact: (() -> Void)? = nil if let contactAddress { onAddToContact = { [weak self] in - ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self) + ContactBookModule.showAddition(contactAddress: contactAddress, parentViewController: self, statPage: .transactionInfo, statSection: .addressRecipient) } } - return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: "tx_info.recipient_hash".localized, value: value, valueTitle: valueTitle, onAddToContact: onAddToContact) + return CellComponent.fromToRow(tableView: tableView, rowInfo: rowInfo, title: "tx_info.recipient_hash".localized, value: value, valueTitle: valueTitle, statPage: .transactionInfo, statSection: .addressRecipient, onAddToContact: onAddToContact) } private func idRow(rowInfo: RowInfo, value: String) -> RowProtocol { @@ -256,6 +259,7 @@ class TransactionInfoViewController: ThemeViewController { component.button.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) component.onTap = { CopyHelper.copyAndNotify(value: value) + stat(page: .transactionInfo, event: .copy(entity: .transactionId)) } }, .secondaryCircleButton { [weak self] (component: SecondaryCircleButtonComponent) in @@ -263,6 +267,7 @@ class TransactionInfoViewController: ThemeViewController { component.onTap = { let activityViewController = UIActivityViewController(activityItems: [value], applicationActivities: []) self?.present(activityViewController, animated: true) + stat(page: .transactionInfo, event: .share(entity: .transactionId)) } }, ]), @@ -363,6 +368,8 @@ class TransactionInfoViewController: ThemeViewController { ) { [weak self] in let viewController = DoubleSpendInfoViewController(transactionHash: txHash, conflictingTransactionHash: conflictingTxHash) self?.present(ThemeNavigationController(rootViewController: viewController), animated: true) + + stat(page: .transactionInfo, event: .open(page: .doubleSpend)) } } @@ -374,6 +381,8 @@ class TransactionInfoViewController: ThemeViewController { if lockState.locked { return warningRow(rowInfo: rowInfo, id: id, image: image, text: "tx_info.locked_until".localized(formattedDate)) { [weak self] in self?.present(InfoModule.timeLockInfo, animated: true) + + stat(page: .transactionInfo, section: .timeLock, event: .open(page: .info)) } } else { return noteRow(rowInfo: rowInfo, id: id, image: image, text: "tx_info.unlocked_at".localized(formattedDate)) @@ -456,6 +465,8 @@ class TransactionInfoViewController: ThemeViewController { action: { [weak self] in if let url { self?.urlManager.open(url: url, from: self) + + stat(page: .transactionInfo, event: .open(page: .externalBlockExplorer)) } } ) diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewModel.swift b/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewModel.swift index 11297f6815..74a45b6904 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewModel.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewModel.swift @@ -54,5 +54,7 @@ extension TransactionInfoViewModel { func togglePrice() { factory.priceReversed.toggle() reSyncServiceItem() + + stat(page: .transactionInfo, event: .togglePrice) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Wallet/Receive/Address/ReceiveAddressView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Wallet/Receive/Address/ReceiveAddressView.swift index b32eb8b3a0..9e04c6a6c5 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Wallet/Receive/Address/ReceiveAddressView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Wallet/Receive/Address/ReceiveAddressView.swift @@ -197,7 +197,7 @@ struct ReceiveAddressView: View { inputAmountPresented = true case .share: shareText = data.copyValue - stat(page: .receive, event: .share) + stat(page: .receive, event: .share(entity: .receiveAddress)) case .copy: CopyHelper.copyAndNotify(value: data.copyValue) stat(page: .receive, event: .copy(entity: .receiveAddress)) diff --git a/UnstoppableWallet/UnstoppableWallet/UserInterface/CellComponent.swift b/UnstoppableWallet/UnstoppableWallet/UserInterface/CellComponent.swift index e3ddd5415d..037c802aba 100644 --- a/UnstoppableWallet/UnstoppableWallet/UserInterface/CellComponent.swift +++ b/UnstoppableWallet/UnstoppableWallet/UserInterface/CellComponent.swift @@ -151,7 +151,7 @@ enum CellComponent { ) } - static func fromToRow(tableView: UITableView, rowInfo: RowInfo, title: String, value: String, valueTitle _: String?, onAddToContact: (() -> Void)? = nil) -> RowProtocol { + static func fromToRow(tableView: UITableView, rowInfo: RowInfo, title: String, value: String, valueTitle _: String?, statPage: StatPage, statSection: StatSection, onAddToContact: (() -> Void)? = nil) -> RowProtocol { let backgroundStyle: BaseThemeCell.BackgroundStyle = .lawrence let titleFont: UIFont = .subhead2 let valueFont: UIFont = .subhead1 @@ -183,6 +183,7 @@ enum CellComponent { component.button.set(image: UIImage(named: "copy_20")) component.onTap = { CopyHelper.copyAndNotify(value: value) + stat(page: statPage, section: statSection, event: .copy(entity: .address)) } }, ]),