Skip to content

Commit

Permalink
Merge pull request #3 from segment-integrations/wenxi/resolve-package…
Browse files Browse the repository at this point in the history
…-collision

resolve package collision
  • Loading branch information
wenxi-zeng authored Mar 8, 2022
2 parents 2362146 + a40380f commit 7d6ec8f
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
id("mvn-publish")
}

val VERSION_NAME: String by project

android {
compileSdk = 31
buildToolsVersion = "31.0.0"
Expand All @@ -17,6 +19,8 @@ android {

testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
consumerProguardFiles("proguard-consumer-rules.pro")

buildConfigField("String", "VERSION_NAME", "\"$VERSION_NAME\"")
}

buildTypes {
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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
)
}
}
2 changes: 1 addition & 1 deletion lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.segment.analytics.kotlin.destinations.plugins">
package="com.segment.analytics.kotlin.destinations.appsflyer">

</manifest>
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -237,4 +238,8 @@ class AppsFlyerDestination(
}
}

override fun version(): String {
return BuildConfig.VERSION_NAME
}

}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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) }
Expand Down Expand Up @@ -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) }
Expand Down

0 comments on commit 7d6ec8f

Please sign in to comment.