
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
react-use-hotjar
Advanced tools
Adds Hotjar capabilities as custom hooks to your project
npm install --save react-use-hotjar
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);
}, [initHotjar]);
return <App />;
};
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);
};
};
useHotjar()
returns:
key | description | arguments | example |
---|---|---|---|
initHotjar | Initialize method | (hotjarId: number, hotjarVersion: number, loggerCallback?: console[method]) | (1933331, 6, console.info) |
identifyHotjar | User identify API method | (userId: string, userInfo: json object, loggerCallback?: console[method]) | ('abcde-12345-12345', JSON.stringify({name:"Olli",surname:"Parno",address:"Streets of Tomorrow"}), console.log) |
hotjarId
: Your Hotjar application ID ex.: 1933331hotjarVersion
: Hotjar's current version ex.: 6logCallback
: Optional callback for logging wether Hotjar is ready or notinitHotjar: (
hotjarId: string,
hotjarVersion: string,
logCallback?: () => void
) => boolean;
userId
: Unique user's identification as stringuserInfo
: 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.)logCallback
: Optional callback for logging wether Hotjar identified user or notidentifyHotjar: (userId: string, userInfo: string, logCallback?: () => void) =>
boolean;
Thanks goes to these wonderful people (emoji key):
Olavo Parno 🤔 💻 ⚠️ | Gianpietro Lavado 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!
react-use-hotjar is MIT licensed.
This hook is created using create-react-hook.
FAQs
Adds Hotjar capabilities as custom hooks
We found that react-use-hotjar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.