From 681630afcb72ee71ab388d4dfef50bb2aff44b12 Mon Sep 17 00:00:00 2001 From: Wenxi Zeng Date: Mon, 7 Mar 2022 16:58:02 -0800 Subject: [PATCH 1/2] update package name --- README.md | 2 +- .../ExampleInstrumentedTest.kt | 11 ++++--- lib/src/main/AndroidManifest.xml | 2 +- .../AppsflyerDestination.kt | 2 +- .../AppsflyerDestinationTests.kt | 33 +++++++------------ 5 files changed, 20 insertions(+), 30 deletions(-) rename lib/src/androidTest/java/com/segment/analytics/kotlin/destinations/{plugins => appsflyer}/ExampleInstrumentedTest.kt (70%) rename lib/src/main/java/com/segment/analytics/kotlin/destinations/{plugins => appsflyer}/AppsflyerDestination.kt (99%) rename lib/src/test/java/com/segment/analytics/kotlin/destinations/{plugins => appsflyer}/AppsflyerDestinationTests.kt (91%) diff --git a/README.md b/README.md index 57625f7..658d0f1 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ implementation("com.segment.analytics.kotlin.destinations:appsflyer:1.4.4") Open the file where you setup and configure the Analytics-Kotlin library. Add this plugin to the list of imports. ``` -import com.segment.analytics.kotlin.destinations.plugins.AppsflyerDestination +import com.segment.analytics.kotlin.destinations.appsflyer.AppsflyerDestination ``` Just under your Analytics-Kotlin library setup, call `analytics.add(plugin = ...)` to add an instance of the plugin to the Analytics timeline. diff --git a/lib/src/androidTest/java/com/segment/analytics/kotlin/destinations/plugins/ExampleInstrumentedTest.kt b/lib/src/androidTest/java/com/segment/analytics/kotlin/destinations/appsflyer/ExampleInstrumentedTest.kt similarity index 70% rename from lib/src/androidTest/java/com/segment/analytics/kotlin/destinations/plugins/ExampleInstrumentedTest.kt rename to lib/src/androidTest/java/com/segment/analytics/kotlin/destinations/appsflyer/ExampleInstrumentedTest.kt index 3686f35..0ff348c 100644 --- a/lib/src/androidTest/java/com/segment/analytics/kotlin/destinations/plugins/ExampleInstrumentedTest.kt +++ b/lib/src/androidTest/java/com/segment/analytics/kotlin/destinations/appsflyer/ExampleInstrumentedTest.kt @@ -1,13 +1,11 @@ -package com.segment.analytics.kotlin.destinations.plugins +package com.segment.analytics.kotlin.destinations.appsflyer import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry - +import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith -import org.junit.Assert.* - /** * Instrumented test, which will execute on an Android device. * @@ -19,6 +17,9 @@ class ExampleInstrumentedTest { fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.segment.analytics.kotlin.destinations.plugins.test", appContext.packageName) + Assert.assertEquals( + "com.segment.analytics.kotlin.destinations.appsflyer.test", + appContext.packageName + ) } } \ No newline at end of file diff --git a/lib/src/main/AndroidManifest.xml b/lib/src/main/AndroidManifest.xml index e5f5b96..883baa9 100644 --- a/lib/src/main/AndroidManifest.xml +++ b/lib/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.segment.analytics.kotlin.destinations.appsflyer"> \ No newline at end of file diff --git a/lib/src/main/java/com/segment/analytics/kotlin/destinations/plugins/AppsflyerDestination.kt b/lib/src/main/java/com/segment/analytics/kotlin/destinations/appsflyer/AppsflyerDestination.kt similarity index 99% rename from lib/src/main/java/com/segment/analytics/kotlin/destinations/plugins/AppsflyerDestination.kt rename to lib/src/main/java/com/segment/analytics/kotlin/destinations/appsflyer/AppsflyerDestination.kt index f25ad29..ddb33c0 100644 --- a/lib/src/main/java/com/segment/analytics/kotlin/destinations/plugins/AppsflyerDestination.kt +++ b/lib/src/main/java/com/segment/analytics/kotlin/destinations/appsflyer/AppsflyerDestination.kt @@ -1,4 +1,4 @@ -package com.segment.analytics.kotlin.destinations.plugins +package com.segment.analytics.kotlin.destinations.appsflyer import android.app.Activity import android.content.Context diff --git a/lib/src/test/java/com/segment/analytics/kotlin/destinations/plugins/AppsflyerDestinationTests.kt b/lib/src/test/java/com/segment/analytics/kotlin/destinations/appsflyer/AppsflyerDestinationTests.kt similarity index 91% rename from lib/src/test/java/com/segment/analytics/kotlin/destinations/plugins/AppsflyerDestinationTests.kt rename to lib/src/test/java/com/segment/analytics/kotlin/destinations/appsflyer/AppsflyerDestinationTests.kt index c7155df..ae78c60 100644 --- a/lib/src/test/java/com/segment/analytics/kotlin/destinations/plugins/AppsflyerDestinationTests.kt +++ b/lib/src/test/java/com/segment/analytics/kotlin/destinations/appsflyer/AppsflyerDestinationTests.kt @@ -1,4 +1,4 @@ -package com.segment.analytics.kotlin.destinations.plugins +package com.segment.analytics.kotlin.destinations.appsflyer import android.app.Activity import android.content.Context @@ -7,23 +7,12 @@ import androidx.core.os.bundleOf import com.appsflyer.AppsFlyerLib import com.segment.analytics.kotlin.core.* import com.segment.analytics.kotlin.core.platform.Plugin -import io.mockk.Called -import io.mockk.MockKAnnotations -import io.mockk.every +import com.segment.analytics.kotlin.destinations.appsflyer.AppsFlyerDestination +import io.mockk.* import io.mockk.impl.annotations.MockK -import io.mockk.mockk -import io.mockk.mockkStatic -import io.mockk.verify import kotlinx.serialization.decodeFromString -import kotlinx.serialization.json.Json -import kotlinx.serialization.json.buildJsonArray -import kotlinx.serialization.json.buildJsonObject -import kotlinx.serialization.json.put -import kotlinx.serialization.json.add -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertNotNull +import kotlinx.serialization.json.* +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test @@ -78,10 +67,10 @@ class AppsflyerDestinationTests { appsflyerDestination.update(settingsBlob, Plugin.UpdateType.Initial) /* assertions about config */ - assertNotNull(appsflyerDestination.settings) + Assertions.assertNotNull(appsflyerDestination.settings) with(appsflyerDestination.settings!!) { - assertTrue(trackAttributionData) - assertEquals("devKey", appsFlyerDevKey) + Assertions.assertTrue(trackAttributionData) + Assertions.assertEquals("devKey", appsFlyerDevKey) } verify { mockAppsflyer.init("devKey", isNull(inverse = true), mockContext) } @@ -118,10 +107,10 @@ class AppsflyerDestinationTests { appsflyerDestination.update(settingsBlob, Plugin.UpdateType.Initial) /* assertions about config */ - assertNotNull(appsflyerDestination.settings) + Assertions.assertNotNull(appsflyerDestination.settings) with(appsflyerDestination.settings!!) { - assertFalse(trackAttributionData) - assertEquals("devKey", appsFlyerDevKey) + Assertions.assertFalse(trackAttributionData) + Assertions.assertEquals("devKey", appsFlyerDevKey) } verify { mockAppsflyer.init("devKey", isNull(), mockContext) } From a40380f5cdfe904b294be775e0503fd74b87b8b7 Mon Sep 17 00:00:00 2001 From: Wenxi Zeng Date: Mon, 7 Mar 2022 17:00:24 -0800 Subject: [PATCH 2/2] implement versioned plugin --- lib/build.gradle.kts | 6 +++++- .../kotlin/destinations/appsflyer/AppsflyerDestination.kt | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 11710b6..ceca391 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -6,6 +6,8 @@ plugins { id("mvn-publish") } +val VERSION_NAME: String by project + android { compileSdk = 31 buildToolsVersion = "31.0.0" @@ -17,6 +19,8 @@ android { testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" consumerProguardFiles("proguard-consumer-rules.pro") + + buildConfigField("String", "VERSION_NAME", "\"$VERSION_NAME\"") } buildTypes { @@ -38,7 +42,7 @@ android { dependencies { coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5") - implementation("com.segment.analytics.kotlin:android:1.4.3") + implementation("com.segment.analytics.kotlin:android:1.5.0") implementation("androidx.multidex:multidex:2.0.1") implementation("androidx.core:core-ktx:1.7.0") diff --git a/lib/src/main/java/com/segment/analytics/kotlin/destinations/appsflyer/AppsflyerDestination.kt b/lib/src/main/java/com/segment/analytics/kotlin/destinations/appsflyer/AppsflyerDestination.kt index ddb33c0..63bb3cf 100644 --- a/lib/src/main/java/com/segment/analytics/kotlin/destinations/appsflyer/AppsflyerDestination.kt +++ b/lib/src/main/java/com/segment/analytics/kotlin/destinations/appsflyer/AppsflyerDestination.kt @@ -13,6 +13,7 @@ import android.os.Bundle import com.appsflyer.AFInAppEventParameterName import com.segment.analytics.kotlin.android.plugins.AndroidLifecycle import com.appsflyer.deeplink.DeepLinkListener +import com.segment.analytics.kotlin.core.platform.VersionedPlugin import com.segment.analytics.kotlin.core.platform.plugins.logger.* import com.segment.analytics.kotlin.core.utilities.getString import com.segment.analytics.kotlin.core.utilities.mapTransform @@ -61,7 +62,7 @@ data class AppsFlyerSettings( class AppsFlyerDestination( private val applicationContext: Context, private var isDebug: Boolean = false -) : DestinationPlugin(), AndroidLifecycle { +) : DestinationPlugin(), AndroidLifecycle, VersionedPlugin { internal var settings: AppsFlyerSettings? = null internal var appsflyer: AppsFlyerLib? = null @@ -237,4 +238,8 @@ class AppsFlyerDestination( } } + override fun version(): String { + return BuildConfig.VERSION_NAME + } + } \ No newline at end of file