You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

react-use-hotjar

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use-hotjar - npm Package Compare versions

Comparing version

to
1.0.10

@@ -5,2 +5,4 @@ # Changelog

### [1.0.10](https://github.com/olavoparno/react-use-hotjar/compare/v1.0.9...v1.0.10) (2021-02-23)
### [1.0.9](https://github.com/olavoparno/react-use-hotjar/compare/v1.0.8...v1.0.9) (2021-02-21)

@@ -7,0 +9,0 @@

declare type TUseHotjar = {
initHotjar: (hotjarId: string, hotjarVersion: string, logCallback?: () => void) => boolean;
identifyHotjar: (userId: string, userInfo: string, logCallback?: () => void) => boolean;
identifyHotjar: (userId: string, userInfo: string | unknown, logCallback?: () => void) => boolean;
};
export declare function useHotjar(): TUseHotjar;
export {};
export default useHotjar;

@@ -1,1 +0,1 @@

import{useCallback as t,useMemo as r}from"react";function n(){var n=function(){var n=t((function(t,r){try{var n=document.getElementById(r)||document.createElement("script");return n.id=r,n.innerText=t,n.crossOrigin="anonymous",document.head.appendChild(n),!0}catch(t){return!1}}),[]);return r((function(){return{appendHeadScript:n}}),[n])}().appendHeadScript,e=t((function(t,r,e){var i=n("(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:"+t+",hjsv:"+r+"};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;a.appendChild(r);})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');","hotjar-script");return e&&"function"==typeof e&&e("Hotjar ready: "+i),i}),[n]),i=t((function(t,r,e){try{var i=n('var userId="'+t+'" || null;window.hj("identify",userId,'+r+");","identify-script");return e&&"function"==typeof e&&e("Hotjar identified: "+i),i}catch(t){return console.error("Hotjar error:",t),!1}}),[n]);return r((function(){return{initHotjar:e,identifyHotjar:i}}),[e,i])}export{n as useHotjar};
import{useMemo as t,useCallback as r}from"react";function n(){var n=function(){var n=r((function(t,r){try{var n=document.getElementById(r)||document.createElement("script");return n.id=r,n.innerText=t,n.crossOrigin="anonymous",document.head.appendChild(n),!0}catch(t){return!1}}),[]);return t((function(){return{appendHeadScript:n}}),[n])}().appendHeadScript,e=r((function(t,r,e){var i=n("(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:"+t+",hjsv:"+r+"};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;a.appendChild(r);})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');","hotjar-init-script");return e&&"function"==typeof e&&e("Hotjar ready: "+i),i}),[n]),i=r((function(t,r,e){try{var i="string"!=typeof r?JSON.stringify(r):r,o=n('var userId="'+t+'" || null;window.hj("identify",userId,'+i+");","hotjar-identify-script");return e&&"function"==typeof e&&e("Hotjar identified: "+o),o}catch(t){return console.error("Hotjar error:",t),!1}}),[n]);return t((function(){return{initHotjar:e,identifyHotjar:i}}),[e,i])}export default n;export{n as useHotjar};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");exports.useHotjar=function(){var e=function(){var e=t.useCallback((function(t,e){try{var r=document.getElementById(e)||document.createElement("script");return r.id=e,r.innerText=t,r.crossOrigin="anonymous",document.head.appendChild(r),!0}catch(t){return!1}}),[]);return t.useMemo((function(){return{appendHeadScript:e}}),[e])}().appendHeadScript,r=t.useCallback((function(t,r,n){var a=e("(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:"+t+",hjsv:"+r+"};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;a.appendChild(r);})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');","hotjar-script");return n&&"function"==typeof n&&n("Hotjar ready: "+a),a}),[e]),n=t.useCallback((function(t,r,n){try{var a=e('var userId="'+t+'" || null;window.hj("identify",userId,'+r+");","identify-script");return n&&"function"==typeof n&&n("Hotjar identified: "+a),a}catch(t){return console.error("Hotjar error:",t),!1}}),[e]);return t.useMemo((function(){return{initHotjar:r,identifyHotjar:n}}),[r,n])};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");function e(){var e=function(){var e=t.useCallback((function(t,e){try{var r=document.getElementById(e)||document.createElement("script");return r.id=e,r.innerText=t,r.crossOrigin="anonymous",document.head.appendChild(r),!0}catch(t){return!1}}),[]);return t.useMemo((function(){return{appendHeadScript:e}}),[e])}().appendHeadScript,r=t.useCallback((function(t,r,n){var i=e("(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:"+t+",hjsv:"+r+"};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;a.appendChild(r);})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');","hotjar-init-script");return n&&"function"==typeof n&&n("Hotjar ready: "+i),i}),[e]),n=t.useCallback((function(t,r,n){try{var i="string"!=typeof r?JSON.stringify(r):r,a=e('var userId="'+t+'" || null;window.hj("identify",userId,'+i+");","hotjar-identify-script");return n&&"function"==typeof n&&n("Hotjar identified: "+a),a}catch(t){return console.error("Hotjar error:",t),!1}}),[e]);return t.useMemo((function(){return{initHotjar:r,identifyHotjar:n}}),[r,n])}exports.default=e,exports.useHotjar=e;
{
"name": "react-use-hotjar",
"version": "1.0.9",
"description": "Add Hotjar capabilities as custom hooks",
"version": "1.0.10",
"description": "Adds Hotjar capabilities as custom hooks",
"author": "Olavo Parno",

@@ -43,34 +43,34 @@ "license": "MIT",

"peerDependencies": {
"react": "^16.13.1"
"react": "^17.0.1"
},
"devDependencies": {
"@babel/core": "^7.11.1",
"@babel/runtime": "^7.11.2",
"@types/jest": "^26.0.9",
"@types/react": "^16.9.46",
"@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/parser": "^3.9.0",
"eslint": "^7.6.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-airbnb-typescript-prettier": "^3.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.0.8",
"husky": "^4.2.5",
"prettier": "^2.0.5",
"react": "^16.13.1",
"react-scripts": "^3.4.1",
"rollup": "^2.23.1",
"@babel/core": "^7.13.1",
"@babel/runtime": "^7.13.1",
"@types/jest": "^26.0.20",
"@types/react": "^17.0.2",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"@typescript-eslint/parser": "^4.15.2",
"eslint": "^7.20.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb-typescript-prettier": "^4.1.0",
"eslint-config-prettier": "^8.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^5.1.1",
"prettier": "^2.2.1",
"react": "^17.0.1",
"react-scripts": "^4.0.3",
"rollup": "^2.39.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-peer-deps-external": "^2.2.3",
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-typescript2": "^0.27.2",
"standard-version": "^8.0.2",
"typescript": "^3.9.7"
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"standard-version": "^9.1.1",
"typescript": "^4.1.5"
}
}

