Skip to content

Commit 31c15fa

Browse files
fix:Revert 4335 (#127)
1 parent d0133de commit 31c15fa

File tree

2 files changed

+5
-30
lines changed

2 files changed

+5
-30
lines changed

src/main/kotlin/com/mparticle/kits/AppboyKit.kt

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,
4646
private val dataFlushHandler = Handler()
4747
private var dataFlushRunnable: Runnable? = null
4848
private var forwardScreenViews = false
49-
private var bundleNonPurchaseCommerceEvents = false
5049
private lateinit var updatedInstanceId: String
5150

5251

@@ -74,7 +73,6 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,
7473
}
7574
}
7675
forwardScreenViews = settings[FORWARD_SCREEN_VIEWS].toBoolean()
77-
bundleNonPurchaseCommerceEvents = settings[BUNDLE_NON_PURCHASE_COMMERCE_EVENTS].toBoolean()
7876
if (key != null) {
7977
val config = BrazeConfig.Builder().setApiKey(key)
8078
.setSdkFlavor(SdkFlavor.MPARTICLE)
@@ -213,33 +211,12 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,
213211
}
214212
val eventList = CommerceEventUtils.expand(event)
215213
if (eventList != null) {
216-
if (!bundleNonPurchaseCommerceEvents) {
217-
eventList.forEachIndexed { index, _ ->
218-
try {
219-
logEvent(eventList[index])
220-
messages.add(ReportingMessage.fromEvent(this, event))
221-
} catch (e: Exception) {
222-
Logger.warning("Failed to call logCustomEvent to Braze kit: $e")
223-
}
224-
}
225-
} else {
226-
val productArray = JSONArray()
227-
eventList.forEachIndexed { index, _ ->
228-
val newAttributes = eventList[index].customAttributes ?: HashMap()
229-
newAttributes["custom attributes"] = event.customAttributes
230-
productArray.put(newAttributes)
231-
}
214+
for (i in eventList.indices) {
232215
try {
233-
val json = JSONObject().put("products", productArray)
234-
val transactionAttributes = event.transactionAttributes
235-
transactionAttributes?.let {
236-
json.put("Transaction ID", transactionAttributes.id)
237-
}
238-
val brazeProperties = BrazeProperties(json)
239-
Braze.getInstance(context).logCustomEvent(eventList[0].eventName, brazeProperties)
216+
logEvent(eventList[i])
240217
messages.add(ReportingMessage.fromEvent(this, event))
241-
} catch (jse: JSONException) {
242-
Logger.warning("Failed to call logCustomEvent to Braze kit: $jse")
218+
} catch (e: Exception) {
219+
Logger.warning("Failed to call logCustomEvent to Appboy kit: $e")
243220
}
244221
}
245222
queueDataFlush()
@@ -421,7 +398,6 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,
421398
}
422399
}
423400
CommerceEventUtils.extractActionAttributes(event, onAttributeExtracted)
424-
purchaseProperties.addProperty("custom_attributes", event?.customAttributes ?: "")
425401
var currencyValue = currency[0]
426402
if (KitUtils.isEmpty(currencyValue)) {
427403
currencyValue = CommerceEventUtils.Constants.DEFAULT_CURRENCY_CODE
@@ -684,7 +660,6 @@ open class AppboyKit : KitIntegration(), AttributeListener, CommerceListener,
684660
companion object {
685661
const val APPBOY_KEY = "apiKey"
686662
const val FORWARD_SCREEN_VIEWS = "forwardScreenViews"
687-
const val BUNDLE_NON_PURCHASE_COMMERCE_EVENTS = "bundleNonPurchaseCommerceEvents"
688663
const val USER_IDENTIFICATION_TYPE = "userIdentificationType"
689664
const val ENABLE_TYPE_DETECTION = "enableTypeDetection"
690665
const val HOST = "host"

src/test/kotlin/com/mparticle/kits/AppboyKitTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ class AppboyKitTests {
446446
properties.remove(CommerceEventUtils.Constants.ATT_AFFILIATION),
447447
"the affiliation"
448448
)
449-
Assert.assertEquals(1, properties.size.toLong())
449+
Assert.assertEquals(0, properties.size.toLong())
450450
}
451451

452452
@Test

0 commit comments

Comments
 (0)