Skip to content

Commit

Permalink
implement versioned plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wenxi-zeng committed Mar 8, 2022
1 parent 96863c6 commit ee58fb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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
Expand Up @@ -9,6 +9,7 @@ import com.segment.analytics.kotlin.android.utilities.toJSONObject
import com.segment.analytics.kotlin.core.*
import com.segment.analytics.kotlin.core.platform.DestinationPlugin
import com.segment.analytics.kotlin.core.platform.Plugin
import com.segment.analytics.kotlin.core.platform.VersionedPlugin
import com.segment.analytics.kotlin.core.platform.plugins.logger.*
import com.segment.analytics.kotlin.core.utilities.*
import kotlinx.serialization.*
Expand Down Expand Up @@ -67,7 +68,7 @@ data class MixpanelSettings(

class MixpanelDestination(
private val context: Context
) : DestinationPlugin(), AndroidLifecycle {
) : DestinationPlugin(), AndroidLifecycle, VersionedPlugin {

internal var settings: MixpanelSettings? = null
internal var mixpanel: MixpanelAPI? = null
Expand Down Expand Up @@ -251,4 +252,8 @@ class MixpanelDestination(
keyMapper: Map<String, String>,
): Map<String, JsonElement> = JsonObject(this).mapTransform(keyMapper, null)

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

}

0 comments on commit ee58fb9

Please sign in to comment.