File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 11# react-use-hotjar
22
3- > Add [ Hotjar] ( https://www.hotjar.com/ ) capabilities as custom hooks to your project
3+ > Adds [ Hotjar] ( https://www.hotjar.com/ ) capabilities as custom hooks to your project
44
55[ ![ NPM] ( https://img.shields.io/npm/v/react-use-hotjar.svg )] ( https://www.npmjs.com/package/react-use-hotjar )
66
@@ -25,7 +25,7 @@ npm install --save react-use-hotjar
2525
2626## Usage
2727
28- - Initializing Hotjar
28+ - Initializing Hotjar (use it at your very ` index.jsx ` )
2929
3030``` tsx
3131import * as React from ' react' ;
@@ -45,7 +45,7 @@ const HotjarReadyApp = () => {
4545};
4646```
4747
48- - Identifying Users
48+ - Identifying Users (use it wherever you get access to user's information)
4949
5050``` tsx
5151const MyCustomComponent = () => {
@@ -54,7 +54,7 @@ const MyCustomComponent = () => {
5454 const handleUserInfo = (userInfo ) => {
5555 const { id, ... restUserInfo } = userInfo ;
5656
57- identityHotjar (
57+ identifyHotjar (
5858 id ,
5959 JSON .stringify ({
6060 restUserInfo ,
@@ -84,14 +84,14 @@ initHotjar: (
8484) => boolean ;
8585```
8686
87- - identityHotjar ()
87+ - identifyHotjar ()
8888
89891 . ` userId ` : Unique user's identification as string
90902 . ` userInfo ` : Stringfied user info of key-value pairs (note this must not be so long and deep according to [ docs] ( https://help.hotjar.com/hc/en-us/articles/360033640653-Identify-API-Reference ) )
91913 . ` logCallback ` : Optional callback for logging wether Hotjar identified user or not
9292
9393``` tsx
94- identityHotjar : (userId : string , userInfo : string , logCallback ? : () => void ) =>
94+ identifyHotjar : (userId : string , userInfo : string , logCallback ? : () => void ) =>
9595 boolean ;
9696```
9797
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ type TUseHotjar = {
77 hotjarVersion : string ,
88 logCallback ?: ( ) => void
99 ) => boolean ;
10- identityHotjar : (
10+ identifyHotjar : (
1111 userId : string ,
1212 userInfo : string ,
1313 logCallback ?: ( ) => void
@@ -30,13 +30,13 @@ export function useHotjar(): TUseHotjar {
3030 [ appendHeadScript ]
3131 ) ;
3232
33- const identityHotjar = React . useCallback (
33+ const identifyHotjar = React . useCallback (
3434 ( userId : string , userInfo : string , loggerFunction ) : boolean => {
3535 try {
36- const hotjarIdentityScript = `var userId="${ userId } " || null;window.hj("identify",userId,${ userInfo } );` ;
36+ const hotjarIdentifyScript = `var userId="${ userId } " || null;window.hj("identify",userId,${ userInfo } );` ;
3737 const isIdentified = appendHeadScript (
38- hotjarIdentityScript ,
39- 'identity -script'
38+ hotjarIdentifyScript ,
39+ 'identify -script'
4040 ) ;
4141
4242 if ( loggerFunction && typeof loggerFunction === 'function' )
@@ -52,8 +52,8 @@ export function useHotjar(): TUseHotjar {
5252 [ appendHeadScript ]
5353 ) ;
5454
55- return React . useMemo ( ( ) => ( { initHotjar, identityHotjar } ) , [
55+ return React . useMemo ( ( ) => ( { initHotjar, identifyHotjar } ) , [
5656 initHotjar ,
57- identityHotjar ,
57+ identifyHotjar ,
5858 ] ) ;
5959}
You can’t perform that action at this time.
0 commit comments