@@ -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"
0 commit comments