Skip to content

Conversation

@Mansi-mParticle
Copy link
Collaborator

Instructions

  1. PR target branch should be against development
  2. PR title name should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-title-check.yml
  3. PR branch prefix should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-branch-check-name.yml

Summary

  • Added enum values instead of enum for hash e-commerce event attributes.
  • Added Separate logic for e-commerce event hash

Testing Plan

  • Was this tested locally? If not, explain why.
  • Tested with sample application and executed unit test cases

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

@Mansi-mParticle Mansi-mParticle requested a review from rmi22186 July 18, 2024 17:34
override fun logEvent(event: CommerceEvent): List<ReportingMessage> {
val messages: MutableList<ReportingMessage> = LinkedList()
//For CommerceEvent, Event Name is not required to generate hash. So, it will be always null.
event.products?.get(0)?.customAttributes?.let {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're missing most of what is mappable for a commerce event:

  • event.getTransactionAttributes()
  • event.customAttributes
  • properties of every product object (eg price, quantity) - you're just doing customAttributes of the 1st product here?

and - does ios or web support mapping properties of impressions and promotions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • event.getTransactionAttributes() (adding this changes)
  • event.customAttributes(adding this changes)
  • properties of every product object (eg price, quantity) - you're just doing customAttributes of the 1st product here? missed this by mistake, will move to loop for all the products.

Web doesn't support mapping properties of impressions and promotions; and for IOS I think currently it only supports custom events not commerce events.

https://github.com/mparticle-integrations/mparticle-apple-integration-appboy/blob/[…]cd60edc2751c10129f168d8a/Sources/mParticle-Appboy/MPKitAppboy.m

//For CommerceEvent, Event Name is not required to generate hash. So, it will be always null.
event.products?.forEach {
it.customAttributes?.let {
changeUserArray(it, CommerceEventUtils.getEventType(event), null, true)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we're suppose to map custom attributes of products like this - does the ui even support mapping them? I think you mean to just have event.customAttributes here

}
event.impressions?.forEach { impression ->
impression.products.forEach { product ->
product.customAttributes?.let {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above - have you tested if the UI even populates a custom attributes that's sent into the product within a impression? if so, I doubt the hash here will be right...?

}
event.transactionAttributes?.let {
val map = mapOf(
"Affiliation" to it.affiliation,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be using the constants that are in here: https://github.com/mParticle/mparticle-android-sdk/blob/main/android-kit-base/src/main/java/com/mparticle/kits/CommerceEventUtils.java#L324

and you are missing quite a few constants/mappings - look at every single call to "hashForFiltering()" in these methods - that is a potential constant that you should likely support:

  • filterCommerceEvent
  • filterCommerceEntities
  • filterCommerceEntityAttributes
  • filterCommerceEventAttributes.

I'd encourage you how to think about how to move this logic into that class so that we have complicated business logic close together vs separated. maybe a function in KitConfiguration or in CommerceEventUtils which accepts in a CommerceEvent and returns a map of <hash, value> - and then you can just use that map in the kit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants