-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Amplitude Unified SDK #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces the initial implementation of the Amplitude Unified SDK for Android and refactors several core components of the existing Android SDK to improve maintainability, type safety, and extendibility.
- Added a new unified SDK module with its own build configuration, manifest, README, and tests.
- Updated build scripts and dependency versions while refactoring identity management and event processing components within the core and Android modules.
- Enhanced the plugin architecture with adjustments in Mediator, Timeline, and related interfaces.
Reviewed Changes
Copilot reviewed 61 out of 62 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| settings.gradle.kts | Added inclusion of the unified module |
| samples/kotlin-android-app/MainActivity.kt | Added an identify call in the onStart() override |
| samples/kotlin-android-app/build.gradle.kts | Refactored SDK version settings to use dynamic values from BuildConfig |
| gradle/libs.versions.toml | Updated Kotlin version and added new plugin versions |
| core/src/main/java/com/amplitude/core/events/BaseEvent.kt | Updated nullability of event property maps |
| core/src/main/java/com/amplitude/core/utilities/JSON.kt | Modified JSONObject.toMapObj() to filter out null values |
| core/src/main/java/com/amplitude/core/platform/Mediator.kt | Refactored execute logic for UniversalPlugin processing |
| android/src/main/java/com/amplitude/android/Timeline.kt | Updated sessionId setter with an asynchronous storage write |
| ... (additional files) | Numerous adjustments and refactorings in identity, event pipelines, plugins |
Comments suppressed due to low confidence (3)
core/src/main/java/com/amplitude/core/events/BaseEvent.kt:10
- [nitpick] Consider initializing 'eventProperties' with an empty mutable map (e.g. mutableMapOf()) instead of null, so that downstream consumers can assume non-null values and avoid repetitive null checks.
override var eventProperties: MutableMap<String, Any>? = null
core/src/main/java/com/amplitude/core/utilities/JSON.kt:26
- Confirm that filtering out null values in 'toMapObj()' is an intentional design decision, since this logic removes keys with null values. If null preservation is required, consider revising the filtering logic.
}
core/src/main/java/com/amplitude/core/platform/Mediator.kt:37
- [nitpick] Ensure that casting a UniversalPlugin to Plugin is safe for all implementations; non-Plugin types will simply return the current event. Confirm that this fallback behavior aligns with your overall plugin processing strategy.
(plugin as? Plugin)?.execute(currentEvent) ?: currentEvent
| var groupProperties: MutableMap<String, Any?>? = null | ||
| open class BaseEvent : EventOptions(), AnalyticsEvent { | ||
| override lateinit var eventType: String | ||
| override var eventProperties: MutableMap<String, Any>? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a huge change, I'm not sure if I'm remembering correctly that null values get filtered out.
Do we need to do this now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's also how iOs works. I can bring back old function but it will silently drop params in this case
# Conflicts: # build.gradle.kts # gradle/libs.versions.toml # samples/kotlin-android-app/src/main/java/com/amplitude/android/sample/MainApplication.kt
# Conflicts: # android/src/main/java/com/amplitude/android/Amplitude.kt # android/src/main/java/com/amplitude/android/internal/fragments/AutocaptureFragmentLifecycleCallbacks.kt # android/src/main/java/com/amplitude/android/internal/gestures/AutocaptureGestureListener.kt # android/src/main/java/com/amplitude/android/plugins/AndroidContextPlugin.kt # android/src/main/java/com/amplitude/android/utilities/DefaultEventUtils.kt # android/src/main/java/com/amplitude/common/android/AndroidContextProvider.kt # android/src/test/kotlin/com/amplitude/android/AmplitudeTest.kt # android/src/test/kotlin/com/amplitude/android/IdentifyInterceptorTest.kt # android/src/test/kotlin/com/amplitude/android/migration/MigrationManagerTest.kt # android/src/test/kotlin/com/amplitude/android/plugins/AndroidLifecyclePluginTest.kt # android/src/test/kotlin/com/amplitude/android/utilities/FakeAndroidAmplitude.kt # android/src/test/kotlin/com/amplitude/core/network/NetworkTrackingPluginTest.kt # core/src/main/java/com/amplitude/core/Amplitude.kt # core/src/main/java/com/amplitude/core/Configuration.kt # core/src/main/java/com/amplitude/core/State.kt # core/src/main/java/com/amplitude/core/events/Identify.kt # core/src/main/java/com/amplitude/core/network/NetworkTrackingPlugin.kt # core/src/main/java/com/amplitude/core/platform/Mediator.kt # core/src/main/java/com/amplitude/core/platform/Plugin.kt # core/src/main/java/com/amplitude/core/platform/Timeline.kt # core/src/main/java/com/amplitude/core/platform/intercept/IdentifyInterceptFileStorageHandler.kt # core/src/main/java/com/amplitude/core/platform/intercept/IdentifyInterceptInMemoryStorageHandler.kt # core/src/main/java/com/amplitude/core/platform/intercept/IdentifyInterceptStorageHandler.kt # core/src/main/java/com/amplitude/core/utilities/AnalyticsIdentityListener.kt # core/src/main/java/com/amplitude/eventbridge/EventBridge.kt # core/src/main/java/com/amplitude/id/IdentityManager.kt # core/src/test/kotlin/com/amplitude/core/IdentifyInterceptTest.kt # core/src/test/kotlin/com/amplitude/core/platform/EventPipelineTest.kt # core/src/test/kotlin/com/amplitude/core/platform/MediatorTest.kt # core/src/test/kotlin/com/amplitude/core/utils/FakeAmplitude.kt # core/src/test/kotlin/com/amplitude/id/IdentityManagerTest.kt # samples/kotlin-android-app/src/main/java/com/amplitude/android/sample/MainApplication.kt
Summary
This pull request introduces the initial implementation of the Amplitude Unified SDK for Android, which consolidates analytics, experimentation, and session replay functionalities into a single integration point. Key changes include the setup of the project structure, configuration files, and foundational classes for the SDK. Additionally, it refactors existing Android SDK components to improve maintainability and functionality.
New SDK Implementation:
Project Initialization:
AmplitudeUnified/build.gradle.ktsto define the Android library module with necessary plugins, dependencies, and build configurations.AndroidManifest.xmlfile for the new module.AmplitudeUnified/proguard-rules.pro.Documentation:
AmplitudeUnified/README.mddescribing the purpose, features, and structure of the Unified SDK.Basic Classes and Tests:
AmplitudeUnified/src/main/java/com/amplitude/android/unified/Amplitude.ktas the main class extending the core Amplitude SDK functionality.ExampleUnitTest.kt,ExampleInstrumentedTest.kt) to validate basic functionality. [1] [2]Refactoring of Existing Android SDK:
Code Cleanup:
android/src/main/java/com/amplitude/android/Amplitude.ktto simplify constructors, remove redundant state management, and streamline session handling. [1] [2] [3]android/src/main/java/com/amplitude/android/Timeline.ktto make session ID handling more robust and align it with the Unified SDK. [1] [2]Improved Type Safety:
FragmentActivityHandlerandAutocaptureGestureListenerto use non-nullable event properties for better type safety. [1] [2]Build Configuration Updates:
android/build.gradle.ktsto useBuildConfig.VersionsforcompileSdkandminSdkvalues, ensuring consistency across builds. [1] [2]Documentation Update for Existing SDK:
android/README.mdproviding detailed information about the structure, usage, and build instructions for the existing Amplitude Kotlin Android SDK.Checklist