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

react-use-hotjar

Package Overview
Dependencies
Maintainers
1
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.0.10
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source
traffic

react-use-hotjar

Adds Hotjar capabilities as custom hooks to your project

NPM


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, myCustomLogger);
  });

  return <App />;
};
  • Identifying Users (Use it wherever user's information is available. Send stringified preferably so that error handling is at this level.)
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;
    const informationStringified = JSON.stringify(restUserInfo);

    identifyHotjar(
      id,
      informationStringified
    );
  };
};

Documentation

useHotjar() returns:

  • initHotjar()
  1. hotjarId: Your Hotjar application ID ex.: 1933331
  2. hotjarVersion: Hotjar's current version ex.: 6
  3. logCallback: Optional callback for logging wether Hotjar is ready or not
initHotjar: (
  hotjarId: string,
  hotjarVersion: string,
  logCallback?: () => void
) => boolean;
  • identifyHotjar()
  1. userId: Unique user's identification as string
  2. userInfo: Stringfied 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 wether Hotjar identified user or not
identifyHotjar: (
  userId: string,
  userInfo: string,
  logCallback?: () => void
) => boolean;

License

react-use-hotjar is MIT licensed.


This hook is created using create-react-hook.

FAQs

Package last updated on 23 Feb 2021

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