braze-inc / braze-web-sdk

Public repo for the Braze Web SDK
https://www.braze.com
Other
70 stars 25 forks source link

[Bug]: User ID is truncated on the colon `:` character #150

Closed bukowskiadam closed 3 months ago

bukowskiadam commented 3 months ago

Braze Web SDK Version

>=5.1.0

Integration Method

NPM

Browser

Chrome

Steps To Reproduce

braze.changeUser(`sdrn:spid.no`);
console.log('User id:', braze.getUser().getUserId());

Expected Behavior

User id: sdrn:spid.no

Actual Incorrect Behavior

User id: sdrn

Verbose Logs

Braze: Initialization Options: {
  "baseUrl": "sdk.fra-01.braze.eu",
  "sessionTimeoutInSeconds": 60,
  "allowUserSuppliedJavascript": true,
  "enableLogging": true
}
Braze: Initialized for the Braze backend at "sdk.fra-01.braze.eu" with API key "...".
Braze: Generating session start event with time 1709900775204. Will expire 1709900835204
Braze: Invoking new session subscriptions
Braze: Changed user to "sdrn:spid.no:user:my_user_id".

My custom log with user_id: sdrn

Additional Information

I tracked down the problem to be in the localstorage format. Previously it was a JSON object like this:

image

In the new version there is this string in the format key:value|anotherKey:anotherValue|... which I believe is the culprit of the issue. See ab.storage.userId.<some uuid> key in localStorage.

spvismaya commented 3 months ago

HI @bukowskiadam, thank you for raising this - we are aware of this issue and are working on a fix asap. We will keep you posted when it's released!

bukowskiadam commented 3 months ago

Thanks for the information! It would be great if you could keep the list of known issues public, because it saves people time, like two hours for me, debugging, shuffling SDK versions, verifying when it works, and creating this bug report 😬 Thank you πŸ™‡πŸ»

spvismaya commented 3 months ago

Thank you for your feedback @bukowskiadam ! Sorry for the trouble you had to go through. We just released SDK v5.2.0 which fixes this issue. Thank you!