From 1a96d79f4d18aeb33aac9ee7fffa435b9d777dc1 Mon Sep 17 00:00:00 2001 From: Andrew Reed Date: Wed, 21 Jun 2023 16:51:17 +0100 Subject: [PATCH] Added initial integration for firebase (#7) * Added initial integration for firebase * Added ios support for firebase integration * Added ios support for firebase integration * fixed lint errors * Bumped version * Adjusted the cocoapod import * bumped kotlin to 1.8.20 * revert back version of kotlin --- gradle.properties | 4 +- library/build.gradle.kts | 10 ++++- library/gradle.properties | 2 +- .../myunidays/segmenkt/FirebaseIntegration.kt | 41 +++++++++++++++++++ .../myunidays/segmenkt/FirebaseIntegration.kt | 10 +++++ .../myunidays/segmenkt/FirebaseIntegration.kt | 30 ++++++++++++++ .../myunidays/segmenkt/FirebaseIntegration.kt | 33 +++++++++++++++ 7 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 library/src/androidMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt create mode 100644 library/src/commonMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt create mode 100644 library/src/iosMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt create mode 100644 library/src/jsMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt diff --git a/gradle.properties b/gradle.properties index 400f594..6231fc2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,6 @@ POM_DEVELOPER_ID=MyUNiDAYS POM_DEVELOPER_NAME=MyUNiDAYS POM_DEVELOPER_EMAIL=app.team@myunidays.com -kotlin.native.binary.memoryModel=experimental \ No newline at end of file +kotlin.native.binary.memoryModel=experimental + +kotlin.native.cacheKind.iosArm64=none \ No newline at end of file diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 5b6ff83..5c4ad1a 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -64,7 +64,7 @@ kotlin { } } cocoapods { - ios.deploymentTarget = "10.0" + ios.deploymentTarget = "11.0" noPodspec() framework { isStatic = true } pod("Analytics") { @@ -73,6 +73,11 @@ kotlin { branch = "master" } } + pod("Segment-Firebase") { + source = git("https://github.com/Reedyuk/analytics-ios-integration-firebase.git") { + branch = "kmm" + } + } } sourceSets { val commonMain by getting @@ -86,7 +91,8 @@ kotlin { val androidMain by getting { dependencies { api("com.segment.analytics.android:analytics:4.10.4") - api("com.appsflyer:segment-android-integration:6.5.2") + api("com.appsflyer:segment-android-integration:6.10.3") + api("com.segment.analytics.android.integrations:firebase:2.3.3") } } val androidTest by getting { diff --git a/library/gradle.properties b/library/gradle.properties index d72856c..80d004a 100644 --- a/library/gradle.properties +++ b/library/gradle.properties @@ -5,7 +5,7 @@ signing.keyId="" signing.password="" MODULE_PACKAGE_NAME=com.myunidays -MODULE_VERSION_NUMBER=0.1.1 +MODULE_VERSION_NUMBER=0.1.2 MODULE_NAME=segmenkt OPEN_SOURCE_REPO=https://oss.sonatype.org/service/local/staging/deploy/maven2/ diff --git a/library/src/androidMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt b/library/src/androidMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt new file mode 100644 index 0000000..a0fd67b --- /dev/null +++ b/library/src/androidMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt @@ -0,0 +1,41 @@ +package com.myunidays.segmenkt + +import android.app.Activity +import android.os.Bundle +import com.myunidays.segmenkt.integrations.AliasPayload +import com.myunidays.segmenkt.integrations.GroupPayload +import com.myunidays.segmenkt.integrations.IdentifyPayload +import com.myunidays.segmenkt.integrations.Integration +import com.myunidays.segmenkt.integrations.IntegrationFactory +import com.myunidays.segmenkt.integrations.ScreenPayload +import com.myunidays.segmenkt.integrations.TrackPayload + +actual class FirebaseIntegration internal constructor( + private val android: com.segment.analytics.integrations.Integration<*> +) : Integration { + fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) = + android.onActivityCreated(activity, savedInstanceState) + fun onActivityStarted(activity: Activity?) = android.onActivityStarted(activity) + fun onActivityResumed(activity: Activity?) = android.onActivityResumed(activity) + fun onActivityPaused(activity: Activity?) = android.onActivityPaused(activity) + fun onActivityStopped(activity: Activity?) = android.onActivityStopped(activity) + fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) = + android.onActivitySaveInstanceState(activity, outState) + fun onActivityDestroyed(activity: Activity?) = android.onActivityDestroyed(activity) + override fun identify(identifyPayload: IdentifyPayload) = android.identify(identifyPayload) + override fun group(groupPayload: GroupPayload) = android.group(groupPayload) + override fun track(trackPayload: TrackPayload) = android.track(trackPayload) + override fun alias(aliasPayload: AliasPayload) = android.alias(aliasPayload) + override fun screen(screenPayload: ScreenPayload) = android.screen(screenPayload) + override fun flush() = android.flush() + override fun reset() = android.reset() + override fun debug(debug: Boolean) { + } + + actual companion object { + actual fun factory( + delegate: Any?, + deeplinkHandler: Any? + ): IntegrationFactory = com.segment.analytics.android.integrations.firebase.FirebaseIntegration.FACTORY + } +} diff --git a/library/src/commonMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt b/library/src/commonMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt new file mode 100644 index 0000000..2d7de42 --- /dev/null +++ b/library/src/commonMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt @@ -0,0 +1,10 @@ +package com.myunidays.segmenkt + +import com.myunidays.segmenkt.integrations.Integration +import com.myunidays.segmenkt.integrations.IntegrationFactory + +expect class FirebaseIntegration : Integration { + companion object { + fun factory(delegate: Any? = null, deeplinkHandler: Any? = null): IntegrationFactory + } +} diff --git a/library/src/iosMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt b/library/src/iosMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt new file mode 100644 index 0000000..8c20044 --- /dev/null +++ b/library/src/iosMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt @@ -0,0 +1,30 @@ +package com.myunidays.segmenkt + +import com.myunidays.segmenkt.integrations.AliasPayload +import com.myunidays.segmenkt.integrations.GroupPayload +import com.myunidays.segmenkt.integrations.IdentifyPayload +import com.myunidays.segmenkt.integrations.Integration +import com.myunidays.segmenkt.integrations.IntegrationFactory +import com.myunidays.segmenkt.integrations.ScreenPayload +import com.myunidays.segmenkt.integrations.TrackPayload + +actual class FirebaseIntegration internal constructor( + private val ios: cocoapods.Analytics.SEGIntegrationProtocol +) : Integration { + override fun identify(identifyPayload: IdentifyPayload) = ios.identify(identifyPayload) + override fun group(groupPayload: GroupPayload) = ios.group(groupPayload) + override fun track(trackPayload: TrackPayload) = ios.track(trackPayload) + override fun alias(aliasPayload: AliasPayload) = ios.alias(aliasPayload) + override fun screen(screenPayload: ScreenPayload) = ios.screen(screenPayload) + override fun flush() = ios.flush() + override fun reset() = ios.reset() + override fun debug(debug: Boolean) { } + + actual companion object { + actual fun factory( + delegate: Any?, + deeplinkHandler: Any? + ): IntegrationFactory = + cocoapods.Segment_Firebase.SEGFirebaseIntegrationFactory.Companion.instance() as cocoapods.Analytics.SEGIntegrationFactoryProtocol + } +} diff --git a/library/src/jsMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt b/library/src/jsMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt new file mode 100644 index 0000000..1d831f8 --- /dev/null +++ b/library/src/jsMain/kotlin/com/myunidays/segmenkt/FirebaseIntegration.kt @@ -0,0 +1,33 @@ +package com.myunidays.segmenkt + +import com.myunidays.segmenkt.integrations.AliasPayload +import com.myunidays.segmenkt.integrations.GroupPayload +import com.myunidays.segmenkt.integrations.IdentifyPayload +import com.myunidays.segmenkt.integrations.Integration +import com.myunidays.segmenkt.integrations.IntegrationFactory +import com.myunidays.segmenkt.integrations.ScreenPayload +import com.myunidays.segmenkt.integrations.TrackPayload + +actual class FirebaseIntegration : Integration { + override fun identify(identifyPayload: IdentifyPayload) { + } + override fun group(groupPayload: GroupPayload) { + } + override fun track(trackPayload: TrackPayload) { + } + override fun alias(aliasPayload: AliasPayload) { + } + override fun screen(screenPayload: ScreenPayload) { + } + override fun flush() { + } + override fun reset() { + } + + override fun debug(debug: Boolean) { + } + + actual companion object { + actual fun factory(delegate: Any?, deeplinkHandler: Any?): IntegrationFactory = TODO() + } +}