@@ -30,9 +30,8 @@ <img align="right" alt="traffic" src="https://pv-badge.herokuapp.com/total.svg?repo_id=olavoparno-react-use-hotjar"/>

- Initializing Hotjar (use it at your very `index.jsx`)
- Initializing Hotjar (use it at the very top of your application)
```tsx
import * as React from 'react';
import useHotjar from 'react-use-hotjar';
import { useHotjar } from 'react-use-hotjar';
const myCustomLogger = console.info;

@@ -44,3 +43,3 @@

React.useEffect(() => {
initHotjar(hotjarId, hotjarVersion, myCustomLogger);
initHotjar(1234567, 6, myCustomLogger);
});

@@ -52,16 +51,20 @@

- Identifying Users (use it wherever you get access to user's information)
- Identifying Users (Use it wherever user's information is available. Send __stringified__ preferably so that error handling is at this level.)
```tsx
import * as React from 'react';
import useHotjar from 'react-use-hotjar';
const myCustomLogger = console.log;
const MyCustomComponent = () => {
const { initHotjar } = useHotjar();
const { identifyHotjar } = useHotjar();
const handleUserInfo = (userInfo) => {
const { id, ...restUserInfo } = userInfo;
const informationStringified = JSON.stringify(restUserInfo);
identifyHotjar(
id,
JSON.stringify({
restUserInfo,
})
informationStringified
);

@@ -95,8 +98,11 @@ };

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](https://help.hotjar.com/hc/en-us/articles/360033640653-Identify-API-Reference))
2. `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)) (Please note: __The Identify API is only available to Business plan customers.__)
3. `logCallback`: Optional callback for logging wether Hotjar identified user or not
```tsx
identifyHotjar: (userId: string, userInfo: string, logCallback?: () => void) =>
boolean;
identifyHotjar: (
userId: string,
userInfo: string,
logCallback?: () => void
) => boolean;
```

@@ -103,0 +109,0 @@