Skip to content

Commit 74155a2

Browse files
author
markvdouw
authored
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
1 parent 01c5b6c commit 74155a2

File tree

4 files changed

+106
-4
lines changed

4 files changed

+106
-4
lines changed

core-sdk-samples/higgs-shop-sample-app/app/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ dependencies {
6666
implementation("androidx.navigation:navigation-fragment-ktx:2.5.3")
6767
implementation("androidx.navigation:navigation-ui-ktx:2.5.3")
6868
implementation("com.google.android.material:material:1.7.0")
69-
implementation("com.mparticle:android-core:5.48.0")
69+
implementation("com.mparticle:android-core:5+")
70+
implementation("com.mparticle:android-kit-base:5+")
7071
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
7172

7273
// implementation(platform("com.google.firebase:firebase-bom:31.0.2"))

core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/HiggsShopSampleApplication.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,23 @@ package com.mparticle.example.higgsshopsampleapp;
33
import android.app.Application
44
import com.mparticle.MParticle
55
import com.mparticle.MParticleOptions
6-
import com.mparticle.networking.NetworkOptions
6+
import com.mparticle.example.higgsshopsampleapp.sideloading_kits.LoggingCustomKit
7+
import com.mparticle.example.higgsshopsampleapp.sideloading_kits.MinimalSideloadingKit
78

8-
class HiggsShopSampleApplication: Application() {
9+
class HiggsShopSampleApplication : Application() {
910
val TAG = "HiggsShopSampleApplication"
1011
override fun onCreate() {
1112
super.onCreate()
1213
val options: MParticleOptions = MParticleOptions.builder(this)
13-
.credentials(BuildConfig.HIGGS_SHOP_SAMPLE_APP_KEY, BuildConfig.HIGGS_SHOP_SAMPLE_APP_SECRET)
14+
.credentials(
15+
BuildConfig.HIGGS_SHOP_SAMPLE_APP_KEY,
16+
BuildConfig.HIGGS_SHOP_SAMPLE_APP_SECRET
17+
)
1418
.environment(MParticle.Environment.Development)
19+
.sideloadedKits(listOf(
20+
LoggingCustomKit(1000001), LoggingCustomKit(1000002),
21+
MinimalSideloadingKit(5000000)
22+
))
1523
// Disable SSL pinning for debugging network requests
1624
// .networkOptions(
1725
// NetworkOptions.builder()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.mparticle.example.higgsshopsampleapp.sideloading_kits
2+
3+
import android.content.Context
4+
import android.util.Log
5+
import com.mparticle.MPEvent
6+
import com.mparticle.internal.CoreCallbacks.KitListener
7+
import com.mparticle.kits.KitIntegration.EventListener
8+
import com.mparticle.kits.MPSideloadedKit
9+
import com.mparticle.kits.ReportingMessage
10+
import java.lang.Exception
11+
12+
class LoggingCustomKit(kitId: Int) : MPSideloadedKit(kitId), KitListener, EventListener {
13+
14+
companion object {
15+
private const val CUSTOM_KIT = "LoggingCustomKit"
16+
}
17+
18+
override fun getName(): String = CUSTOM_KIT
19+
20+
override fun onKitCreate(
21+
settings: MutableMap<String, String>?,
22+
context: Context?
23+
): MutableList<ReportingMessage> {
24+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT onKitCreate")
25+
return mutableListOf()
26+
}
27+
28+
override fun leaveBreadcrumb(breadcrumb: String?): MutableList<ReportingMessage> {
29+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT leaveBreadcrumb with breadcrumb: ${breadcrumb.orEmpty()}")
30+
return mutableListOf()
31+
}
32+
33+
override fun logError(
34+
message: String?,
35+
errorAttributes: MutableMap<String, String>?
36+
): MutableList<ReportingMessage> {
37+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT logError with message: ${message.orEmpty()}")
38+
return mutableListOf()
39+
}
40+
41+
override fun logException(
42+
exception: Exception?,
43+
exceptionAttributes: MutableMap<String, String>?,
44+
message: String?
45+
): MutableList<ReportingMessage> {
46+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT logException with exception: ${exception?.message.orEmpty()} and message: ${message.orEmpty()}")
47+
return mutableListOf()
48+
}
49+
50+
override fun logEvent(baseEvent: MPEvent): MutableList<ReportingMessage>? {
51+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT logEvent with name: ${baseEvent.eventName}")
52+
return super.logEvent(baseEvent)
53+
}
54+
55+
override fun logScreen(
56+
screenName: String?,
57+
screenAttributes: MutableMap<String, String>?
58+
): MutableList<ReportingMessage> {
59+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT logScreen with screen name: ${screenName.orEmpty()}")
60+
return mutableListOf()
61+
}
62+
63+
override fun setOptOut(optedOut: Boolean): MutableList<ReportingMessage> = mutableListOf()
64+
65+
override fun kitFound(kitId: Int) {
66+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT kitFound for kit: $kitId")
67+
}
68+
69+
override fun kitConfigReceived(kitId: Int, p1: String?) {
70+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT kitConfigReceived for kit: $kitId")
71+
}
72+
73+
override fun kitExcluded(kitId: Int, p1: String?) {
74+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT kitExcluded for kit $kitId")
75+
}
76+
77+
override fun kitStarted(kitId: Int) {
78+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT kitStarted for kit: $kitId")
79+
}
80+
81+
override fun onKitApiCalled(kitId: Int, p1: Boolean?, vararg p2: Any?) {
82+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT onKitApiCalled for kit: $kitId")
83+
}
84+
85+
override fun onKitApiCalled(methodName: String?, kitId: Int, p2: Boolean?, vararg p3: Any?) {
86+
Log.d(CUSTOM_KIT, "$CUSTOM_KIT onKitApiCalled for kit: $kitId with method name: ${methodName.orEmpty()}")
87+
}
88+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.mparticle.example.higgsshopsampleapp.sideloading_kits
2+
3+
import com.mparticle.kits.MPSideloadedKit
4+
5+
class MinimalSideloadingKit(kitId : Int) : MPSideloadedKit(kitId)

0 commit comments

Comments
 (0)