Last active
June 27, 2018 14:36
-
-
Save kuyazee/50c7ea0abc29d9e9a869d1373600d96d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum AnalyticsEvent: AnalyticsEventProtocol { | |
case userLoggedIn | |
case userLoggedOut | |
case productSelected(productId: Int) | |
var name: String { | |
switch self { | |
case .userLoggedIn: return "User Logged In" | |
case .userLoggedOut: return "User Logged Out" | |
case .productSelected: return "Product Selected" | |
} | |
} | |
/// The parameters before used the AnalyticsEventProtocol's default implementation which | |
/// always returned nil. Now we just have to create our own implementation based on the | |
/// cases of this enum. | |
var parameters: [String: Any]? { | |
switch self { | |
case .userLoggedIn: return nil | |
case .userLoggedOut: return nil | |
case .productSelected(id: let id): return ["product_id": productId] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment