How chryssaaliferi/rudder-sdk-kotlin works
Project Type and Purpose
• This is a multi-module SDK aimed at enabling event tracking and user analytics from Android and Kotlin JVM applications.
• The SDK provides core functionality (in the “core” module) that is extended by platform-specific implementations (e.g., the “android” module for Android applications and “kotlin-jvm-app” for JVM use cases).
• Sample applications (“app” and “kotlin-jvm-app”) illustrate how to integrate the SDK into client projects.
Main Components
• Platform-Specific SDK Modules:
• Android SDK Module: Contains packages for Android-specific initialization, configuration, lifecycle management, and various plugins (analytics, logging, plugins for deeplinks, screen recording, session tracking, etc.).
• Kotlin JVM SDK (and associated sample): Focused on non-Android environments that use the core functionalities provided by the SDK.
• Core SDK Module:
• The “core” module centralizes core logic like event modeling, network communications (HTTP client, error handling), storage (event batching, key-value storage), policies (flush policies), and plugin management. It provides the base interfaces and utility functions used by the platform-specific modules.
• Sample Applications:
• The “app” directory contains an Android sample application that demonstrates SDK initialization (e.g., Analytics, Configuration) and usage (identify, track, etc.).
• The “kotlin-jvm-app” directory includes a sample JVM application, showing how to integrate and initialize the SDK on a JVM environment.
• Test Suites and Build Infrastructure:
• Each module (android, core, etc.) includes extensive test directories that validate functionality of plugins, network modules, storage utilities, and more.
• Build configuration files (e.g., Gradle scripts, settings file) ensure that dependencies and module interactions are properly configured.
Relationships and Interactions
• The Sample Applications depend on the Android/Kotlin-JVM SDK modules for initializing analytics, capturing user events (track, identify), and using plugins.
• The Android module interacts with the core module to leverage shared utilities such as networking, storage, and event queuing.
• The plugin system (present in both android and core) lets you extend and modify the default behavior of analytics (e.g., screen info, device info, lifecycle events).
• Testing modules validate the implementations of each component, ensuring that the core services as well as platform-specific plugins work correctly.
• Build scripts and GitHub workflows (e.g., lint.yml) indicate the CI/CD and quality control process.
Architectural Patterns and Design Principles
• Modular Architecture: The separation between core, android, and JVM modules promotes reusability and separation of concerns.
• Plugin Pattern: The design utilizes plugins for various analytics aspects (e.g., lifecycle management plugins, custom plugins in the sample app), allowing for extensibility.
• Separation of Concerns: Distinct layers for event data models, network communication, storage management, and user identification enable maintainable code.
• Test-Driven Development (TDD): The extensive test folders indicate an emphasis on unit testing and integration testing of each component.
Elements
• Android SDK, Kotlin JVM SDK, Core SDK, Sample Application (App), Test Suites, CI/CD Infrastructure.
• Where typical SDK calls (like initialize, track, identify) occur and how they propagate through the system.