From 74155a2136db1a7af81243ceeef065f807298896 Mon Sep 17 00:00:00 2001 From: markvdouw Date: Tue, 25 Jul 2023 11:59:29 +0200 Subject: [PATCH 01/21] 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 d8700880b475f6a47895358fe6fbbed6b7e95b5f Mon Sep 17 00:00:00 2001 From: James Newman Date: Fri, 11 Jul 2025 01:06:39 +1000 Subject: [PATCH 02/21] Base updates for AGP --- .gitignore | 2 ++ .../app/build.gradle.kts | 29 ++++++++++--------- .../activities/CheckoutActivity.kt | 2 +- .../activities/LandingActivity.kt | 2 +- .../activities/ProductDetailActivity.kt | 2 +- .../fragments/AccountFragment.kt | 2 +- .../repositories/database/daos/CartDao.kt | 8 ++--- .../higgsshopsampleapp/utils/ImageUtils.kt | 2 +- .../higgs-shop-sample-app/build.gradle.kts | 4 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 1 + 11 files changed, 30 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 75fe29c8..d080e2c8 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ hs_err_pid* .idea .gradle + +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..61f004f0 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,11 +11,12 @@ plugins { } android { - compileSdk = 33 + namespace = "com.mparticle.example.higgsshopsampleapp" + compileSdk = 34 defaultConfig { applicationId = "com.mparticle.example.higgsshopsampleapp" minSdk = 24 - targetSdk = 33 + targetSdk = 34 versionCode = buildVersionCode() versionName = "0.14.1-SNAPSHOT" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -24,11 +25,12 @@ android { buildConfigField("String", "HIGGS_SHOP_FCM_SENDER_ID", "\"${System.getenv("HIGGS_SHOP_FCM_SENDER_ID")}\"") } buildFeatures { + buildConfig = true dataBinding = true compose = true } composeOptions { - kotlinCompilerExtensionVersion = "1.3.2" + kotlinCompilerExtensionVersion = "1.5.8" } kotlinOptions { jvmTarget = "11" @@ -46,16 +48,15 @@ android { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } - namespace = "com.mparticle.example.higgsshopsampleapp" } dependencies { implementation("androidx.appcompat:appcompat:1.5.1") - implementation("androidx.compose.runtime:runtime:1.3.0") - implementation("androidx.compose.ui:ui:1.3.0") - implementation("androidx.compose.material:material:1.3.0") - implementation("androidx.compose.ui:ui-tooling:1.3.0") - implementation("androidx.compose.runtime:runtime-livedata:1.3.0") + implementation("androidx.compose.runtime:runtime:1.5.4") + implementation("androidx.compose.ui:ui:1.5.4") + implementation("androidx.compose.material:material:1.5.4") + implementation("androidx.compose.ui:ui-tooling:1.5.4") + implementation("androidx.compose.runtime:runtime-livedata:1.5.4") implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("androidx.core:core-ktx:1.9.0") implementation("androidx.fragment:fragment:1.5.4") @@ -77,9 +78,9 @@ dependencies { implementation("com.github.bumptech.glide:glide:4.14.2") - api("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") - api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4") + api("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.3") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") + api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3") implementation("com.squareup.retrofit2:retrofit:2.9.0") implementation("com.squareup.retrofit2:converter-gson:2.9.0") @@ -91,9 +92,9 @@ dependencies { implementation("com.squareup.okhttp3:okhttp:4.10.0") implementation("com.squareup.okhttp3:logging-interceptor:4.10.0") - debugImplementation("androidx.compose.ui:ui-tooling:1.3.0") + debugImplementation("androidx.compose.ui:ui-tooling:1.5.4") - 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/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/LandingActivity.kt b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/LandingActivity.kt index 64bb6456..5a737eec 100644 --- a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/LandingActivity.kt +++ b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/LandingActivity.kt @@ -77,7 +77,7 @@ class LandingActivity : AppCompatActivity() { ) val layoutParams = ActionBar.LayoutParams(snackbar.view.layoutParams) - val tv = (snackbar.view.findViewById(R.id.snackbar_text)) + val tv = (snackbar.view.findViewById(com.google.android.material.R.id.snackbar_text)) tv?.maxLines = 5 tv?.textAlignment = View.TEXT_ALIGNMENT_TEXT_START diff --git a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/ProductDetailActivity.kt b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/ProductDetailActivity.kt index 5b0fe2cd..ccb6ddbe 100644 --- a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/ProductDetailActivity.kt +++ b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/ProductDetailActivity.kt @@ -119,7 +119,7 @@ class ProductDetailActivity : AppCompatActivity() { snackbar.setBackgroundTint(getColor(R.color.white)) snackbar.setTextColor(getColor(R.color.black)) 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 snackbar.setActionTextColor(getColor(R.color.blue_4079FE)) val snackbarActionTextView = diff --git a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/fragments/AccountFragment.kt b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/fragments/AccountFragment.kt index c32fb22d..ed320850 100644 --- a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/fragments/AccountFragment.kt +++ b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/fragments/AccountFragment.kt @@ -76,7 +76,7 @@ class AccountFragment : Fragment() { val snackbar = Snackbar.make(parentLayout, message, Snackbar.LENGTH_SHORT) val layoutParams = ActionBar.LayoutParams(snackbar.view.layoutParams) - val tv = (snackbar.view.findViewById(R.id.snackbar_text)) + val tv = (snackbar.view.findViewById(com.google.android.material.R.id.snackbar_text)) tv?.textAlignment = View.TEXT_ALIGNMENT_CENTER snackbar.setBackgroundTint(requireContext().getColor(R.color.white)) diff --git a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/repositories/database/daos/CartDao.kt b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/repositories/database/daos/CartDao.kt index 64f75078..5b1b35b8 100644 --- a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/repositories/database/daos/CartDao.kt +++ b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/repositories/database/daos/CartDao.kt @@ -7,16 +7,16 @@ import com.mparticle.example.higgsshopsampleapp.repositories.database.entities.C interface CartDao { @Query("SELECT * FROM CartItems ORDER BY sku desc") - fun getAllCartItems(): List + suspend fun getAllCartItems(): List @Query("SELECT * FROM CartItems WHERE sku=:sku ORDER BY sku desc") - fun getCartItemByKey(sku: String): CartItemEntity? + suspend fun getCartItemByKey(sku: String): CartItemEntity? @Insert(onConflict = OnConflictStrategy.REPLACE) - suspend fun addToCart(CartItemEntity: CartItemEntity): Long + suspend fun addToCart(cartItem: CartItemEntity): Long @Delete - suspend fun removeFromCart(CartItemEntity: CartItemEntity): Int + suspend fun removeFromCart(cartItem: CartItemEntity): Int @Query("DELETE FROM CartItems") suspend fun clearCart(): Int diff --git a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/utils/ImageUtils.kt b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/utils/ImageUtils.kt index 63f4b35b..eb4b69f1 100644 --- a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/utils/ImageUtils.kt +++ b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/utils/ImageUtils.kt @@ -15,7 +15,7 @@ import com.bumptech.glide.request.transition.Transition import com.mparticle.example.higgsshopsampleapp.R -const val DEFAULT_PRODUCT_IMAGE = R.drawable.product_image_placeholder +var DEFAULT_PRODUCT_IMAGE = R.drawable.product_image_placeholder @SuppressLint("UnrememberedMutableState") @Composable 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..6c550106 100644 --- a/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts +++ b/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts @@ -6,8 +6,8 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:7.3.1") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20") + classpath("com.android.tools.build:gradle:8.6.1") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22") classpath("com.google.gms:google-services:4.3.14") } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 91a50655..27d0dafb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sun Feb 13 22:21:18 PST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index 94bbed1f..627b4094 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,6 +2,7 @@ dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) repositories { google() + mavenLocal() mavenCentral() } } From 5248f140e4d070b74de18dc57ab91af2c425972e Mon Sep 17 00:00:00 2001 From: James Newman Date: Fri, 11 Jul 2025 19:44:03 +1000 Subject: [PATCH 03/21] Remove excessive logging --- .../higgsshopsampleapp/repositories/ProductsRepository.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/repositories/ProductsRepository.kt b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/repositories/ProductsRepository.kt index 2b903eda..c5ffb227 100644 --- a/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/repositories/ProductsRepository.kt +++ b/core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/repositories/ProductsRepository.kt @@ -22,9 +22,11 @@ class ProductsRepository() { fun getProducts(context: Context) : List { val jsonFileString = getJsonDataFromAsset(context, "products.json") - Log.i(TAG, jsonFileString ?: "Could not find local products.json") + if (jsonFileString.isNullOrBlank()) { + Log.e(TAG, "Could not find local products.json") + } val listProductType = object : TypeToken() {}.type - var products: Products = Gson().fromJson(jsonFileString, listProductType) + val products: Products = Gson().fromJson(jsonFileString, listProductType) return products.products } From ced184538f371ee0c102a92117259854fb243670 Mon Sep 17 00:00:00 2001 From: James Newman Date: Fri, 11 Jul 2025 19:59:33 +1000 Subject: [PATCH 04/21] Update deps to use BOM and add Rokt --- .../app/build.gradle.kts | 128 +++++++++--------- .../higgs-shop-sample-app/build.gradle.kts | 6 +- 2 files changed, 67 insertions(+), 67 deletions(-) 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 61f004f0..355c4422 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 @@ -7,7 +7,7 @@ plugins { id("org.jlleitschuh.gradle.ktlint") version "11.0.0" // id("com.google.gms.google-services") kotlin("android") - kotlin("kapt") + id("com.google.devtools.ksp") } android { @@ -26,101 +26,97 @@ android { } buildFeatures { buildConfig = true + viewBinding = true dataBinding = true compose = true } composeOptions { - kotlinCompilerExtensionVersion = "1.5.8" + kotlinCompilerExtensionVersion = "1.5.15" } kotlinOptions { - jvmTarget = "11" + jvmTarget = "17" } buildTypes { - getByName("release") { + release { isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) } - getByName("debug") { + debug { isMinifyEnabled = false } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } } dependencies { - implementation("androidx.appcompat:appcompat:1.5.1") - implementation("androidx.compose.runtime:runtime:1.5.4") - implementation("androidx.compose.ui:ui:1.5.4") - implementation("androidx.compose.material:material:1.5.4") - implementation("androidx.compose.ui:ui-tooling:1.5.4") - implementation("androidx.compose.runtime:runtime-livedata:1.5.4") + // AndroidX BOM + implementation(platform("androidx.compose:compose-bom:2024.01.00")) + implementation("androidx.compose.runtime:runtime") + implementation("androidx.compose.ui:ui") + implementation("androidx.compose.material:material") + debugImplementation("androidx.compose.ui:ui-tooling") + implementation("androidx.compose.runtime:runtime-livedata") + + // Core AndroidX dependencies + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.appcompat:appcompat:1.6.1") implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("androidx.core:core-ktx:1.9.0") - 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-livedata-ktx:2.5.1") - 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+") - implementation("com.mparticle:android-kit-base:5+") - implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") + implementation("androidx.fragment:fragment-ktx:1.6.2") + implementation("androidx.recyclerview:recyclerview:1.3.2") + + // Lifecycle + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") + implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0") + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0") - // implementation(platform("com.google.firebase:firebase-bom:31.0.2")) - // implementation("com.google.firebase:firebase-analytics-ktx") + // Navigation + implementation("androidx.navigation:navigation-fragment-ktx:2.7.7") + implementation("androidx.navigation:navigation-ui-ktx:2.7.7") - // implementation("com.mparticle:android-media:1.4.2") + // Room + implementation("androidx.room:room-runtime:2.6.1") + implementation("androidx.room:room-ktx:2.6.1") + ksp("androidx.room:room-compiler:2.6.1") - implementation("com.github.bumptech.glide:glide:4.14.2") + // Coroutines + implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.7.3")) + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") - api("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.3") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") - api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3") + // OkHttp + implementation(platform("com.squareup.okhttp3:okhttp-bom:4.12.0")) + implementation("com.squareup.okhttp3:okhttp") + implementation("com.squareup.okhttp3:logging-interceptor") + // Retrofit implementation("com.squareup.retrofit2:retrofit:2.9.0") implementation("com.squareup.retrofit2:converter-gson:2.9.0") - implementation("com.squareup.retrofit2:converter-moshi:2.9.0") - implementation("com.squareup.retrofit2:adapter-rxjava2:2.9.0") - implementation("io.reactivex.rxjava2:rxjava:2.2.21") - implementation("io.reactivex.rxjava2:rxandroid:2.1.1") - implementation("com.squareup.okhttp3:logging-interceptor:4.10.0") - implementation("com.squareup.okhttp3:okhttp:4.10.0") - implementation("com.squareup.okhttp3:logging-interceptor:4.10.0") - debugImplementation("androidx.compose.ui:ui-tooling:1.5.4") + // mParticle + implementation("com.mparticle:android-core:5+") + implementation("com.mparticle:android-kit-base:5+") + implementation("com.mparticle:android-rokt-kit:5+") - val roomVersion = "2.6.1" - implementation("androidx.room:room-runtime:$roomVersion") - // annotationProcessor("androidx.room:room-compiler:$roomVersion") - kapt("androidx.room:room-compiler:$roomVersion") - // ksp("androidx.room:room-compiler:$roomVersion") - implementation("androidx.room:room-ktx:$roomVersion") - implementation("androidx.room:room-rxjava2:$roomVersion") - // implementation("androidx.room:room-rxjava3:$roomVersion") - // implementation("androidx.room:room-guava:$roomVersion") - // implementation("androidx.room:room-paging:2.4.1") - testImplementation("androidx.room:room-testing:$roomVersion") - testImplementation("junit:junit:4.13.2") + // Google Services + implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") - androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.3.0") - androidTestImplementation("androidx.test:core:1.4.0") - androidTestImplementation("androidx.test:core-ktx:1.4.0") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") - androidTestImplementation("androidx.test.espresso:espresso-intents:3.4.0") - androidTestImplementation("androidx.test:rules:1.4.0") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.ext:junit-ktx:1.1.3") - androidTestImplementation("androidx.test.ext:truth:1.4.0") - androidTestImplementation("androidx.test:runner:1.4.0") - androidTestImplementation("com.google.truth:truth:1.1.3") - androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4") + // Other dependencies + implementation("com.google.android.material:material:1.11.0") + implementation("com.google.code.gson:gson:2.10.1") + implementation("com.github.bumptech.glide:glide:4.16.0") + ksp("com.github.bumptech.glide:compiler:4.16.0") - androidTestUtil("androidx.test:orchestrator:1.4.1") + // Testing dependencies + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.ext:junit-ktx:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") } fun buildVersionCode(): Int { 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 6c550106..bfdd331d 100644 --- a/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts +++ b/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts @@ -7,11 +7,15 @@ buildscript { } dependencies { classpath("com.android.tools.build:gradle:8.6.1") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25") classpath("com.google.gms:google-services:4.3.14") } } +plugins { + id("com.google.devtools.ksp") version "1.9.25-1.0.20" apply false +} + tasks.register("clean", Delete::class) { delete(rootProject.buildDir) } \ No newline at end of file From d41dab33d21c791dd5a6db89e4adfba065a901c3 Mon Sep 17 00:00:00 2001 From: James Newman Date: Fri, 11 Jul 2025 19:59:56 +1000 Subject: [PATCH 05/21] Add Rokt overlay placement post checkout --- .../activities/CheckoutActivity.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 535e5fd5..347beb6d 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 @@ -40,6 +40,8 @@ import com.mparticle.example.higgsshopsampleapp.databinding.ActivityCheckoutBind import com.mparticle.example.higgsshopsampleapp.repositories.database.entities.CartItemEntity import com.mparticle.example.higgsshopsampleapp.utils.Constants import com.mparticle.example.higgsshopsampleapp.viewmodels.CheckoutViewModel +import com.mparticle.rokt.RoktConfig +import java.lang.ref.WeakReference import java.math.BigDecimal import java.util.* @@ -89,6 +91,7 @@ class CheckoutActivity : AppCompatActivity() { checkoutViewModel.checkOutLiveData.observe(this) { checkedOut -> if (checkedOut) { showPurchaseAlert() + showRoktPlacement() } } @@ -100,6 +103,21 @@ class CheckoutActivity : AppCompatActivity() { return super.onSupportNavigateUp() } + private fun showRoktPlacement() { + val attributes = mapOf( + "email" to "j.smith@example.com", + "firstname" to "Jenny", + "lastname" to "Smith", + "billingzipcode" to "90210", + "confirmationref" to "54321", + ) + + MParticle.getInstance()?.Rokt()?.selectPlacements( + identifier = "MSDKOverlayLayout", + attributes = attributes, + ) + } + fun showPurchaseAlert() { val snackbar = Snackbar.make( binding.root, From 7fbcfe29e9ec863e0a8c22240211caf6dd753f09 Mon Sep 17 00:00:00 2001 From: James Newman Date: Fri, 11 Jul 2025 20:33:14 +1000 Subject: [PATCH 06/21] Add Rokt close implementation --- .../activities/CheckoutActivity.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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 347beb6d..dc3cd732 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 @@ -27,9 +27,12 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.databinding.DataBindingUtil import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.lifecycleScope import com.google.android.material.snackbar.BaseTransientBottomBar import com.google.android.material.snackbar.Snackbar import com.mparticle.MParticle +import com.mparticle.RoktEvent +import com.mparticle.RoktEvent.PlacementReady import com.mparticle.commerce.CommerceEvent import com.mparticle.commerce.Product import com.mparticle.commerce.TransactionAttributes @@ -40,8 +43,10 @@ import com.mparticle.example.higgsshopsampleapp.databinding.ActivityCheckoutBind import com.mparticle.example.higgsshopsampleapp.repositories.database.entities.CartItemEntity import com.mparticle.example.higgsshopsampleapp.utils.Constants import com.mparticle.example.higgsshopsampleapp.viewmodels.CheckoutViewModel -import com.mparticle.rokt.RoktConfig -import java.lang.ref.WeakReference +import com.rokt.roktsdk.Rokt +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.launch import java.math.BigDecimal import java.util.* @@ -104,6 +109,8 @@ class CheckoutActivity : AppCompatActivity() { } private fun showRoktPlacement() { + val identifer = "MSDKOverlayLayout" + val attributes = mapOf( "email" to "j.smith@example.com", "firstname" to "Jenny", @@ -113,12 +120,16 @@ class CheckoutActivity : AppCompatActivity() { ) MParticle.getInstance()?.Rokt()?.selectPlacements( - identifier = "MSDKOverlayLayout", + identifier = identifer, attributes = attributes, ) + lifecycleScope.launch { + delay(5000) + MParticle.getInstance()?.Rokt()?.close() + } } - fun showPurchaseAlert() { + private fun showPurchaseAlert() { val snackbar = Snackbar.make( binding.root, getString(R.string.checkout_thanks), From de0bf0f617423235475c2976025b065abe187f6c Mon Sep 17 00:00:00 2001 From: James Newman Date: Fri, 11 Jul 2025 21:36:15 +1000 Subject: [PATCH 07/21] Add event logging and auto close --- .../activities/CheckoutActivity.kt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) 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 dc3cd732..1dea883c 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 @@ -31,7 +31,6 @@ import androidx.lifecycle.lifecycleScope import com.google.android.material.snackbar.BaseTransientBottomBar import com.google.android.material.snackbar.Snackbar import com.mparticle.MParticle -import com.mparticle.RoktEvent import com.mparticle.RoktEvent.PlacementReady import com.mparticle.commerce.CommerceEvent import com.mparticle.commerce.Product @@ -43,9 +42,7 @@ import com.mparticle.example.higgsshopsampleapp.databinding.ActivityCheckoutBind import com.mparticle.example.higgsshopsampleapp.repositories.database.entities.CartItemEntity import com.mparticle.example.higgsshopsampleapp.utils.Constants import com.mparticle.example.higgsshopsampleapp.viewmodels.CheckoutViewModel -import com.rokt.roktsdk.Rokt import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import java.math.BigDecimal import java.util.* @@ -109,7 +106,20 @@ class CheckoutActivity : AppCompatActivity() { } private fun showRoktPlacement() { - val identifer = "MSDKOverlayLayout" + val identifier = "MSDKOverlayLayout" + + lifecycleScope.launch { + MParticle.getInstance()?.Rokt()?.events(identifier)?.collect { + Log.v(TAG, "Rokt event: $it") + when (it) { + is PlacementReady -> { + delay(5000) + MParticle.getInstance()?.Rokt()?.close() + } + else -> {} + } + } + } val attributes = mapOf( "email" to "j.smith@example.com", @@ -120,13 +130,9 @@ class CheckoutActivity : AppCompatActivity() { ) MParticle.getInstance()?.Rokt()?.selectPlacements( - identifier = identifer, + identifier = identifier, attributes = attributes, ) - lifecycleScope.launch { - delay(5000) - MParticle.getInstance()?.Rokt()?.close() - } } private fun showPurchaseAlert() { From 1038c773cae556d2a172211887ee0c5f46f23d25 Mon Sep 17 00:00:00 2001 From: James Newman Date: Fri, 11 Jul 2025 22:15:57 +1000 Subject: [PATCH 08/21] Migrate to toml version management --- .../app/build.gradle.kts | 72 +++++++++--------- .../higgs-shop-sample-app/build.gradle.kts | 8 +- gradle/libs.versions.toml | 76 +++++++++++++++++++ 3 files changed, 116 insertions(+), 40 deletions(-) create mode 100644 gradle/libs.versions.toml 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 355c4422..7f5eb08b 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 @@ -56,47 +56,47 @@ android { dependencies { // AndroidX BOM - implementation(platform("androidx.compose:compose-bom:2024.01.00")) - implementation("androidx.compose.runtime:runtime") - implementation("androidx.compose.ui:ui") - implementation("androidx.compose.material:material") - debugImplementation("androidx.compose.ui:ui-tooling") - implementation("androidx.compose.runtime:runtime-livedata") + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.compose.runtime.runtime) + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material.material) + debugImplementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.runtime.livedata) // Core AndroidX dependencies - implementation("androidx.core:core-ktx:1.12.0") - implementation("androidx.appcompat:appcompat:1.6.1") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("androidx.fragment:fragment-ktx:1.6.2") - implementation("androidx.recyclerview:recyclerview:1.3.2") + implementation(libs.androidx.core.ktx) + implementation(libs.appcompat) + implementation(libs.androidx.constraintlayout) + implementation(libs.androidx.fragment.ktx) + implementation(libs.androidx.recyclerview) // Lifecycle - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") - implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0") - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0") + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.lifecycle.livedata.ktx) + implementation(libs.androidx.lifecycle.viewmodel.ktx) // Navigation - implementation("androidx.navigation:navigation-fragment-ktx:2.7.7") - implementation("androidx.navigation:navigation-ui-ktx:2.7.7") + implementation(libs.androidx.navigation.fragment.ktx) + implementation(libs.navigation.ui.ktx) // Room - implementation("androidx.room:room-runtime:2.6.1") - implementation("androidx.room:room-ktx:2.6.1") - ksp("androidx.room:room-compiler:2.6.1") + implementation(libs.androidx.room.runtime) + implementation(libs.androidx.room.ktx) + ksp(libs.androidx.room.compiler) // Coroutines - implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.7.3")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") + implementation(platform(libs.kotlinx.coroutines.bom)) + implementation(libs.org.jetbrains.kotlinx.coroutines.android) + implementation(libs.org.jetbrains.kotlinx.coroutines.core) // OkHttp - implementation(platform("com.squareup.okhttp3:okhttp-bom:4.12.0")) - implementation("com.squareup.okhttp3:okhttp") - implementation("com.squareup.okhttp3:logging-interceptor") + implementation(platform(libs.okhttp.bom)) + implementation(libs.okhttp3.okhttp) + implementation(libs.squareup.logging.interceptor) // Retrofit - implementation("com.squareup.retrofit2:retrofit:2.9.0") - implementation("com.squareup.retrofit2:converter-gson:2.9.0") + implementation(libs.com.squareup.retrofit) + implementation(libs.com.squareup.retrofit.converter.gson) // mParticle implementation("com.mparticle:android-core:5+") @@ -104,19 +104,19 @@ dependencies { implementation("com.mparticle:android-rokt-kit:5+") // Google Services - implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") + implementation(libs.play.services.ads.identifier) // Other dependencies - implementation("com.google.android.material:material:1.11.0") - implementation("com.google.code.gson:gson:2.10.1") - implementation("com.github.bumptech.glide:glide:4.16.0") - ksp("com.github.bumptech.glide:compiler:4.16.0") + implementation(libs.material) + implementation(libs.gson) + implementation(libs.glide) + ksp(libs.compiler.glide) // Testing dependencies - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.5") - androidTestImplementation("androidx.test.ext:junit-ktx:1.1.5") - androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.junit.ktx) + androidTestImplementation(libs.androidx.espresso.core) } fun buildVersionCode(): Int { 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 bfdd331d..a639c956 100644 --- a/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts +++ b/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts @@ -6,14 +6,14 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:8.6.1") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25") - classpath("com.google.gms:google-services:4.3.14") + classpath(libs.gradle) + classpath(libs.kotlin.gradle.plugin) + classpath(libs.google.services) } } plugins { - id("com.google.devtools.ksp") version "1.9.25-1.0.20" apply false + alias(libs.plugins.ksp) apply false } tasks.register("clean", Delete::class) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..87f3d225 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,76 @@ +[versions] +androidxConstraintlayout = "2.1.4" +androidxFragmentKtxVersion = "1.6.2" +androidxLifecycleViewmodelKtx = "2.7.0" +androidxRecyclerviewRecyclerview = "1.3.2" +androidxRoomKtxVersion = "2.6.1" +androidxRoomRoomCompiler = "2.6.1" +androidxRoomRuntime = "2.6.1" +appcompatVersion = "1.6.1" +compiler = "4.16.0" +composeBom = "2024.01.00" +comSquareupRetrofit2ConverterGson2 = "2.9.0" +comSquareupRetrofit2Retrofit = "2.9.0" +coreKtx = "1.12.0" +espressoCore = "3.5.1" +glide = "4.16.0" +googleServices = "4.3.14" +gradle = "8.6.1" +gson = "2.10.1" +junit = "4.13.2" +junitVersion = "1.1.5" +junitKtx = "1.1.5" +kotlinGradlePlugin = "1.9.25" +kotlinxCoroutinesBom = "1.7.3" +ksp = "1.9.25-1.0.20" +lifecycleLivedataKtxVersion = "2.7.0" +lifecycleRuntimeKtx = "2.7.0" +material = "1.11.0" +navigationFragmentKtx = "2.7.7" +navigationUiKtxVersion = "2.7.7" +okhttpBom = "4.12.0" +playServicesAdsIdentifier = "18.0.1" + +[libraries] +androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" } +androidx-compose-material-material = { module = "androidx.compose.material:material" } +androidx-compose-runtime-runtime = { module = "androidx.compose.runtime:runtime" } +androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidxConstraintlayout" } +androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" } +androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoCore" } +androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "androidxFragmentKtxVersion" } +androidx-junit-ktx = { module = "androidx.test.ext:junit-ktx", version.ref = "junitKtx" } +androidx-junit = { module = "androidx.test.ext:junit", version.ref = "junitVersion" } +androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidxLifecycleViewmodelKtx" } +androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } +androidx-navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigationFragmentKtx" } +androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "androidxRecyclerviewRecyclerview" } +androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "androidxRoomRoomCompiler" } +androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "androidxRoomKtxVersion" } +androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "androidxRoomRuntime" } +appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompatVersion" } +com-squareup-retrofit-converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "comSquareupRetrofit2ConverterGson2" } +com-squareup-retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "comSquareupRetrofit2Retrofit" } +compiler-glide = { module = "com.github.bumptech.glide:compiler", version.ref = "compiler" } +glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" } +google-services = { module = "com.google.gms:google-services", version.ref = "googleServices" } +gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" } +gson = { module = "com.google.code.gson:gson", version.ref = "gson" } +junit = { module = "junit:junit", version.ref = "junit" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinGradlePlugin" } +kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "kotlinxCoroutinesBom" } +lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycleLivedataKtxVersion" } +material = { module = "com.google.android.material:material", version.ref = "material" } +navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigationUiKtxVersion" } +okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttpBom" } +okhttp3-okhttp = { module = "com.squareup.okhttp3:okhttp" } +org-jetbrains-kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android" } +org-jetbrains-kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core" } +play-services-ads-identifier = { module = "com.google.android.gms:play-services-ads-identifier", version.ref = "playServicesAdsIdentifier" } +squareup-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor" } + +[plugins] +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } From 73534a1c6c347546f31697c294ee6d17cc4796c2 Mon Sep 17 00:00:00 2001 From: James Newman Date: Fri, 11 Jul 2025 22:16:12 +1000 Subject: [PATCH 09/21] Add lint baseline --- .../app/build.gradle.kts | 4 + .../app/lint-baseline.xml | 652 ++++++++++++++++++ 2 files changed, 656 insertions(+) create mode 100644 core-sdk-samples/higgs-shop-sample-app/app/lint-baseline.xml 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 7f5eb08b..3bbb81c6 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 @@ -52,6 +52,10 @@ android { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } + lint { + baseline = file("lint-baseline.xml") + disable += "MParticleVersionInconsistency" + } } dependencies { diff --git a/core-sdk-samples/higgs-shop-sample-app/app/lint-baseline.xml b/core-sdk-samples/higgs-shop-sample-app/app/lint-baseline.xml new file mode 100644 index 00000000..646f7f10 --- /dev/null +++ b/core-sdk-samples/higgs-shop-sample-app/app/lint-baseline.xml @@ -0,0 +1,652 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From f51ed202f12c389741f8d51bd640753ccc3cc538 Mon Sep 17 00:00:00 2001 From: James Newman Date: Fri, 11 Jul 2025 22:18:08 +1000 Subject: [PATCH 10/21] Add standard files --- .github/CODEOWNERS | 1 + .github/dependabot.yml | 13 +++++++++++-- .github/workflows/pull-request.yml | 11 +++++++++++ SECURITY.md | 9 +++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 SECURITY.md diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..3a87f152 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @mParticle/sdk-team diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 41bc4d10..4ac43f4e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,7 @@ version: 2 updates: - package-ecosystem: gradle - directory: "/core-sdk-samples/higgs-shop-sample-app/" + directory: "/" schedule: interval: daily time: "08:00" @@ -10,4 +10,13 @@ updates: labels: ['dependabot'] open-pull-requests-limit: 10 commit-message: - prefix: "chore" \ No newline at end of file + prefix: "chore" + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 4 + labels: + - dependabot + commit-message: + prefix: "chore" diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b1e7f22f..25558553 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -14,3 +14,14 @@ jobs: name: "Save PR Number for Dependabot Automerge" needs: [ higgs-shop-sample-app ] uses: mParticle/mparticle-workflows/.github/workflows/dependabot-save-pr-number.yml@main + + pr-notify: + if: > + github.event_name == 'pull_request' && + github.event.pull_request.draft == false + needs: + - higgs-shop-sample-app + name: Notify GChat + uses: ROKT/rokt-workflows/.github/workflows/oss_pr_opened_notification.yml@main + secrets: + gchat_webhook: ${{ secrets.GCHAT_PRS_WEBHOOK }} diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..4f3346ae --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,9 @@ +# Security Policy + +## Reporting a vulnerability + +To avoid abuse by malicious actors please do not open GitHub issues or pull requests for any security related issue you may have spotted. + +The safest way to report any vulnerability or concern you may have is via our [dedicated submission form](https://www.rokt.com/vulnerability-disclosure/). + +For further information please refer to the [Rokt Vulnerability Disclosure Policy](https://www.rokt.com/vulnerability-disclosure/). From 6bc3df271943753c93dce8225ea80c259d8e6cd0 Mon Sep 17 00:00:00 2001 From: James Newman Date: Mon, 14 Jul 2025 20:52:44 +1000 Subject: [PATCH 11/21] Migrate missed plugins --- .../higgs-shop-sample-app/app/build.gradle.kts | 8 ++++---- core-sdk-samples/higgs-shop-sample-app/build.gradle.kts | 5 +++-- gradle/libs.versions.toml | 8 +++++--- settings.gradle.kts | 8 ++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) 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 3bbb81c6..852e5720 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 @@ -3,11 +3,11 @@ import java.util.Date import java.util.TimeZone plugins { - id("com.android.application") - id("org.jlleitschuh.gradle.ktlint") version "11.0.0" + alias(libs.plugins.android.application) + alias(libs.plugins.ktlint) // id("com.google.gms.google-services") - kotlin("android") - id("com.google.devtools.ksp") + alias(libs.plugins.kotlin.android) + alias(libs.plugins.ksp) } android { 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 a639c956..4bd01edd 100644 --- a/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts +++ b/core-sdk-samples/higgs-shop-sample-app/build.gradle.kts @@ -6,14 +6,15 @@ buildscript { mavenCentral() } dependencies { - classpath(libs.gradle) - classpath(libs.kotlin.gradle.plugin) classpath(libs.google.services) } } plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.ksp) apply false + alias(libs.plugins.ktlint) apply false } tasks.register("clean", Delete::class) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 87f3d225..46d59a19 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,4 +1,5 @@ [versions] +androidGradlePlugin = "8.6.1" androidxConstraintlayout = "2.1.4" androidxFragmentKtxVersion = "1.6.2" androidxLifecycleViewmodelKtx = "2.7.0" @@ -15,7 +16,6 @@ coreKtx = "1.12.0" espressoCore = "3.5.1" glide = "4.16.0" googleServices = "4.3.14" -gradle = "8.6.1" gson = "2.10.1" junit = "4.13.2" junitVersion = "1.1.5" @@ -23,6 +23,7 @@ junitKtx = "1.1.5" kotlinGradlePlugin = "1.9.25" kotlinxCoroutinesBom = "1.7.3" ksp = "1.9.25-1.0.20" +ktlint = "11.0.0" lifecycleLivedataKtxVersion = "2.7.0" lifecycleRuntimeKtx = "2.7.0" material = "1.11.0" @@ -57,10 +58,8 @@ com-squareup-retrofit = { module = "com.squareup.retrofit2:retrofit", version.re compiler-glide = { module = "com.github.bumptech.glide:compiler", version.ref = "compiler" } glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" } google-services = { module = "com.google.gms:google-services", version.ref = "googleServices" } -gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" } gson = { module = "com.google.code.gson:gson", version.ref = "gson" } junit = { module = "junit:junit", version.ref = "junit" } -kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinGradlePlugin" } kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "kotlinxCoroutinesBom" } lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycleLivedataKtxVersion" } material = { module = "com.google.android.material:material", version.ref = "material" } @@ -74,3 +73,6 @@ squareup-logging-interceptor = { module = "com.squareup.okhttp3:logging-intercep [plugins] ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } +android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinGradlePlugin" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 627b4094..820362b0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,11 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) repositories { From 01f346f5245e7773f0f341709506cd56cbe0f7bb Mon Sep 17 00:00:00 2001 From: James Newman Date: Mon, 14 Jul 2025 21:37:31 +1000 Subject: [PATCH 12/21] Add versions to toml file --- gradle/libs.versions.toml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 46d59a19..f2ceb91e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,8 +12,12 @@ compiler = "4.16.0" composeBom = "2024.01.00" comSquareupRetrofit2ConverterGson2 = "2.9.0" comSquareupRetrofit2Retrofit = "2.9.0" +core = "1.4.0" coreKtx = "1.12.0" +coreKtxVersion = "1.4.0" +coreTesting = "2.1.0" espressoCore = "3.5.1" +espressoIntents = "3.4.0" glide = "4.16.0" googleServices = "4.3.14" gson = "2.10.1" @@ -22,15 +26,22 @@ junitVersion = "1.1.5" junitKtx = "1.1.5" kotlinGradlePlugin = "1.9.25" kotlinxCoroutinesBom = "1.7.3" +kotlinxCoroutinesTest = "1.6.4" ksp = "1.9.25-1.0.20" ktlint = "11.0.0" lifecycleLivedataKtxVersion = "2.7.0" lifecycleRuntimeKtx = "2.7.0" material = "1.11.0" +mockitoKotlin = "4.0.0" navigationFragmentKtx = "2.7.7" navigationUiKtxVersion = "2.7.7" okhttpBom = "4.12.0" playServicesAdsIdentifier = "18.0.1" +rules = "1.4.0" +runner = "1.4.0" +truth = "1.4.0" +truthVersion = "1.1.3" +uiTestJunit4 = "1.3.0" [libraries] androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" } @@ -40,8 +51,11 @@ androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } androidx-compose-ui = { module = "androidx.compose.ui:ui" } androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidxConstraintlayout" } +androidx-core = { module = "androidx.test:core", version.ref = "core" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" } +androidx-core-testing = { module = "androidx.arch.core:core-testing", version.ref = "coreTesting" } androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoCore" } +androidx-espresso-intents = { module = "androidx.test.espresso:espresso-intents", version.ref = "espressoIntents" } androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "androidxFragmentKtxVersion" } androidx-junit-ktx = { module = "androidx.test.ext:junit-ktx", version.ref = "junitKtx" } androidx-junit = { module = "androidx.test.ext:junit", version.ref = "junitVersion" } @@ -52,17 +66,24 @@ androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "androidxRoomRoomCompiler" } androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "androidxRoomKtxVersion" } androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "androidxRoomRuntime" } +androidx-rules = { module = "androidx.test:rules", version.ref = "rules" } +androidx-runner = { module = "androidx.test:runner", version.ref = "runner" } +androidx-truth = { module = "androidx.test.ext:truth", version.ref = "truth" } +androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "uiTestJunit4" } appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompatVersion" } com-squareup-retrofit-converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "comSquareupRetrofit2ConverterGson2" } com-squareup-retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "comSquareupRetrofit2Retrofit" } compiler-glide = { module = "com.github.bumptech.glide:compiler", version.ref = "compiler" } +core-ktx = { module = "androidx.test:core-ktx", version.ref = "coreKtxVersion" } glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" } google-services = { module = "com.google.gms:google-services", version.ref = "googleServices" } gson = { module = "com.google.code.gson:gson", version.ref = "gson" } junit = { module = "junit:junit", version.ref = "junit" } kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "kotlinxCoroutinesBom" } +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutinesTest" } lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycleLivedataKtxVersion" } material = { module = "com.google.android.material:material", version.ref = "material" } +mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockitoKotlin" } navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigationUiKtxVersion" } okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttpBom" } okhttp3-okhttp = { module = "com.squareup.okhttp3:okhttp" } @@ -70,6 +91,7 @@ org-jetbrains-kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kot org-jetbrains-kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core" } play-services-ads-identifier = { module = "com.google.android.gms:play-services-ads-identifier", version.ref = "playServicesAdsIdentifier" } squareup-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor" } +truth = { module = "com.google.truth:truth", version.ref = "truthVersion" } [plugins] ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } From 3ae6ee245092cd6273abb652ada97c31186557e3 Mon Sep 17 00:00:00 2001 From: James Newman Date: Mon, 14 Jul 2025 21:40:17 +1000 Subject: [PATCH 13/21] Add permissions --- .github/workflows/pull-request.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 25558553..6ee7e219 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -2,6 +2,12 @@ name: "Build and Test" on: [ push, workflow_dispatch, pull_request ] +permissions: + contents: read + pull-requests: read + checks: write + id-token: write + jobs: higgs-shop-sample-app: From 5fd7e843a229e789ede10c53b326b1d120508a7e Mon Sep 17 00:00:00 2001 From: James Newman Date: Mon, 14 Jul 2025 21:41:59 +1000 Subject: [PATCH 14/21] Bump upload artifact version --- .github/workflows/pull-request-app-checks.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull-request-app-checks.yml b/.github/workflows/pull-request-app-checks.yml index a7b232bc..5b7a8f58 100644 --- a/.github/workflows/pull-request-app-checks.yml +++ b/.github/workflows/pull-request-app-checks.yml @@ -55,7 +55,7 @@ jobs: api-level: 29 script: ./gradlew connectedCheck - name: "Archive Instrumented Tests Results" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: "instrumented-tests-results" @@ -81,7 +81,7 @@ jobs: working-directory: ${{ inputs.app_relative_path }} run: ./gradlew test - name: "Android Unit Tests Report" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: "unit-tests-results" @@ -107,7 +107,7 @@ jobs: working-directory: ${{ inputs.app_relative_path }} run: ./gradlew lint - name: "Archive Lint Test Results" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: "lint-results" @@ -133,7 +133,7 @@ jobs: working-directory: ${{ inputs.app_relative_path }} run: ./gradlew ktlintCheck - name: "Archive Lint Test Results" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: "kotlin-lint-results" From 375140c866d9160051f097ea0e023af0ba1adfec Mon Sep 17 00:00:00 2001 From: James Newman Date: Mon, 14 Jul 2025 21:42:58 +1000 Subject: [PATCH 15/21] Add concurrency --- .github/workflows/pull-request.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6ee7e219..d762e4ba 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -2,6 +2,10 @@ name: "Build and Test" on: [ push, workflow_dispatch, pull_request ] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + permissions: contents: read pull-requests: read From d5beeba44634de91834834bded06b416d6110100 Mon Sep 17 00:00:00 2001 From: James Newman Date: Mon, 14 Jul 2025 21:46:23 +1000 Subject: [PATCH 16/21] Remove main qualifier --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d762e4ba..819585c9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -16,7 +16,7 @@ jobs: higgs-shop-sample-app: name: "Check Higgs Shop Sample App" - uses: mParticle/mparticle-android-sample-apps/.github/workflows/pull-request-app-checks.yml@main + uses: mParticle/mparticle-android-sample-apps/.github/workflows/pull-request-app-checks.yml with: app_relative_path: "core-sdk-samples/higgs-shop-sample-app" From eea3e2eb70be727ed9db7a1ba9608629e6f4a713 Mon Sep 17 00:00:00 2001 From: James Newman Date: Mon, 14 Jul 2025 21:51:34 +1000 Subject: [PATCH 17/21] Use local reference --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 819585c9..f9021e52 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -16,7 +16,7 @@ jobs: higgs-shop-sample-app: name: "Check Higgs Shop Sample App" - uses: mParticle/mparticle-android-sample-apps/.github/workflows/pull-request-app-checks.yml + uses: ./.github/workflows/pull-request-app-checks.yml with: app_relative_path: "core-sdk-samples/higgs-shop-sample-app" From 9006201e0c94094629c60f1d0585a1ab8392058f Mon Sep 17 00:00:00 2001 From: James Newman Date: Mon, 14 Jul 2025 21:55:10 +1000 Subject: [PATCH 18/21] Bump versions --- .github/workflows/pull-request-app-checks.yml | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pull-request-app-checks.yml b/.github/workflows/pull-request-app-checks.yml index 5b7a8f58..135497d7 100644 --- a/.github/workflows/pull-request-app-checks.yml +++ b/.github/workflows/pull-request-app-checks.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: "Checkout Sample Apps" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive # - name: "Create Path Triggers" @@ -39,14 +39,14 @@ jobs: needs: confirm-folder-changes steps: - name: "Checkout Branch" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - - name: "Install JDK 11" - uses: actions/setup-java@v3 + - name: "Install JDK" + uses: actions/setup-java@v4 with: distribution: "zulu" - java-version: "11" + java-version: 17 cache: "gradle" - name: "Run Instrumented Tests" uses: reactivecircus/android-emulator-runner@v2.27.0 @@ -68,14 +68,14 @@ jobs: needs: confirm-folder-changes steps: - name: "Checkout Branch" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - - name: "Install JDK 11" - uses: actions/setup-java@v3 + - name: "Install JDK" + uses: actions/setup-java@v4 with: distribution: "zulu" - java-version: "11" + java-version: 17 cache: "gradle" - name: "Run Unit Tests" working-directory: ${{ inputs.app_relative_path }} @@ -94,14 +94,14 @@ jobs: needs: confirm-folder-changes steps: - name: "Checkout Branch" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - - name: "Install JDK 11" - uses: actions/setup-java@v3 + - name: Install JDK + uses: actions/setup-java@v4 with: distribution: "zulu" - java-version: "11" + java-version: 17 cache: "gradle" - name: "Run Android Core SDK Lint" working-directory: ${{ inputs.app_relative_path }} @@ -120,14 +120,14 @@ jobs: needs: confirm-folder-changes steps: - name: "Checkout Branch" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - - name: "Install JDK 11" - uses: actions/setup-java@v3 + - name: Install JDK + uses: actions/setup-java@v4 with: distribution: "zulu" - java-version: "11" + java-version: 17 cache: "gradle" - name: "Run Android Core SDK Kotlin Lint" working-directory: ${{ inputs.app_relative_path }} From b06345d6e2f5d9a27d96ebfc4c2b01976a81193a Mon Sep 17 00:00:00 2001 From: James Newman Date: Tue, 15 Jul 2025 00:35:20 +1000 Subject: [PATCH 19/21] Change runner to recommended by reactivecircus --- .github/workflows/pull-request-app-checks.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull-request-app-checks.yml b/.github/workflows/pull-request-app-checks.yml index 135497d7..87291a96 100644 --- a/.github/workflows/pull-request-app-checks.yml +++ b/.github/workflows/pull-request-app-checks.yml @@ -35,7 +35,7 @@ jobs: instrumented-tests: name: "Instrumented Tests" timeout-minutes: 30 - runs-on: macos-latest + runs-on: ubuntu-latest needs: confirm-folder-changes steps: - name: "Checkout Branch" @@ -48,11 +48,18 @@ jobs: distribution: "zulu" java-version: 17 cache: "gradle" + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm - name: "Run Instrumented Tests" - uses: reactivecircus/android-emulator-runner@v2.27.0 + uses: reactivecircus/android-emulator-runner@v2 with: working-directory: ${{ inputs.app_relative_path }} api-level: 29 + arch: x86_64 + profile: Nexus 6 script: ./gradlew connectedCheck - name: "Archive Instrumented Tests Results" uses: actions/upload-artifact@v4 @@ -90,7 +97,7 @@ jobs: lint-checks: name: "Lint Checks" timeout-minutes: 15 - runs-on: macos-latest + runs-on: ubuntu-latest needs: confirm-folder-changes steps: - name: "Checkout Branch" @@ -116,7 +123,7 @@ jobs: kotlin-lint-checks: name: "Kotlin Lint Checks" timeout-minutes: 15 - runs-on: macos-latest + runs-on: ubuntu-latest needs: confirm-folder-changes steps: - name: "Checkout Branch" From 4c6e56d8f79c8ac077a7b9bfee8555611d4e3ffe Mon Sep 17 00:00:00 2001 From: James Newman Date: Tue, 15 Jul 2025 00:38:53 +1000 Subject: [PATCH 20/21] Bump gradle version --- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-sdk-samples/higgs-shop-sample-app/gradle/wrapper/gradle-wrapper.properties b/core-sdk-samples/higgs-shop-sample-app/gradle/wrapper/gradle-wrapper.properties index 56dca877..586a7bbe 100644 --- a/core-sdk-samples/higgs-shop-sample-app/gradle/wrapper/gradle-wrapper.properties +++ b/core-sdk-samples/higgs-shop-sample-app/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sun Feb 13 22:22:36 PST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From fdf0d27de8a24e20e8e3e92576387f9dc39b4d53 Mon Sep 17 00:00:00 2001 From: James Newman Date: Tue, 15 Jul 2025 00:48:26 +1000 Subject: [PATCH 21/21] Update settings.gradle.kts --- .../higgs-shop-sample-app/settings.gradle.kts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core-sdk-samples/higgs-shop-sample-app/settings.gradle.kts b/core-sdk-samples/higgs-shop-sample-app/settings.gradle.kts index a9df6ffc..a968693b 100644 --- a/core-sdk-samples/higgs-shop-sample-app/settings.gradle.kts +++ b/core-sdk-samples/higgs-shop-sample-app/settings.gradle.kts @@ -1,5 +1,13 @@ import org.gradle.api.initialization.resolve.RepositoriesMode +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) repositories { @@ -7,6 +15,11 @@ dependencyResolutionManagement { mavenLocal() mavenCentral() } + versionCatalogs { + create("libs") { + from(files("../../gradle/libs.versions.toml")) + } + } } rootProject.name = "Higgs Shop Sample App"