npm.io
1.1.0 • Published 3 years ago

fullstory-register-user

Licence
Version
1.1.0
Deps
2
Size
30 kB
Vulns
0
Weekly
0

Contents

Fullstory-Register-User

This React component is for registering the user to Fullstory with their name and email. Passing additional parameters is optional.

Issue And Solution

When the user signs in the first time to an app, Fullstory would log an anonymous user because of the redirect needed for signing in the user. This component eliminates the anonymous user being logged because it waits for the user to be authenticated before registering Fullstory and passing it the user.

How to use

npm i fullstory-register-user
import { Auth0Provider, User, useAuth0 } from "@auth0/auth0-react";
import { RegisterUser } from 'fullstory-register-user';

const AuthenticatedRoutes = () => {
  const { isLoading, isAuthenticated, user, loginWithRedirect, error } = useAuth0();

  if ( isLoading ) {
    return <div >loading...</div>;
  }
  if ( error ) {
    return <div>Oops... { error.message }</div>;
  }
  if ( isAuthenticated ) {
    return (
        <>
            <RegisterUser user={ user } org={ "YOUR FULLSTORY ID" } />
            <Switch>
                <Route exact path="/" render={()=> <PrivateComponent />}/>
                <Route exact path="/other" render={()=> <OtherComponent />}/>
            </Switch>
        </>
    );
  } else {
    loginWithRedirect();
    return null;
  }
};

Passing Options

Options Default Required Result
user null true The user to be registered with Fullstory
org null true Registers Fullstory
env null false Specifies what NODE_ENV to register Fullstory. If no env is specified then all NODE_ENV are registered.

User

The user object is what is passed to Fullstory Identify. The user must have an id, name and email in order to register that user to Fullstory. any additonal parameters are optional.

Options Default Required Result
id null true uid is a string containing a unique identifier for the current user
name null true Name of user
email null true Email of user

Additional Info

  • All React dependencies for Fullstory-Register-User are dependent on the application using the component. This is to avoid any version dependency conflicts.
  • The Fullstory dependency uses "react-fullstory": "^1.4.0" for registering the user.