Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-use-hotjar

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use-hotjar

Adds Hotjar capabilities as custom hooks

  • 1.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
decreased by-59.45%
Maintainers
2
Weekly downloads
 
Created
Source
traffic

react-use-hotjar

Adds Hotjar capabilities as custom hooks to your project

NPM


StatementsBranchesFunctionsLines
StatementsBranchesFunctionsLines

Table of Contents


Install

npm install --save react-use-hotjar

Usage

  • Initializing Hotjar (use it at the very top of your application)
import * as React from 'react';
import useHotjar from 'react-use-hotjar';

const myCustomLogger = console.info;

const HotjarReadyApp = () => {
  const { initHotjar } = useHotjar();

  React.useEffect(() => {
    initHotjar(1234567, 6, false, myCustomLogger);
  }, [initHotjar]);

  return <App />;
};
  • Identifying Users (Use it wherever user's information is available. Send and object respecting Identify API's rules)
import * as React from 'react';
import useHotjar from 'react-use-hotjar';

const myCustomLogger = console.log;

const MyCustomComponent = () => {
  const { identifyHotjar } = useHotjar();

  const handleUserInfo = (userInfo) => {
    const { id, ...restUserInfo } = userInfo;

    identifyHotjar(id, restUserInfo, myCustomLogger);
  };
};

Examples


Documentation

useHotjar() returns:

  • An object with the following keys:
keydescriptionargumentsexample
readyStateStates if Hotjar is readyN/AN/A
initHotjarInitialize method(hotjarId: number, hotjarVersion: number, hotjarDebug?: boolean, loggerCallback?: console[method])(1933331, 6, false, console.info)
identifyHotjarUser identify API method(userId: string, userInfo: object, loggerCallback?: console[method])('abcde-12345-12345', {name:"Olli",surname:"Parno",address:"Streets of Tomorrow"}, console.log)
stateChangeRelative path state change(relativePath: string, loggerCallback?: console[method])('route/logged-route/user?registered=true')
tagRecordingTag a recording(tags: string[], loggerCallback?: console[method])(['tag1', 'tag2'])
  • initHotjar()
  1. hotjarId: Your Hotjar application ID ex.: 1933331
  2. hotjarVersion: Hotjar's current version ex.: 6
  3. hotjarDebug: Optional Debug Mode to see hotjar logs in console ex.: true
  4. logCallback: Optional callback for logging whether Hotjar is ready or not
initHotjar: (
  hotjarId: string,
  hotjarVersion: string,
  hotjarDebug?: boolean,
  logCallback?: () => void
) => boolean;
  • identifyHotjar()
  1. userId: Unique user's identification as string
  2. userInfo: User info of key-value pairs (note this must not be so long and deep according to docs) (Please note: The Identify API is only available to Business plan customers.)
  3. logCallback: Optional callback for logging whether Hotjar identified user or not
identifyHotjar: (userId: string, userInfo: object, logCallback?: () => void) =>
  boolean;
  • stateChange()
  1. relativePath: A change in a route specially for SPAs usage. stateChange docs
  2. logCallback: Optional callback for logging whether Hotjar stateChange was called or not
stateChange: (relativePath: string, logCallback?: () => void) => boolean;
  • tagRecording()
  1. tags: List of strings to associate with a recording that can be used for filtering
  2. logCallback: Optional callback for logging whether Hotjar tagRecording was called or not
tagRecording: (tags: string[], logCallback?: () => void) => boolean;

Contributors

Thanks goes to these wonderful people (emoji key):

Olavo Parno
Olavo Parno

🤔 💻 ⚠️
Gianpietro Lavado
Gianpietro Lavado

📖
Ivan Kleshnin
Ivan Kleshnin

💻 🤔
Ajay Varghese
Ajay Varghese

💻 🤔
honicole
honicole

🔧 💻 🤔 📖
Georg Bakken Idland
Georg Bakken Idland

📖 🤔
Jason Papakostas
Jason Papakostas

🐛
Luighi Viton-Zorrilla
Luighi Viton-Zorrilla

🐛 🚧
Quentin Luc
Quentin Luc

💻

This project follows the all-contributors specification. Contributions of any kind welcome!


License

react-use-hotjar is MIT licensed.


This hook is created using create-react-hook.

FAQs

Package last updated on 16 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc