Analytics library preferably sharpened for Google Analytics
Ganalytics is tiny api layer for any analytics in application. It provides an object oriented, typesafe, strict and testable way to organize work with analytics in the application. More information on wiki pages.
Here is latest changelog.
Also, you can read these articles for more details:
1) @programmerr47/declarative-analytics-ganalytics-4cb927b98be8">Introduction to conception
2) @programmerr47/effective-application-analytic-832f950232b9">V1.1 Changelog details
With gradle:
compile 'com.github.programmerr47:ganalytics-core:1.1.0'
With maven:
<dependency>
<groupId>com.github.programmerr47</groupId>
<artifactId>ganalytics-core</artifactId>
<version>1.1.0</version>
<type>pom</type>
</dependency>
To start with gathering analytics:
Create an group or category interface and fill it with necessary annotations:
or
interface GroupInterface {
@Prefix fun category(): CategoryInterface
@Convention(NamingConventions.LOWER_CAMEL_CASE) fun otherCategory(): OtherCategoryInterface
}
For more information about interfaces and annotations read linked sections.
Prepare Ganalytics
instance through:
For group interfaces:
val ganalytics = Ganalytics({ System.out.println(it) /**or do something with received incoming events**/ }) {
cutOffAnalyticsClassPrefix = false
prefixSplitter = "_"
namingConvention = NamingConventions.LOWER_SNAKE_CASE
labelTypeConverters += TypeConverterPair<DummyDataClass> { it.name } +
TypeConverterPair<DummyReversedClass> { it.id.toString() }
}
wich is equal to:
val ganalytics = GanalyticsSettings {
cutOffAnalyticsClassPrefix = false
prefixSplitter = "_"
namingConvention = NamingConventions.LOWER_SNAKE_CASE
labelTypeConverters += TypeConverterPair<DummyDataClass> { it.name } +
TypeConverterPair<DummyReversedClass> { it.id.toString() }
}.createGroup { System.out.println(it) /**or do something with received incoming events**/ }
For category interfaces:
val ganalytics = GanalyticsSettings {
cutOffAnalyticsClassPrefix = false
prefixSplitter = "_"
namingConvention = NamingConventions.LOWER_SNAKE_CASE
labelTypeConverters += TypeConverterPair<DummyDataClass> { it.name } +
TypeConverterPair<DummyReversedClass> { it.id.toString() }
}.createSingle { System.out.println(it) /** or do something with received incoming events**/ }
ganalytics
: val analytics = ganalytics.create(GroupInterface::class)
analytics
. For example:analytics.category().otherAction("label")
will print to the standart output: Event(category=sampleinterface, action=sampleinterface_method1)
Note: instead of System.out.println
you can pass, for example:
googleAnalyticsTracker.send(HitBuilders.EventBuilder()
.setCategory(it.category)
.setAction(it.action)
.setLabel(it.label)
.setValue(it.value)
.build())
Or any analytics method as you want.
For more info of basic usage see samples folder in project.
Also please visit the wiki pages to know more details.