Last active
April 23, 2020 08:28
-
-
Save mukyasa/e3d2024a490037719f9326603d3d064f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| protocol AnalyticsEventsLoggerProtocol { | |
| func setUserProperties(user: UserProfileModel) | |
| func trackEvent(event: EventProtocol) | |
| } | |
| // Firebase | |
| class FirebaseEventLogger: AnalyticsEventsLoggerProtocol { | |
| func setUserProperties(user: UserProfileModel) { | |
| // set user properties | |
| } | |
| func trackEvent(event: EventProtocol) { | |
| // add implementation of tracking events | |
| } | |
| } | |
| // Mixpanel | |
| class MixpanelEventLogger: AnalyticsEventsLoggerProtocol { | |
| func setUserProperties(user: UserProfileModel) { | |
| // set user properties | |
| } | |
| func trackEvent(event: EventProtocol) { | |
| // add implementation of tracking events | |
| } | |
| } | |
| // Manager | |
| protocol AnalyticsManagerProtocol { | |
| func setUp() | |
| func trackEvent(_ event: EventProtocol, | |
| params: [String: Any]) | |
| } | |
| class AnalyticsManager: AnalyticsManagerProtocol { | |
| static let shared = AnalyticsManager() | |
| var loggers: [AnalyticsEventsLoggerProtocol] = [] | |
| func setUp() { | |
| // Setup all the Analytics SDK | |
| } | |
| func trackEvent(_ event: EventProtocol, | |
| params: [String: Any] = [:]) { | |
| // add extra params to event | |
| // hit event from all tracking SDK's | |
| loggers.forEach({ logger in | |
| logger.trackEvent(event: event) | |
| }) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment