statsig-io / node-js-server-sdk

Statsig's SDK for server-side Node.js applications.
ISC License
20 stars 15 forks source link

fix(typing): userID is required on StatsigUser #18

Closed cajubelt closed 1 year ago

cajubelt commented 1 year ago

If you do not supply a userID getting a dynamic config, you get a runtime error. This should be reflected in the StatsigUser type to enable static type checks for when userID is set to something that might be null or undefined.

This type is also listed as having userID required in the docs

jkw-statsig commented 1 year ago

Hi @cajubelt - thanks for the PR. The userID is indeed optional though, but only when one or more customIDs are provided, reason being sometimes you don't have a userID, but do have other IDs like deviceID and etc. The error message and logic is here. We will fix up the docs though, thanks!