-
-
Save saqib-github-commits/16c9a4855fb5aaaea620150deef747c5 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
// AnalyticsLogger interface | |
interface AnalyticsLogger { | |
fun logEvent(name: String, params: List<AnalyticsParam>) | |
} | |
data class AnalyticsParam(val name: String, val value: String) | |
// extension method to log screen visit event | |
fun AnalyticsLogger.logScreenVisited(screenName: String) { | |
logEvent("screenViewed", listOf( | |
AnalyticsParam("screen_name", screenName) | |
)) | |
} | |
// DummyAnalyticsLogger | |
// Its created to provide default value to the CompositionLocal | |
class DummyAnalyticsLogger: AnalyticsLogger { | |
override fun logEvent(name: String, params: List<AnalyticsParam>) = Unit | |
} | |
// Actual Implementation for logging analytics, It will be bind using Hilt | |
class AnalyticsLoggerImpl @Inject constructor( | |
) : AnalyticsLogger { | |
override fun logEvent(name: String, params: List<AnalyticsParam>) { | |
// actual implementation via firebase or newrelic or any other | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment