From 74155a2136db1a7af81243ceeef065f807298896 Mon Sep 17 00:00:00 2001 From: markvdouw Date: Tue, 25 Jul 2023 11:59:29 +0200 Subject: [PATCH 1/3] feat: sideloaded kit integration (#211) * Sideloaded kit integration * Testing sideloading integration * Fix dependency version * Changes due to comments * Adding kitId in constructor due to change in architecture * Implementing default functions from KitIntegration * Adding minimal sideloading kit example and kit-base dependency --- .../app/build.gradle.kts | 3 +- .../HiggsShopSampleApplication.kt | 14 ++- .../sideloading_kits/LoggingCustomKit.kt | 88 +++++++++++++++++++ .../sideloading_kits/MinimalSideloadingKit.kt | 5 ++ 4 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/sideloading_kits/LoggingCustomKit.kt create mode 100644 core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/sideloading_kits/MinimalSideloadingKit.kt diff --git a/core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts b/core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts index 6ea0fac8..c6ce5f66 100644 --- a/core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts +++ b/core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts @@ -66,7 +66,8 @@ dependencies { implementation("androidx.navigation:navigation-fragment-ktx:2.5.3") implementation("androidx.navigation:navigation-ui-ktx:2.5.3") implementation("com.google.android.material:material:1.7.0") - implementation("com.mparticle:android-core:5.48.0") + implementation("com.mparticle:android-core:5+") + implementation("com.mparticle:android-kit-base:5+") implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") // implementation(platform("com.google.firebase:firebase-bom:31.0.2")) diff --git a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/HiggsShopSampleApplication.kt b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/HiggsShopSampleApplication.kt index 59cb9c34..0a9e271d 100644 --- a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/HiggsShopSampleApplication.kt +++ b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/HiggsShopSampleApplication.kt @@ -3,15 +3,23 @@ package com.mparticle.example.higgsshopsampleapp; import android.app.Application import com.mparticle.MParticle import com.mparticle.MParticleOptions -import com.mparticle.networking.NetworkOptions +import com.mparticle.example.higgsshopsampleapp.sideloading_kits.LoggingCustomKit +import com.mparticle.example.higgsshopsampleapp.sideloading_kits.MinimalSideloadingKit -class HiggsShopSampleApplication: Application() { +class HiggsShopSampleApplication : Application() { val TAG = "HiggsShopSampleApplication" override fun onCreate() { super.onCreate() val options: MParticleOptions = MParticleOptions.builder(this) - .credentials(BuildConfig.HIGGS_SHOP_SAMPLE_APP_KEY, BuildConfig.HIGGS_SHOP_SAMPLE_APP_SECRET) + .credentials( + BuildConfig.HIGGS_SHOP_SAMPLE_APP_KEY, + BuildConfig.HIGGS_SHOP_SAMPLE_APP_SECRET + ) .environment(MParticle.Environment.Development) + .sideloadedKits(listOf( + LoggingCustomKit(1000001), LoggingCustomKit(1000002), + MinimalSideloadingKit(5000000) + )) // Disable SSL pinning for debugging network requests // .networkOptions( // NetworkOptions.builder() diff --git a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/sideloading_kits/LoggingCustomKit.kt b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/sideloading_kits/LoggingCustomKit.kt new file mode 100644 index 00000000..75f02b94 --- /dev/null +++ b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/sideloading_kits/LoggingCustomKit.kt @@ -0,0 +1,88 @@ +package com.mparticle.example.higgsshopsampleapp.sideloading_kits + +import android.content.Context +import android.util.Log +import com.mparticle.MPEvent +import com.mparticle.internal.CoreCallbacks.KitListener +import com.mparticle.kits.KitIntegration.EventListener +import com.mparticle.kits.MPSideloadedKit +import com.mparticle.kits.ReportingMessage +import java.lang.Exception + +class LoggingCustomKit(kitId: Int) : MPSideloadedKit(kitId), KitListener, EventListener { + + companion object { + private const val CUSTOM_KIT = "LoggingCustomKit" + } + + override fun getName(): String = CUSTOM_KIT + + override fun onKitCreate( + settings: MutableMap?, + context: Context? + ): MutableList { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT onKitCreate") + return mutableListOf() + } + + override fun leaveBreadcrumb(breadcrumb: String?): MutableList { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT leaveBreadcrumb with breadcrumb: ${breadcrumb.orEmpty()}") + return mutableListOf() + } + + override fun logError( + message: String?, + errorAttributes: MutableMap? + ): MutableList { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT logError with message: ${message.orEmpty()}") + return mutableListOf() + } + + override fun logException( + exception: Exception?, + exceptionAttributes: MutableMap?, + message: String? + ): MutableList { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT logException with exception: ${exception?.message.orEmpty()} and message: ${message.orEmpty()}") + return mutableListOf() + } + + override fun logEvent(baseEvent: MPEvent): MutableList? { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT logEvent with name: ${baseEvent.eventName}") + return super.logEvent(baseEvent) + } + + override fun logScreen( + screenName: String?, + screenAttributes: MutableMap? + ): MutableList { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT logScreen with screen name: ${screenName.orEmpty()}") + return mutableListOf() + } + + override fun setOptOut(optedOut: Boolean): MutableList = mutableListOf() + + override fun kitFound(kitId: Int) { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT kitFound for kit: $kitId") + } + + override fun kitConfigReceived(kitId: Int, p1: String?) { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT kitConfigReceived for kit: $kitId") + } + + override fun kitExcluded(kitId: Int, p1: String?) { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT kitExcluded for kit $kitId") + } + + override fun kitStarted(kitId: Int) { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT kitStarted for kit: $kitId") + } + + override fun onKitApiCalled(kitId: Int, p1: Boolean?, vararg p2: Any?) { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT onKitApiCalled for kit: $kitId") + } + + override fun onKitApiCalled(methodName: String?, kitId: Int, p2: Boolean?, vararg p3: Any?) { + Log.d(CUSTOM_KIT, "$CUSTOM_KIT onKitApiCalled for kit: $kitId with method name: ${methodName.orEmpty()}") + } +} \ No newline at end of file diff --git a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/sideloading_kits/MinimalSideloadingKit.kt b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/sideloading_kits/MinimalSideloadingKit.kt new file mode 100644 index 00000000..67ecda96 --- /dev/null +++ b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/sideloading_kits/MinimalSideloadingKit.kt @@ -0,0 +1,5 @@ +package com.mparticle.example.higgsshopsampleapp.sideloading_kits + +import com.mparticle.kits.MPSideloadedKit + +class MinimalSideloadingKit(kitId : Int) : MPSideloadedKit(kitId) \ No newline at end of file From 7a4089a69c52c4405c3c06c29996fae94c40c09e Mon Sep 17 00:00:00 2001 From: mpalexl Date: Tue, 1 Apr 2025 16:05:24 -0400 Subject: [PATCH 2/3] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 75fe29c8..23250208 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ hs_err_pid* .idea .gradle +test/test From b315a3e35147b0624c139f3786689567d9aa9ebe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 20:06:51 +0000 Subject: [PATCH 3/3] chore: bump androidx.lifecycle:lifecycle-viewmodel-ktx Bumps androidx.lifecycle:lifecycle-viewmodel-ktx from 2.5.1 to 2.8.7. --- updated-dependencies: - dependency-name: androidx.lifecycle:lifecycle-viewmodel-ktx dependency-version: 2.8.7 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts b/core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts index c6ce5f66..dae992df 100644 --- a/core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts +++ b/core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts @@ -61,7 +61,7 @@ dependencies { implementation("androidx.fragment:fragment:1.5.4") implementation("androidx.fragment:fragment-ktx:1.5.4") implementation("androidx.recyclerview:recyclerview:1.2.1") - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1") + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7") implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.5.1") implementation("androidx.navigation:navigation-fragment-ktx:2.5.3") implementation("androidx.navigation:navigation-ui-ktx:2.5.3")