Log opening blockchain explorer

pull/2705/head
Hwee-Boon Yar 4 years ago
parent 58165b4431
commit 34a0c21d85
  1. 8
      AlphaWallet/Analytics/Models/AnalyticsTypes.swift
  2. 7
      AlphaWallet/InCoordinator.swift
  3. 5
      AlphaWallet/Transactions/Coordinators/TransactionCoordinator.swift
  4. 12
      AlphaWallet/Transactions/ViewControllers/TransactionViewController.swift

@ -34,6 +34,7 @@ enum Analytics {
case twitter = "Screen: Twitter"
case reddit = "Screen: Reddit"
case facebook = "Screen: Facebook"
case explorer = "Screen: Explorer"
}
enum Action: String, AnalyticsAction {
@ -67,6 +68,7 @@ enum Analytics {
case name
case messageType
case isTaiChiEnabled
case type
}
enum UserProperties: String, AnalyticsUserProperty {
@ -137,4 +139,10 @@ enum Analytics {
case eip712
case eip712v3And4
}
enum ExplorerType: String {
case transaction
case token
case wallet
}
}

@ -410,6 +410,7 @@ class InCoordinator: NSObject, Coordinator {
let transactionsStoragesForEnabledServers = config.enabledServers.map { transactionsStorages[$0] }
let transactionsCollection = TransactionCollection(transactionsStorages: transactionsStoragesForEnabledServers)
let coordinator = TransactionCoordinator(
analyticsCoordinator: analyticsCoordinator,
sessions: walletSessions,
transactionsCollection: transactionsCollection,
keystore: keystore,
@ -731,9 +732,11 @@ extension InCoordinator: CanOpenURL {
func didPressViewContractWebPage(forContract contract: AlphaWallet.Address, server: RPCServer, in viewController: UIViewController) {
if contract.sameContract(as: Constants.nativeCryptoAddressInDatabase) {
logExplorerUse(type: .wallet)
let url = server.etherscanContractDetailsWebPageURL(for: wallet.address)
open(url: url, in: viewController)
} else {
logExplorerUse(type: .token)
let url = server.etherscanTokenDetailsWebPageURL(for: contract)
open(url: url, in: viewController)
}
@ -1024,6 +1027,10 @@ extension InCoordinator {
private func logTappedSwap(service: SwapTokenURLProviderType) {
analyticsCoordinator.log(navigation: Analytics.Navigation.tokenSwap, properties: [Analytics.Properties.name.rawValue: service.analyticsName])
}
private func logExplorerUse(type: Analytics.ExplorerType) {
analyticsCoordinator.log(navigation: Analytics.Navigation.explorer, properties: [Analytics.Properties.type.rawValue: type.rawValue])
}
}
extension InCoordinator: ReplaceTransactionCoordinatorDelegate {

@ -8,6 +8,7 @@ protocol TransactionCoordinatorDelegate: class, CanOpenURL {
}
class TransactionCoordinator: Coordinator {
private let analyticsCoordinator: AnalyticsCoordinator
private let keystore: Keystore
private let transactionsCollection: TransactionCollection
private let promptBackupCoordinator: PromptBackupCoordinator
@ -34,6 +35,7 @@ class TransactionCoordinator: Coordinator {
var coordinators: [Coordinator] = []
init(
analyticsCoordinator: AnalyticsCoordinator,
sessions: ServerDictionary<WalletSession>,
navigationController: UINavigationController = UINavigationController(),
transactionsCollection: TransactionCollection,
@ -41,6 +43,7 @@ class TransactionCoordinator: Coordinator {
tokensStorages: ServerDictionary<TokensDataStore>,
promptBackupCoordinator: PromptBackupCoordinator
) {
self.analyticsCoordinator = analyticsCoordinator
self.sessions = sessions
self.keystore = keystore
self.navigationController = navigationController
@ -67,7 +70,7 @@ class TransactionCoordinator: Coordinator {
}
private func showTransaction(_ transactionRow: TransactionRow, on navigationController: UINavigationController) {
let controller = TransactionViewController(session: sessions[transactionRow.server], transactionRow: transactionRow, delegate: self)
let controller = TransactionViewController(analyticsCoordinator: analyticsCoordinator, session: sessions[transactionRow.server], transactionRow: transactionRow, delegate: self)
controller.hidesBottomBarWhenPushed = true
controller.navigationItem.largeTitleDisplayMode = .never

@ -9,6 +9,7 @@ protocol TransactionViewControllerDelegate: class, CanOpenURL {
}
class TransactionViewController: UIViewController {
private let analyticsCoordinator: AnalyticsCoordinator
private lazy var viewModel: TransactionDetailsViewModel = {
return .init(
transactionRow: transactionRow,
@ -25,7 +26,8 @@ class TransactionViewController: UIViewController {
weak var delegate: TransactionViewControllerDelegate?
init(session: WalletSession, transactionRow: TransactionRow, delegate: TransactionViewControllerDelegate?) {
init(analyticsCoordinator: AnalyticsCoordinator, session: WalletSession, transactionRow: TransactionRow, delegate: TransactionViewControllerDelegate?) {
self.analyticsCoordinator = analyticsCoordinator
self.session = session
self.transactionRow = transactionRow
self.delegate = delegate
@ -152,6 +154,7 @@ class TransactionViewController: UIViewController {
@objc func more() {
guard let url = viewModel.detailsURL else { return }
logUse()
delegate?.didPressOpenWebPage(url, in: self)
}
@ -175,3 +178,10 @@ class TransactionViewController: UIViewController {
dismiss(animated: true, completion: nil)
}
}
// MARK: Analytics
extension TransactionViewController {
private func logUse() {
analyticsCoordinator.log(navigation: Analytics.Navigation.explorer, properties: [Analytics.Properties.type.rawValue: Analytics.ExplorerType.transaction])
}
}
Loading…
Cancel
Save