Skip to content
32 changes: 30 additions & 2 deletions src/main/kotlin/com/mparticle/kits/RoktKit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.content.pm.PackageManager
import android.graphics.Typeface
import android.os.Build
import com.mparticle.BuildConfig
import com.mparticle.MParticle
import com.mparticle.MParticle.IdentityType
import com.mparticle.MpRoktEventCallback
import com.mparticle.UnloadReasons
Expand Down Expand Up @@ -188,7 +189,7 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
}?.toMap()

this.mpRoktEventCallback = mpRoktEventCallback
val finalAttributes: HashMap<String, String> = HashMap<String, String>()
val finalAttributes = mutableMapOf<String, String>()
filterUser?.userAttributes?.let { userAttrs ->
for ((key, value) in userAttrs) {
finalAttributes[key] = value.toString()
Expand All @@ -199,13 +200,14 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
finalAttributes[MPID] = mpid
} ?: Logger.warning("RoktKit: No user ID available for placement")

addIdentityAttributes(finalAttributes, filterUser)
//addIdentityAttributes(finalAttributes, filterUser)
Comment thread
Mansi-mParticle marked this conversation as resolved.
Outdated


val SANDBOX_MODE_ROKT: String = "sandbox"
attributes?.get(SANDBOX_MODE_ROKT)?.let { value ->
finalAttributes.put(SANDBOX_MODE_ROKT, value)
}
verifyHashedEmail(finalAttributes)
val roktConfig = mpRoktConfig?.let { mapToRoktConfig(it) }
Rokt.execute(
viewName,
Expand Down Expand Up @@ -318,6 +320,32 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
}
}

private fun verifyHashedEmail(attributes: MutableMap<String, String>?) {
if (attributes == null) return

val emailKey = "Email"
val otherKey = "Other"
Comment thread
Mansi-mParticle marked this conversation as resolved.
Outdated
val emailShaKey = "emailsha256"

val emailSha = attributes[emailShaKey]
val otherValue = attributes[otherKey]

when {
!emailSha.isNullOrEmpty() -> {
attributes.remove(emailKey)
attributes.remove(otherKey)
}

!otherValue.isNullOrEmpty() -> {
Comment thread
Mansi-mParticle marked this conversation as resolved.
Outdated
attributes.remove(emailKey)
attributes[emailShaKey] = otherValue
attributes.remove(otherKey)
}

// else do nothing
}
}

private fun getStringForIdentity(identityType: IdentityType): String {
return when (identityType) {
IdentityType.Other -> "other"
Expand Down
Loading