The simplest library to record analytical events in an Android application.
"What cannot be measured cannot be improved" by William Thomson Kelvin
We need to have metrics or analytics in our application to better understand our users, thus improving our applications. This library is a Kotlin DSL that allows you to record events to:
- Firebase Analytics
- Mixpanel
You can download and install Wrapper Analytics
with Maven
and Gradle
:
dependencies {
implementation("co.devhack:analytics:1.0.1")
}
Make sure to include MavenCentral
in your repositories
repositories {
mavenCentral()
}
Send an event for default to firebase:
createAnalytic {
eventName = FirebaseAnalytics.Event.ADD_PAYMENT_INFO
params {
param {
nameParam = FirebaseAnalytics.Param.ITEM_ID
valueParam = 1
}
param {
nameParam = FirebaseAnalytics.Param.ITEM_NAME
valueParam = "Jean"
}
}
}.track()
Or send the event to mixpanel:
First, you need to add the mixpanel token as metadata in the manifest file:
<meta-data
android:name="co.devhack.analytics.mixpanel.TOKEN"
android:value="MIXPANEL_TOKEN" />
Afterward...
createAnalytic {
provider = Provider.MIX_PANEL
eventName = "Event MixPanel"
params {
param {
nameParam = "Param 1 Mixpanel"
valueParam = 1
}
param {
nameParam = "Param 2 Mixpanel"
valueParam = "valor"
}
}
}.track()
And you can send the events to both.
createAnalytic {
provider = Provider.ALL
eventName = "Event"
params {
param {
nameParam = "Param 1"
valueParam = 1
}
param {
nameParam = "Param 2"
valueParam = "valor"
}
}
}.track()
Or you can send multiple events at the same time.
createAnalytics {
createAnalytic {
provider = Provider.ALL
eventName = "Event1"
params {
param {
nameParam = "Param 1"
valueParam = 1
}
param {
nameParam = "Param 2"
valueParam = "value"
}
}
}
createAnalytic {
eventName = "Event2"
}
}.track
Made with ❤ by jggomez.
Copyright 2021 Juan Guillermo Gómez
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.