The aim of this library is to content the commons services, providers, API clients, ... for both Android applications. This library must not contain anything related with the presentation layer of Android (base activities, base fragments, custom views ...)
The Analytics package is a wrapper of all analytics clients that are currently being used to send user events to all of them at the same time.
val analyticsService = AnalyticsService(listOf(GoogleAnalyticsProvider()))
class SafeBodaAnalyticsUser(
val id: Long,
val phoneNumber: String,
val firstName: String,
val lastName: String,
override val email: String? = null,
) : AnalyticsUser(
id = userId,
identifier = phoneNumber,
name = "$firstName $lastName",
email = email
) {
init {
addProperty(FIRST_NAME, firstName)
addProperty(LAST_NAME, lastName)
}
companion object {
private const val FIRST_NAME = "first_name"
private const val LAST_NAME = "last_name"
}
}
analyticsService.setUser(safeBodaAnalyticsUser)
analyticsService.trackScreen(
activity = this,
screenName = SplashAnalyticsEventManager.EVENT_SPLASH_SCREEN,
overrideScreenClass = null
)
analyticsService.trackScreen(
activity = activity,
screenName = SplashAnalyticsEventManager.EVENT_SPLASH_SCREEN,
overrideScreenClass = this::class.java.simpleName
)
class SplashAnalyticsEventManager {
companion object {
fun splashScreenLoginEvent(
id: String,
walletId: Int,
amount: Double
): AnalyticsEvent = AnalyticsEventFactory.createAnalyticsEvent(
name = EVENT_SPLASH_SCREEN_LOGIN,
properties = listOf(
PROPERTY_ID to id,
PROPERTY_WALLET_ID to walletId,
PROPERTY_AMOUNT to amount
)
)
// region EVENTS
const val EVENT_SPLASH_SCREEN = "splash_screen"
private const val BASIC_EVENT_SPLASH_SCREEN = "splash_screen_"
private const val EVENT_SPLASH_SCREEN_LOGIN = "${BASIC_EVENT_SPLASH_SCREEN}login"
// endregion
// region PROPERTIES
private const val PROPERTY_ID = "id"
private const val PROPERTY_WALLET_ID = "wallet_id"
private const val PROPERTY_AMOUNT = "amount"
// endregion
}
}
analyticsService.track(SplashAnalyticsEventManager.splashScreenTimeout())
analyticsService.clearUser(safeBodaAnalyticsUser)
If you will like to use different clients from the already provided by the library (GoogleAnalyticsProvider
and AmplitudeAnalyticsProvider
)
class FacebookAnalyticsProvider : AnalyticsProvider {
override fun setUser(user: AnalyticsUser) {
TODO("Facebook Analytics implementation")
}
override fun clearUser(user: AnalyticsUser) {
TODO("Facebook Analytics implementation")
}
override fun setUserLogged() {
TODO("Facebook Analytics implementation")
}
override fun setUserNotLogged() {
TODO("Facebook Analytics implementation")
}
override fun track(event: AnalyticsEvent) {
TODO("Facebook Analytics implementation")
}
override fun trackScreen(activity: Activity?, screenName: String, overrideScreenClass: String?) {
TODO("Facebook Analytics implementation")
}
}
In order to upload a new version to JFrog you will have to follow these steps:
- Open
local.properties
file and write these two variables:bintray.user
with your bintray username andbintray.key
with your bintray api key (You can find it inbintray.com->Go to your username->Edit Profile->API Key
). Do not use quotes inlocal.properties
- Execute this command in the Android Studio terminal
./gradlew install
and then./gradlew bintrayUpload
.