Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump org.jetbrains.kotlin:kotlin-gradle-plugin from 1.8.10 to 1.9.10 #160

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.4.1'
classpath 'com.mparticle:android-kit-plugin:' + project.version
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10'
}
}

Expand Down Expand Up @@ -43,12 +43,11 @@ android {
}

repositories {
maven { url "https://appboy.github.io/appboy-android-sdk/sdk" }
mavenCentral()
}

dependencies {
compileOnly 'com.google.firebase:firebase-messaging:[10.2.1, )'
api 'com.appboy:android-sdk-ui:24.3.0'
api 'com.braze:android-sdk-ui:25.0.0'
testImplementation files('libs/java-json.jar')
}
36 changes: 29 additions & 7 deletions src/main/kotlin/com/mparticle/kits/AppboyKit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,13 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,
if (eventList != null) {
for (i in eventList.indices) {
try {
logEvent(eventList[i])
val e = eventList[i]
val map = mutableMapOf<String, String>()
event.customAttributeStrings?.let { map.putAll(it) }
for (pair in map) {
e.customAttributes?.put(pair.key, pair.value)
}
logEvent(e)
messages.add(ReportingMessage.fromEvent(this, event))
} catch (e: Exception) {
Logger.warning("Failed to call logCustomEvent to Appboy kit: $e")
Expand Down Expand Up @@ -445,6 +451,13 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,
if (KitUtils.isEmpty(currencyValue)) {
currencyValue = CommerceEventUtils.Constants.DEFAULT_CURRENCY_CODE
}

event?.customAttributes?.let {
for ((key, value) in it) {
purchaseProperties.addProperty(key, value)
}
}

Braze.Companion.getInstance(context).logPurchase(
product.sku,
currencyValue,
Expand Down Expand Up @@ -523,7 +536,7 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,

val eventName = "eCommerce - %s"
if (!KitUtils.isEmpty(event?.productAction) &&
event?.productAction.equals(Product.PURCHASE,true)
event?.productAction.equals(Product.PURCHASE, true)
) {
Braze.Companion.getInstance(context).logPurchase(
String.format(eventName, event?.productAction),
Expand All @@ -534,11 +547,14 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,
)
} else {
if (!KitUtils.isEmpty(event?.productAction)) {
Braze.getInstance(context).logCustomEvent(String.format(eventName, event?.productAction), properties)
Braze.getInstance(context)
.logCustomEvent(String.format(eventName, event?.productAction), properties)
} else if (!KitUtils.isEmpty(event?.promotionAction)) {
Braze.getInstance(context).logCustomEvent(String.format(eventName, event?.promotionAction), properties)
Braze.getInstance(context)
.logCustomEvent(String.format(eventName, event?.promotionAction), properties)
} else {
Braze.getInstance(context).logCustomEvent(String.format(eventName, "Impression"), properties)
Braze.getInstance(context)
.logCustomEvent(String.format(eventName, "Impression"), properties)
}
}
}
Expand Down Expand Up @@ -763,7 +779,10 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,
for ((i, promotion) in promotionList.withIndex()) {
val promotionProperties = BrazeProperties()
promotion.creative?.let {
promotionProperties.addProperty(CommerceEventUtils.Constants.ATT_PROMOTION_CREATIVE, it)
promotionProperties.addProperty(
CommerceEventUtils.Constants.ATT_PROMOTION_CREATIVE,
it
)
}
promotion.id?.let {
promotionProperties.addProperty(CommerceEventUtils.Constants.ATT_PROMOTION_ID, it)
Expand All @@ -772,7 +791,10 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,
promotionProperties.addProperty(CommerceEventUtils.Constants.ATT_PROMOTION_NAME, it)
}
promotion.position?.let {
promotionProperties.addProperty(CommerceEventUtils.Constants.ATT_PROMOTION_POSITION, it)
promotionProperties.addProperty(
CommerceEventUtils.Constants.ATT_PROMOTION_POSITION,
it
)
}
promotionArray[i] = promotionProperties
}
Expand Down
141 changes: 123 additions & 18 deletions src/test/kotlin/com/mparticle/kits/AppboyKitTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.mparticle.MPEvent
import com.mparticle.MParticle
import com.mparticle.MParticle.IdentityType
import com.mparticle.MParticle.LogLevel
import com.mparticle.MParticleOptions
import com.mparticle.commerce.CommerceEvent
import com.mparticle.commerce.Impression
import com.mparticle.commerce.Product
Expand Down Expand Up @@ -74,11 +75,12 @@ class AppboyKitTests {
@Test
@Throws(Exception::class)
fun testClassName() {
val factory = KitIntegrationFactory()
val integrations = factory.knownIntegrations
val options = Mockito.mock(MParticleOptions::class.java)
val factory = KitIntegrationFactory(options)
val integrations = factory.supportedKits.values
val className = kit.javaClass.name
for (integration in integrations) {
if (integration.value == className) {
if (integration.name == className) {
return
}
}
Expand Down Expand Up @@ -449,6 +451,11 @@ class AppboyKitTests {
properties.remove(CommerceEventUtils.Constants.ATT_AFFILIATION),
"the affiliation"
)

//Custom Attributes
Assert.assertEquals(properties.remove("key1"), "value1")
Assert.assertEquals(properties.remove("key #2"), "value #3")

val emptyAttributes = HashMap<String, String>()
Assert.assertEquals(emptyAttributes, properties)
}
Expand Down Expand Up @@ -494,11 +501,26 @@ class AppboyKitTests {
val productBrazeProperties = productArray[0]
if (productBrazeProperties is BrazeProperties) {
val productProperties = productBrazeProperties.properties
Assert.assertEquals(productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_TOTAL_AMOUNT), 22.5)
Assert.assertEquals(productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_PRICE), 4.5)
Assert.assertEquals(productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_QUANTITY), 5.0)
Assert.assertEquals(productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_ID), "sku1")
Assert.assertEquals(productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_NAME), "product name")
Assert.assertEquals(
productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_TOTAL_AMOUNT),
22.5
)
Assert.assertEquals(
productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_PRICE),
4.5
)
Assert.assertEquals(
productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_QUANTITY),
5.0
)
Assert.assertEquals(
productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_ID),
"sku1"
)
Assert.assertEquals(
productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_NAME),
"product name"
)
Assert.assertEquals(emptyAttributes, productProperties)
}
}
Expand Down Expand Up @@ -584,7 +606,7 @@ class AppboyKitTests {
id = "my_promo_1"
creative = "sale_banner_1"
name = "App-wide 50% off sale"
position ="dashboard_bottom"
position = "dashboard_bottom"
}
val commerceEvent = CommerceEvent.Builder(Promotion.VIEW, promotion)
.customAttributes(customAttributes)
Expand All @@ -604,10 +626,22 @@ class AppboyKitTests {
val promotionBrazeProperties = promotionArray[0]
if (promotionBrazeProperties is BrazeProperties) {
val promotionProperties = promotionBrazeProperties.properties
Assert.assertEquals(promotionProperties.remove(CommerceEventUtils.Constants.ATT_PROMOTION_ID), "my_promo_1")
Assert.assertEquals(promotionProperties.remove(CommerceEventUtils.Constants.ATT_PROMOTION_NAME), "App-wide 50% off sale")
Assert.assertEquals(promotionProperties.remove(CommerceEventUtils.Constants.ATT_PROMOTION_POSITION), "dashboard_bottom")
Assert.assertEquals(promotionProperties.remove(CommerceEventUtils.Constants.ATT_PROMOTION_CREATIVE), "sale_banner_1")
Assert.assertEquals(
promotionProperties.remove(CommerceEventUtils.Constants.ATT_PROMOTION_ID),
"my_promo_1"
)
Assert.assertEquals(
promotionProperties.remove(CommerceEventUtils.Constants.ATT_PROMOTION_NAME),
"App-wide 50% off sale"
)
Assert.assertEquals(
promotionProperties.remove(CommerceEventUtils.Constants.ATT_PROMOTION_POSITION),
"dashboard_bottom"
)
Assert.assertEquals(
promotionProperties.remove(CommerceEventUtils.Constants.ATT_PROMOTION_CREATIVE),
"sale_banner_1"
)
Assert.assertEquals(emptyAttributes, promotionProperties)
}
}
Expand Down Expand Up @@ -697,7 +731,10 @@ class AppboyKitTests {
val impressionBrazeProperties = impressionArray[0]
if (impressionBrazeProperties is BrazeProperties) {
val impressionProperties = impressionBrazeProperties.properties
Assert.assertEquals(impressionProperties.remove("Product Impression List"), "Suggested Products List")
Assert.assertEquals(
impressionProperties.remove("Product Impression List"),
"Suggested Products List"
)
val productArray = impressionProperties.remove(AppboyKit.PRODUCT_KEY)
Assert.assertTrue(productArray is Array<*>)
if (productArray is Array<*>) {
Expand Down Expand Up @@ -725,11 +762,19 @@ class AppboyKitTests {
productProperties.remove(CommerceEventUtils.Constants.ATT_PRODUCT_PRICE),
4.5
)
val brazeProductCustomAttributesDictionary = productProperties.remove(AppboyKit.CUSTOM_ATTRIBUTES_KEY)
val brazeProductCustomAttributesDictionary =
productProperties.remove(AppboyKit.CUSTOM_ATTRIBUTES_KEY)
if (brazeProductCustomAttributesDictionary is BrazeProperties) {
val customProductAttributesDictionary = brazeProductCustomAttributesDictionary.properties
Assert.assertEquals(customProductAttributesDictionary.remove("key1"), "value1")
Assert.assertEquals(customProductAttributesDictionary.remove("key #2"), "value #3")
val customProductAttributesDictionary =
brazeProductCustomAttributesDictionary.properties
Assert.assertEquals(
customProductAttributesDictionary.remove("key1"),
"value1"
)
Assert.assertEquals(
customProductAttributesDictionary.remove("key #2"),
"value #3"
)
Assert.assertEquals(emptyAttributes, customProductAttributesDictionary)
}
Assert.assertEquals(emptyAttributes, productProperties)
Expand Down Expand Up @@ -797,6 +842,66 @@ class AppboyKitTests {
// Assert.assertEquals(0, properties.size.toLong())
// }

// @Test
// fun testLogCommerceEvent() {
// val kit = MockAppboyKit()
//
// val product: Product = Product.Builder("La Enchilada", "13061043670", 12.5)
// .quantity(1.0)
// .build()
//
// val txAttributes = TransactionAttributes()
// .setRevenue(product.getTotalAmount())
//
// kit.configuration = MockKitConfiguration()
// val customAttributes: MutableMap<String, String> = HashMap()
// customAttributes["currentLocationLongitude"] = "2.1811267"
// customAttributes["country"] = "ES"
// customAttributes["deliveryLocationLatitude"] = "41.4035798"
// customAttributes["appVersion"] = "5.201.0"
// customAttributes["city"] = "BCN"
// customAttributes["deviceId"] = "1104442582"
// customAttributes["platform"] = "android"
// customAttributes["isAuthorized"] = "true"
// customAttributes["productSelectionOrigin"] = "Catalogue"
// customAttributes["currentLocationLatitude"] = "41.4035798"
// customAttributes["collectionId"] = "1180889389"
// customAttributes["multiplatformVersion"] = "1.0.288"
// customAttributes["deliveryLocationTimestamp"] = "1675344636685"
// customAttributes["productId"] = "13061043670"
// customAttributes["storeAddressId"] = "300482"
// customAttributes["currentLocationAccuracy"] = "19.278"
// customAttributes["productAddedOrigin"] = "Item Detail Add to Order"
// customAttributes["deliveryLocationLongitude"] = "2.1811267"
// customAttributes["currentLocationTimestamp"] = "1675344636685"
// customAttributes["dynamicSessionId"] = "67f8fb8d-8d14-4f0e-bf1a-73fb8e6eed95"
// customAttributes["deliveryLocationAccuracy"] = "19.278"
// customAttributes["categoryId"] = "1"
// customAttributes["isSponsored"] = "false"
//
// val commerceEvent: CommerceEvent = CommerceEvent.Builder(Product.ADD_TO_CART, product)
// .currency("EUR")
// .customAttributes(customAttributes)
// .transactionAttributes(txAttributes)
// .build()
// kit.logEvent(commerceEvent)
//
// val braze = Braze
// val events = braze.events
// Assert.assertEquals(1, events.size.toLong())
// val event = events.values.iterator().next()
// Assert.assertNotNull(event.properties)
// val properties = event.properties
//
// Assert.assertEquals(properties.remove("Name"), "La Enchilada")
// Assert.assertEquals(properties.remove("Total Product Amount"), "12.5")
// Assert.assertEquals(properties.remove("Id"), "13061043670")
// for (item in customAttributes) {
// Assert.assertTrue(properties.containsKey(item.key))
// Assert.assertTrue(properties.containsValue(item.value))
// }
// }

// @Test
// fun testEventStringTypeNotEnabled() {
// val kit = MockAppboyKit()
Expand Down