Skip to content

A lightweight Analytics library that logs events, identifies the user, and dispatches the data at one. πŸ“Š

License

Notifications You must be signed in to change notification settings

aminekarimii/analytiks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š Analytiks

A unified Android analytics library that centralizes multiple analytics services

Build Status Maven Central License

Analytiks Banner


πŸ“‹ Table of Contents


πŸ’­ Overview

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.

Why Analytiks?

  • 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

Library Architecture


✨ Key Features

  • πŸ”§ 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

πŸ“₯ Installation

Add the following dependencies to your app-level build.gradle file:

Core Library

dependencies {
    implementation 'io.github.aminekarimii:analytiks:VERSION'
    implementation 'io.github.aminekarimii:analytiks-core:VERSION'
}

Analytics Providers (Add as needed)

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.


πŸš€ Quick Start

1. Initialize Analytiks

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()
    }
}

2. Initialize the Library

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    // ... configuration above
    
    // Initialize all configured analytics providers
    analytiks.initialize(applicationContext)
}

3. Start Tracking Events

// 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()

πŸ”§ Core Features

Event Tracking

// 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"
))

User Management

// 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")

Data Management

// Force send all queued events
analytiks.flush()

// Reset user data and clear queue
analytiks.reset()

πŸ—ƒ Supported Analytics SDKs

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 - -

Request New Integrations

Can't find your analytics service? Open an issue with the service name and documentation link.


πŸ” AnalytiksVisor - Event Monitoring

AnalytiksVisor provides real-time event monitoring and debugging capabilities, allowing you to see exactly what analytics events are being tracked in your application.

Features

  • πŸ“Š 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

Setup

  1. Add the dependency:
implementation 'io.github.aminekarimii:analytiks-addon-appvisor:VERSION'
  1. Initialize with interceptor:
analytiks = Analytiks.Builder()
    .addInterceptor(AppVisorActivity.initialize())
    .addClient(/* your analytics clients */)
    .build()
  1. Create app shortcut (optional):
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        AnalytiksVisor.createShortcut(this)
    }
}

Demo

Screen_recording_20240305_234527.webm

πŸ”¨ Advanced Usage

Creating Custom Analytics Providers

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
    }
}

Debug Mode

Enable debug logging in development builds:

analytiks = Analytiks.Builder()
    .addClient(TimberAnalyticsClient()) // Logs to console
    .build()

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

git clone https://github.com/aminekarimii/analytiks.git
cd analytiks
./gradlew build

πŸ“« Contact

Amine Karimi - Library Creator & Maintainer


πŸ“„ License

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! ⭐

About

A lightweight Analytics library that logs events, identifies the user, and dispatches the data at one. πŸ“Š

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages