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 3f6a23a7432172cd3203f0858d4a4308463446b5 Mon Sep 17 00:00:00 2001 From: Mansi Pandya Date: Wed, 12 Mar 2025 17:38:12 -0400 Subject: [PATCH 2/3] Gradle 7 working settings --- .../higgs-shop-sample-app/app/build.gradle.kts | 7 ++++--- .../higgsshopsampleapp/activities/CheckoutActivity.kt | 2 +- core-sdk-samples/higgs-shop-sample-app/build.gradle.kts | 2 +- local.properties | 8 ++++++++ 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 local.properties 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..14fbe408 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 @@ -11,7 +11,7 @@ plugins { } android { - compileSdk = 33 + compileSdk = 34 defaultConfig { applicationId = "com.mparticle.example.higgsshopsampleapp" minSdk = 24 @@ -26,9 +26,10 @@ android { buildFeatures { dataBinding = true compose = true + buildConfig = true } composeOptions { - kotlinCompilerExtensionVersion = "1.3.2" + kotlinCompilerExtensionVersion = "1.5.2" } kotlinOptions { jvmTarget = "11" @@ -93,7 +94,7 @@ dependencies { debugImplementation("androidx.compose.ui:ui-tooling:1.3.0") - val roomVersion = "2.4.3" + val roomVersion = "2.6.1" implementation("androidx.room:room-runtime:$roomVersion") // annotationProcessor("androidx.room:room-compiler:$roomVersion") kapt("androidx.room:room-compiler:$roomVersion") diff --git a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/CheckoutActivity.kt b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/CheckoutActivity.kt index 207c4892..535e5fd5 100644 --- a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/CheckoutActivity.kt +++ b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/CheckoutActivity.kt @@ -112,7 +112,7 @@ class CheckoutActivity : AppCompatActivity() { snackbar.setTextColor(getColor(R.color.black)) snackbar.setActionTextColor(getColor(R.color.blue_4079FE)) snackbar.view.setPadding(20, 10, 20, 0) - (snackbar.view.findViewById(R.id.snackbar_text))?.textAlignment = + (snackbar.view.findViewById(com.google.android.material.R.id.snackbar_text))?.textAlignment = View.TEXT_ALIGNMENT_TEXT_START val snackbarActionTextView = snackbar.view.findViewById(com.google.android.material.R.id.snackbar_action) as TextView diff --git a/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts b/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts index 6273e76f..3de76f62 100644 --- a/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts +++ b/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts @@ -7,7 +7,7 @@ buildscript { } dependencies { classpath("com.android.tools.build:gradle:7.3.1") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0") classpath("com.google.gms:google-services:4.3.14") } } diff --git a/local.properties b/local.properties new file mode 100644 index 00000000..d240ae75 --- /dev/null +++ b/local.properties @@ -0,0 +1,8 @@ +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Wed Mar 12 17:04:50 EDT 2025 +sdk.dir=/Users/mpandya/Library/Android/sdk From 8f17d023bb33e5c058c755faa036fa50ff0567c1 Mon Sep 17 00:00:00 2001 From: Mansi Pandya Date: Tue, 22 Apr 2025 11:18:50 -0400 Subject: [PATCH 3/3] Gradle 7 setup --- core-sdk-samples/higgs-shop-sample-app/build.gradle.kts | 2 +- gradle.properties | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts b/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts index 3de76f62..0d67d87c 100644 --- a/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts +++ b/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts @@ -6,7 +6,7 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:7.3.1") + classpath("com.android.tools.build:gradle:7.2.2") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0") classpath("com.google.gms:google-services:4.3.14") } diff --git a/gradle.properties b/gradle.properties index 98bed167..18cf9391 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,6 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official +# Enable Jetpack Compose +android.compose.compiler.kotlin.version=1.7.21 \ No newline at end of file