The Segment Spec: Identify docs mention that if using an anonymousId you can call identify without specifying a userId (i.e. it can be undefined).
But in the NPM package, there's a conflict between ClientMethods interface and the SegmentClient class:
ClientMethods interface does not allow for userId argument to be undefined (i.e. it's required):
|
identify: (userId: string, userTraits?: UserTraits) => void; |
SegmentClient class does allow for
userId argument to be undefined (i.e. it's optional):
|
identify(userId?: string, userTraits?: UserTraits) { |
TLDR; Cannot make identify calls for anonymous users when leveraging the useAnalytics hook. This is a blocker for customers that want to identify traits for anonymous users while at the same time leveraging the useAnalytics hook.
analytics-react-native version: 2.1.12
- Integrations versions (if used): N/A
- React Native version: 0.66.4
- iOS or Android or both? Both
Steps to reproduce
Attempt to use identify method on client returned from createClient module export when surfaced via the useAnalytics React hook.
Expected behavior
userId argument should be optional for identify method of ClientMethods interface such that undefined could be passed to allow for updating traits of anonymous users when leveraging the useAnalytics hook.
Actual behavior
userId argument is required for identify method of ClientMethods return value of useAnalytics hook.
The Segment Spec: Identify docs mention that if using an
anonymousIdyou can call identify without specifying a userId (i.e. it can beundefined).But in the NPM package, there's a conflict between
ClientMethodsinterface and theSegmentClientclass:ClientMethodsinterface does not allow foruserIdargument to beundefined(i.e. it's required):analytics-react-native/packages/core/src/types.ts
Line 131 in d48b7f9
SegmentClientclass does allow foruserIdargument to be undefined (i.e. it's optional):analytics-react-native/packages/core/src/analytics.ts
Line 495 in d48b7f9
TLDR; Cannot make
identifycalls for anonymous users when leveraging theuseAnalyticshook. This is a blocker for customers that want to identify traits for anonymous users while at the same time leveraging theuseAnalyticshook.analytics-react-nativeversion: 2.1.12Steps to reproduce
Attempt to use
identifymethod on client returned fromcreateClientmodule export when surfaced via theuseAnalyticsReact hook.Expected behavior
userIdargument should be optional foridentifymethod ofClientMethodsinterface such thatundefinedcould be passed to allow for updating traits of anonymous users when leveraging theuseAnalyticshook.Actual behavior
userIdargument is required foridentifymethod ofClientMethodsreturn value ofuseAnalyticshook.