Skip to content

identify method interface vs class type mismatch #531

@509dave16

Description

@509dave16

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions