Discussions

Ask a Question
Back to All

Purchasely.setUserAttributes() with array (v5.0.2)

Hello,

We recently updated to the latest version of your Android SDK (5.0.2). With the 5.0.0, it is now possible to send a string array into user attributes, even if the documentation section seems outdated, we did the following:

val data = mutableMapOf<String, Any>(
  "a" to "a1", // simple string
  "b" to listOf("b1", "b2") // list of strings
)
Purchasely.setUserAttributes(data)

After we created the custom attributes into our console, the second attribute b is never received on Purchasely's end. Our audience based on b is never successful, and the logs from the SDK shows all the other attributes (as a in our example, but never b).

We also tried to convert our list into an array of string as following and still failed:

val data = mutableMapOf<String, Any>(
  "a" to "a1", // simple string
  "b" to listOf("b1", "b2") // list of strings
)
data["b"] = data[b].toTypedArray() // convert to array
Purchasely.setUserAttributes(data)

However, setting the array individually or creating a loop to iterate through the values seems to work:

val data = mutableMapOf<String, Any>(
  "a" to "a1", // simple string
  "b" to listOf("b1", "b2") // list of strings
)
(data["b"] as? List<String>)?.forEach { // iterate to send each value
  Purchasely.setUserAttribute("b", it)
}

// 
Purchasely.setUserAttribute(listOf("b1", "b2").toTypedArray()) // send the array individually

Could you tell us why this is not working with the function setUserAttributes please?
Thanks in advance.

Best Regards,
Florent