braze-inc / braze-swift-sdk

https://www.braze.com
Other
48 stars 19 forks source link

[Bug]: The custom attribute with `$` symbol in the very beginning of the name (key) is being ignored #102

Closed sergiisukhanov closed 5 months ago

sergiisukhanov commented 5 months ago

Platform

iOS

Platform Version

iOS 15.5

Braze SDK Version

The latest one (from master branch)

Xcode Version

Xcode 15.1

Computer Processor

Apple (M1)

Repro Rate

100%

Steps To Reproduce

  1. Add brazeUser?.setCustomAttribute(key: "$my_attribute", value: true) to the Example application right after brazeUser?.setCustomAttribute(key: "last_login_date", value: Date()) line.
  2. Run the app.
  3. Autheticate user.
  4. Observe the request body in the logs.

Expected Behavior

Having the $my_attribute field with value in the request body:

  "attributes" : [
    {
      "custom" : {
        "last_login_date" : ,
        "$my_attribute" : 
      },

    }
  ]

Actual Incorrect Behavior

Absence of the $my_attribute field with value in the request body:

  "attributes" : [
    {
      "custom" : {
        "last_login_date" : 
      },

    }
  ]

Verbose Logs

[braze] The value starts with an invalid prefix.
- value: $my_attribute
- invalid prefix: $
- location: Analytics/AuthenticationManager.swift:18
- function: setCustomAttribute(key:value:fileID:line:)
- parameter: key

Additional Information

It's only iOS issue, Android folks were able to set the custom attribute with $ in the name.

Ro-M commented 5 months ago

It's worth it to mention that the same attribute can be added through the braze android SDK without any problem.

hokstuff commented 5 months ago

Hi @sergiisukhanov @Ro-M,

Thanks for filing this issue! We have identified a fix and are planning to include it into our upcoming release very soon.

jerielng commented 5 months ago

Hey @sergiisukhanov @Ro-M, this fix should be out with our 7.6.0 release! I'll close out this issue, but feel free to open a new one if you have other questions or concerns. Thank you!