A unified Android analytics library that centralizes multiple analytics services
- Overview
- Key Features
- Installation
- Quick Start
- Core Features
- Supported Analytics SDKs
- AnalytiksVisor - Event Monitoring
- Advanced Usage
- Contributing
- Contact
- License
Analytiks is a powerful Android library designed to simplify analytics integration by centralizing multiple analytics services into a single, unified interface. Instead of managing multiple SDKs and their different APIs, Analytiks provides a consistent way to track events, identify users, and manage analytics across your entire application.
- Single Implementation: Write once, use with multiple analytics providers
- Modular Architecture: Add only the analytics services you need
- Debug-Friendly: Built-in logging for development and testing
- Lightweight: Minimal impact on your app's size and performance
- Easy Migration: Switch between analytics providers without code changes
- π§ Easy Integration - Single API for multiple analytics services
- π¦ Modular Design - Add only the providers you need
- π Debug Mode - Console logging for development
- π Performance Optimized - Minimal overhead and smart batching
- π Provider Agnostic - Switch providers without changing your code
- π± Real-time Monitoring - Built-in event viewer with AnalytiksVisor
Add the following dependencies to your app-level build.gradle
file:
dependencies {
implementation 'io.github.aminekarimii:analytiks:VERSION'
implementation 'io.github.aminekarimii:analytiks-core:VERSION'
}
dependencies {
// Google Analytics / Firebase
implementation 'io.github.aminekarimii:analytiks-addon-googleanalytics:VERSION'
// Mixpanel
implementation 'io.github.aminekarimii:analytiks-addon-mixpanel:VERSION'
// Segment
implementation 'io.github.aminekarimii:analytiks-addon-segment:VERSION'
// Amplitude
implementation 'io.github.aminekarimii:analytiks-addon-amplitude:VERSION'
// Local Logging (Timber)
implementation 'io.github.aminekarimii:analytiks-addon-timber:VERSION'
// Event Monitoring UI
implementation 'io.github.aminekarimii:analytiks-addon-appvisor:VERSION'
}
Note: Replace
VERSION
with the latest version available on Maven Central.
In your Activity
or Application
class:
class MainActivity : AppCompatActivity() {
private lateinit var analytiks: Analytiks
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Build your analytics configuration
analytiks = Analytiks.Builder()
.addClient(GoogleAnalyticsClient()) // Firebase Analytics
.addClient(MixpanelAnalyticsClient(token = "YOUR_MIXPANEL_TOKEN"))
.addClient(
SegmentAnalyticsClient(
token = "YOUR_SEGMENT_TOKEN",
flushIntervalInSeconds = 5,
trackApplicationLifecycleEvents = true
)
)
.addClient(TimberAnalyticsClient()) // For debug logging
.build()
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ... configuration above
// Initialize all configured analytics providers
analytiks.initialize(applicationContext)
}
// Track a simple event
analytiks.logEvent("user_signup")
// Track an event with properties
analytiks.logEvent(
eventName = "purchase_completed",
properties = mapOf(
"product_id" to "12345",
"price" to 29.99,
"currency" to "USD"
)
)
// Identify a user
analytiks.identify(userId = "user_12345")
// Set user properties
analytiks.setUserProperty("subscription_type", "premium")
// Send all queued events immediately
analytiks.pushAll()
// Simple event
analytiks.logEvent("button_clicked")
// Event with custom properties
analytiks.logEvent("video_played", mapOf(
"video_id" to "abc123",
"duration" to 120,
"quality" to "HD"
))
// Identify user with custom ID
analytiks.identify("user_12345")
// Identify with auto-generated UUID
analytiks.identify()
// Set user properties
analytiks.setUserProperty("age", 25)
analytiks.setUserProperty("plan", "premium")
// Force send all queued events
analytiks.flush()
// Reset user data and clear queue
analytiks.reset()
Service | Status | Implementation Guide | Official Documentation |
---|---|---|---|
Google Analytics/Firebase | β Available | Setup Guide | Firebase Docs |
Segment | β Available | Setup Guide | Segment Docs |
Mixpanel | β Available | Setup Guide | Mixpanel Docs |
Amplitude | β Available | Setup Guide | Amplitude Docs |
Timber (Local Logging) | β Available | Built-in | Timber GitHub |
Custom Analytics | β Available | Create Custom Addon | - |
Flurry Analytics | π§ Coming Soon | - | - |
CleverTap | π§ Coming Soon | - | - |
MoEngage | π§ Coming Soon | - | - |
Adjust | π§ Coming Soon | - | - |
AppsFlyer | π§ Coming Soon | - | - |
Can't find your analytics service? Open an issue with the service name and documentation link.
AnalytiksVisor provides real-time event monitoring and debugging capabilities, allowing you to see exactly what analytics events are being tracked in your application.
- π Real-time Event Visualization - Monitor events as they happen
- π Timestamp Tracking - Precise event timing information
- π Event Details - Complete event properties and metadata
- π§ Coming Soon: Event sharing and push notifications
- Add the dependency:
implementation 'io.github.aminekarimii:analytiks-addon-appvisor:VERSION'
- Initialize with interceptor:
analytiks = Analytiks.Builder()
.addInterceptor(AppVisorActivity.initialize())
.addClient(/* your analytics clients */)
.build()
- Create app shortcut (optional):
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
AnalytiksVisor.createShortcut(this)
}
}
Screen_recording_20240305_234527.webm
You can create custom analytics providers by implementing the AnalyticsClient
interface:
class CustomAnalyticsClient : AnalyticsClient {
override fun initialize(context: Context) {
// Initialize your custom analytics SDK
}
override fun logEvent(eventName: String, properties: Map<String, Any>?) {
// Implement event logging
}
override fun identify(userId: String) {
// Implement user identification
}
override fun setUserProperty(key: String, value: Any) {
// Implement user property setting
}
override fun flush() {
// Implement force flush
}
override fun reset() {
// Implement reset functionality
}
}
Enable debug logging in development builds:
analytiks = Analytiks.Builder()
.addClient(TimberAnalyticsClient()) // Logs to console
.build()
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
git clone https://github.com/aminekarimii/analytiks.git
cd analytiks
./gradlew build
Amine Karimi - Library Creator & Maintainer
- π§ Email: aminekarimi1998@gmail.com
- πΌ LinkedIn: aminekarimi
- π¦ Twitter: @aminekarimii
- π GitHub: aminekarimii
Apache License 2.0
Copyright 2022 KARIMI Amine
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.
β If you find Analytiks helpful, please consider giving it a star on GitHub! β