Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
react-use-hotjar
Advanced tools
Adds Hotjar capabilities as custom hooks to your project
Statements | Branches | Functions | Lines |
---|---|---|---|
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;
identifyHotjar(id, restUserInfo, myCustomLogger);
};
};
useHotjar()
returns:
key | description | arguments | example |
---|---|---|---|
readyState | States if Hotjar is ready | N/A | N/A |
initHotjar | Initialize method | (hotjarId: number, hotjarVersion: number, loggerCallback?: console[method]) | (1933331, 6, console.info) |
identifyHotjar | User identify API method | (userId: string, userInfo: object, loggerCallback?: console[method]) | ('abcde-12345-12345', {name:"Olli",surname:"Parno",address:"Streets of Tomorrow"}, console.log) |
stateChange | Relative path state change | (relativePath: string, loggerCallback?: console[method]) | ('route/logged-route/user?registered=true') |
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
: 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: object, logCallback?: () => void) =>
boolean;
relativePath
: A change in a route specially for SPAs usage. stateChange docslogCallback
: Optional callback for logging wether Hotjar stateChange was called or notstateChange: (relativePath: string, logCallback?: () => void) => boolean;
Thanks goes to these wonderful people (emoji key):
Olavo Parno 🤔 💻 ⚠️ | Gianpietro Lavado 📖 | Ivan Kleshnin 💻 🤔 |
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
The npm package react-use-hotjar receives a total of 2,468 weekly downloads. As such, react-use-hotjar popularity was classified as popular.
We found that react-use-hotjar demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.