[Streamlabs] Unexpected "amount" format on Youtube Superchat
iGoodie opened this issue ยท 2 comments
Describe the bug
Streamlabs Socket API sends Youtube Superchat event with the amount multiplied with 1_000_000 (?)
To Reproduce
- Replay a Youtube Superchat event on Streamlabs Dashboard
- Check
messages
array and findamount
field - The value seems to be multiplied with 1_000_000
Expected behavior
The donation value in human-readable format, just like on other events.
Version (please complete the following information):
- OS: Windows
- TwitchSpawn Version: v1.2.5
- Forge Version: -
Additional context
This is an inconsistency (?) that can only be fixed by Streamlabs Socket API developers. Contact them and report this inconsistency.
This is actually a localization problem. Let me expand:
The amount field probably mapped to a decimal field which happens to be defaulted by various dbms as decimal(19,6) which means 19 figures before decimal point, 6 figures after. So your 2$ value is recorded as "0000000000000000002.0000000" to the DB.
We, the people in Turkiye, represent money values as "." as thousands seperator and "," as decimal seperator, but most of the world is the other way around, "." as decimal point and "," as thousands seperator. So that generates a confusion and requires serious attention by programmers. Why?
If you write code to "." being decimal point and have "2$" stored "2.000000" respectively and host in Turkiye, then what you get back is "2.000.000".
Notify them to check their "string to decimal" and "decimal to string" conversions to be based upon "Invariant Culture".
Thanks for that beautifully written explanation @hasanmanzak! ๐
Precision and localization concerns seem to be the cause of that as you mentioned.
However at this point I'm not sure if that is an inconsistency or I should just handle that in the client side. It would be pretty fun if I handled that internally, and then suddenly the way Streamlabs represent that value was changed.
Anyways currently the TSL matching a $2.00
Youtube Superchat looks like so:
...
ON Youtube Superchat
WITH amount = 2000000
The amount looks confusing to the user, because it is way different than the other TSL Predicates.
And I believe I will resolve this issue by parsing displayString
instead in the next TwitchSpawnLanguage implementation, until I hear from Streamlabs' Support Team