Created
June 27, 2018 14:58
-
-
Save kuyazee/ecc51ab3625db978210d4023accc0243 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" | |
} | |
} | |
var parameters: [String: Any]? { | |
switch self { | |
case .userLoggedIn: return nil | |
case .userLoggedOut: return nil | |
case .productSelected(id: let id): return ["product_id": productId] | |
} | |
} | |
/// Add our own implementation of `isTrackedOnAnalyticsServices` instead of relying | |
/// on the default one which doens't send anything anywhere | |
var isTrackedOnAnalyticsServices: [AnalyticsServiceProtocol.Type] { | |
switch self { | |
/// will be sent on 2 services | |
case .userLoggedIn: return [FacebookAnalyticsService.self, FabricAnalyticsService.self] | |
/// will not be sent anywhere | |
case .userLoggedOut: return [] | |
/// will be sent on only one service | |
case .productSelected: return [FacebookAnalyticsService.self] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment