Log to analytics message signing prompts

pull/2645/head
Hwee-Boon Yar 4 years ago
parent e3995c7493
commit 91594c64a5
  1. 17
      AlphaWallet/Analytics/Models/AnalyticsTypes.swift
  2. 17
      AlphaWallet/Transfer/Coordinators/SignMessageCoordinator.swift

@ -26,6 +26,7 @@ enum Analytics {
case showDapps = "Screen: Dapps"
case showHistory = "Screen: Dapp History"
case tapBrowserMore = "Screen: Browser More Options"
case signMessageRequest = "Screen: Sign Message Request"
}
enum Action: String, AnalyticsAction {
@ -36,6 +37,8 @@ enum Analytics {
case shareUrl = "Share URL"
case addDapp = "Add Dapp"
case enterUrl = "Enter URL"
case signMessageRequest = "Sign Message Request"
case cancelSignMessageRequest = "Cancel Sign Message Request"
}
enum Properties: String {
@ -49,6 +52,7 @@ enum Analytics {
case chain
case transactionType
case name
case messageType
}
enum UserProperties: String, AnalyticsUserProperty {
@ -104,4 +108,17 @@ enum Analytics {
case nativeCryptoTransfer
case unknown
}
enum SignMessageRequestSource: String {
case dappBrowser
case tokenScript
case walletConnect
}
enum SignMessageRequestType: String {
case message
case personalMessage
case eip712
case eip712v3And4
}
}

@ -54,7 +54,7 @@ class SignMessageCoordinator: Coordinator {
func start() {
guard let keyWindow = UIApplication.shared.keyWindow else { return }
analyticsCoordinator.log(navigation: Analytics.Navigation.signMessageRequest, properties: [Analytics.Properties.source.rawValue: source.rawValue, Analytics.Properties.messageType.rawValue: mapMessageToAnalyticsType(message).rawValue])
if let controller = keyWindow.rootViewController?.presentedViewController {
controller.present(navigationController, animated: false)
} else {
@ -64,6 +64,19 @@ class SignMessageCoordinator: Coordinator {
confirmationViewController.reloadView()
}
private func mapMessageToAnalyticsType(_ message: SignMessageType) -> Analytics.SignMessageRequestType {
switch message {
case .message:
return .message
case .personalMessage:
return .personalMessage
case .typedMessage:
return .eip712
case .eip712v3And4:
return .eip712v3And4
}
}
func dissmissAnimated(completion: @escaping () -> Void) {
confirmationViewController.dismissViewAnimated {
//Needs a strong self reference otherwise `self` might have been removed by its owner by the time animation completes and the `completion` block not called
@ -107,6 +120,7 @@ class SignMessageCoordinator: Coordinator {
extension SignMessageCoordinator: SignatureConfirmationViewControllerDelegate {
func controller(_ controller: SignatureConfirmationViewController, continueButtonTapped sender: UIButton) {
analyticsCoordinator.log(action: Analytics.Action.signMessageRequest)
signMessage(with: message)
}
@ -117,6 +131,7 @@ extension SignMessageCoordinator: SignatureConfirmationViewControllerDelegate {
}
func didClose(in controller: SignatureConfirmationViewController) {
analyticsCoordinator.log(action: Analytics.Action.cancelSignMessageRequest)
navigationController.dismiss(animated: false) {
guard let delegate = self.delegate else { return }
delegate.didCancel(in: self)

Loading…
Cancel
Save