Skip to content

Conversation

@igor-amp
Copy link
Contributor

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:

    • Added AmplitudeUnified/build.gradle.kts to define the Android library module with necessary plugins, dependencies, and build configurations.
    • Created a basic AndroidManifest.xml file for the new module.
    • Added ProGuard rules specific to the module in AmplitudeUnified/proguard-rules.pro.
  • Documentation:

    • Added AmplitudeUnified/README.md describing the purpose, features, and structure of the Unified SDK.
  • Basic Classes and Tests:

    • Introduced AmplitudeUnified/src/main/java/com/amplitude/android/unified/Amplitude.kt as the main class extending the core Amplitude SDK functionality.
    • Added example unit and instrumented tests (ExampleUnitTest.kt, ExampleInstrumentedTest.kt) to validate basic functionality. [1] [2]

Refactoring of Existing Android SDK:

  • Code Cleanup:

    • Refactored android/src/main/java/com/amplitude/android/Amplitude.kt to simplify constructors, remove redundant state management, and streamline session handling. [1] [2] [3]
    • Updated android/src/main/java/com/amplitude/android/Timeline.kt to make session ID handling more robust and align it with the Unified SDK. [1] [2]
  • Improved Type Safety:

    • Changed callback definitions in FragmentActivityHandler and AutocaptureGestureListener to use non-nullable event properties for better type safety. [1] [2]

Build Configuration Updates:

  • Dynamic Build Variables:
    • Updated android/build.gradle.kts to use BuildConfig.Versions for compileSdk and minSdk values, ensuring consistency across builds. [1] [2]

Documentation Update for Existing SDK:

  • Android SDK Overview:
    • Added android/README.md providing detailed information about the structure, usage, and build instructions for the existing Amplitude Kotlin Android SDK.

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?:

@igor-amp igor-amp requested review from Copilot and polbins June 30, 2025 17:08
Copy link

Copilot AI left a 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
Copy link
Contributor

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?

Copy link
Contributor Author

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

igor-amp added 5 commits July 1, 2025 10:19
# Conflicts:
#	build.gradle.kts
#	gradle/libs.versions.toml
#	samples/kotlin-android-app/src/main/java/com/amplitude/android/sample/MainApplication.kt
@igor-amp igor-amp changed the title Amp 132657/initial set up feat: Amplitude Unified SDK Jul 1, 2025
igor-amp added 14 commits July 1, 2025 14:12
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants