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 - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

CHANGELOG.md

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

### [1.0.7](https://github.com/olavoparno/react-use-hotjar/compare/v1.0.6...v1.0.7) (2020-08-13)
### [1.0.6](https://github.com/olavoparno/react-use-hotjar/compare/v1.0.5...v1.0.6) (2020-08-11)

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

50

dist/index.es.js

@@ -1,50 +0,2 @@

import { useCallback, useMemo } from 'react';
function useAppendHeadScript() {
var appendHeadScript = useCallback(function (scriptText, scriptId) {
try {
var existentScript = document.getElementById(scriptId);
var script = existentScript || document.createElement('script');
script.id = scriptId;
script.innerText = scriptText;
script.crossOrigin = 'anonymous';
document.head.appendChild(script);
return true;
}
catch (_a) {
return false;
}
}, []);
return useMemo(function () { return ({ appendHeadScript: appendHeadScript }); }, [appendHeadScript]);
}
function useHotjar() {
var appendHeadScript = useAppendHeadScript().appendHeadScript;
var initHotjar = useCallback(function (hotjarId, hotjarVersion, loggerFunction) {
var hotjarScript = "(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:" + hotjarId + ",hjsv:" + hotjarVersion + "};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=');";
var isHotjarAppended = appendHeadScript(hotjarScript, 'hotjar-script');
if (loggerFunction && typeof loggerFunction === 'function')
loggerFunction("Hotjar ready: " + isHotjarAppended);
return isHotjarAppended;
}, [appendHeadScript]);
var identifyHotjar = useCallback(function (userId, userInfo, loggerFunction) {
try {
var hotjarIdentifyScript = "var userId=\"" + userId + "\" || null;window.hj(\"identify\",userId," + userInfo + ");";
var isIdentified = appendHeadScript(hotjarIdentifyScript, 'identify-script');
if (loggerFunction && typeof loggerFunction === 'function')
loggerFunction("Hotjar identified: " + isIdentified);
return isIdentified;
}
catch (error) {
console.error('Hotjar error:', error);
return false;
}
}, [appendHeadScript]);
return useMemo(function () { return ({ initHotjar: initHotjar, identifyHotjar: identifyHotjar }); }, [
initHotjar,
identifyHotjar,
]);
}
export { useHotjar };
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};
//# sourceMappingURL=index.es.js.map

@@ -1,54 +0,2 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
function useAppendHeadScript() {
var appendHeadScript = React.useCallback(function (scriptText, scriptId) {
try {
var existentScript = document.getElementById(scriptId);
var script = existentScript || document.createElement('script');
script.id = scriptId;
script.innerText = scriptText;
script.crossOrigin = 'anonymous';
document.head.appendChild(script);
return true;
}
catch (_a) {
return false;
}
}, []);
return React.useMemo(function () { return ({ appendHeadScript: appendHeadScript }); }, [appendHeadScript]);
}
function useHotjar() {
var appendHeadScript = useAppendHeadScript().appendHeadScript;
var initHotjar = React.useCallback(function (hotjarId, hotjarVersion, loggerFunction) {
var hotjarScript = "(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:" + hotjarId + ",hjsv:" + hotjarVersion + "};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=');";
var isHotjarAppended = appendHeadScript(hotjarScript, 'hotjar-script');
if (loggerFunction && typeof loggerFunction === 'function')
loggerFunction("Hotjar ready: " + isHotjarAppended);
return isHotjarAppended;
}, [appendHeadScript]);
var identifyHotjar = React.useCallback(function (userId, userInfo, loggerFunction) {
try {
var hotjarIdentifyScript = "var userId=\"" + userId + "\" || null;window.hj(\"identify\",userId," + userInfo + ");";
var isIdentified = appendHeadScript(hotjarIdentifyScript, 'identify-script');
if (loggerFunction && typeof loggerFunction === 'function')
loggerFunction("Hotjar identified: " + isIdentified);
return isIdentified;
}
catch (error) {
console.error('Hotjar error:', error);
return false;
}
}, [appendHeadScript]);
return React.useMemo(function () { return ({ initHotjar: initHotjar, identifyHotjar: identifyHotjar }); }, [
initHotjar,
identifyHotjar,
]);
}
exports.useHotjar = useHotjar;
"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])};
//# sourceMappingURL=index.js.map
{
"name": "react-use-hotjar",
"version": "1.0.6",
"version": "1.0.7",
"description": "Add Hotjar capabilities as custom hooks",

@@ -36,2 +36,3 @@ "author": "Olavo Parno",

"test:watch": "react-scripts test --env=jsdom",
"prebuild": "rm -rf dist",
"build": "rollup -c",

@@ -74,2 +75,3 @@ "start": "rollup -c -w",

"rollup-plugin-peer-deps-external": "^2.2.3",
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-typescript2": "^0.27.2",

@@ -76,0 +78,0 @@ "standard-version": "^8.0.2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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