croct.identify throws Invalid user ID when passing our numeric customer ID
Working on an ecommerce site in Tokyo, @croct/plug 0.16 on the storefront.
On login we call croct.identify(user.id) where id comes from our backend as a number. The SDK throws "Invalid user ID" every time. The ID itself is valid, it is the same value our whole platform keys on.
Secondary question while I am here: I set a custom attribute with croct.user.edit().set('custom.tier', 'gold').save() but an audience with user's custom.tier is "gold" never matches, is that related?
1 answer
Two separate quirks, both easy fixes.
croct.identify accepts strings only, so a numeric ID is rejected regardless of the value. Convert it at the call site:
croct.identify(String(user.id));While you are in that code, note that the userId and token plug options are mutually exclusive, in case you ever move identification to init time.
The custom attribute issue is not related, it is its own documented quirk: custom attributes are written with the custom. prefix but queried without it in CQL. Your write call is correct, the query should be:
user's tier is "gold"Drop the custom. from the audience condition and it will match.
Confirmed, both fixed. The prefix asymmetry is surprising but at least it is consistent. Thank you.