New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gtm-react-hook

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gtm-react-hook - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

10

dist/index.js

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

"use strict";var p=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var g=(e,t,o)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,h=(e,t)=>{for(var o in t||(t={}))T.call(t,o)&&g(e,o,t[o]);if(f)for(var o of f(t))D.call(t,o)&&g(e,o,t[o]);return e};var G=(e,t)=>{for(var o in t)p(e,o,{get:t[o],enumerable:!0})},N=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $(t))!T.call(e,n)&&n!==o&&p(e,n,{get:()=>t[n],enumerable:!(s=L(t,n))||s.enumerable});return e};var b=e=>N(p({},"__esModule",{value:!0}),e);var C={};G(C,{useGTM:()=>M});module.exports=b(C);var i=require("react");var l="dataLayer",E="https://www.googletagmanager.com",w="gtm.js";var _=(e,t)=>e===void 0?"":t==="script"?`+ '&gtm_auth=${e.gtm_auth}&gtm_preview=${e.gtm_preview}&gtm_cookies_win=x'`:`&gtm_auth=${e.gtm_auth}&gtm_preview=${e.gtm_preview}&gtm_cookies_win=x`,y=e=>{let[t,o]=e==="script"?["Script","header"]:["Noscript","body"];console.info(`\u{1F7E2} [gtm-react-hook] GTM ${t} was added to ${o}`)},A=e=>{let{tagId:t,domain:o=E,script:s=w,dataLayerName:n=l,nonce:r,environment:c,devMode:m}=e,a=document.createElement("script");r&&a.setAttribute("nonce",r);let u=_(c,"script");a.innerHTML=`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
"use strict";var p=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var g=(e,t,o)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,h=(e,t)=>{for(var o in t||(t={}))T.call(t,o)&&g(e,o,t[o]);if(f)for(var o of f(t))D.call(t,o)&&g(e,o,t[o]);return e};var G=(e,t)=>{for(var o in t)p(e,o,{get:t[o],enumerable:!0})},N=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $(t))!T.call(e,n)&&n!==o&&p(e,n,{get:()=>t[n],enumerable:!(s=L(t,n))||s.enumerable});return e};var b=e=>N(p({},"__esModule",{value:!0}),e);var C={};G(C,{useGTM:()=>M});module.exports=b(C);var i=require("react");var u="dataLayer",E="https://www.googletagmanager.com",w="gtm.js";var _=(e,t)=>e===void 0?"":t==="script"?`+ '&gtm_auth=${e.gtm_auth}&gtm_preview=${e.gtm_preview}&gtm_cookies_win=x'`:`&gtm_auth=${e.gtm_auth}&gtm_preview=${e.gtm_preview}&gtm_cookies_win=x`,y=e=>{let[t,o]=e==="script"?["Script","header"]:["Noscript","body"];console.info(`\u{1F7E2} [gtm-react-hook] GTM ${t} was added to ${o}`)},A=e=>{let{tagId:t,domain:o=E,script:s=w,dataLayerName:n=u,nonce:r,environment:c,devMode:m}=e,d=document.createElement("script");r&&d.setAttribute("nonce",r);let l=_(c,"script");d.innerHTML=`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'${o}/${s}?id='+i+dl${u};f.parentNode.insertBefore(j,f);
})(window,document,'script','${n}','${t}');`,document.head.childNodes[0]?document.head.insertBefore(a,document.head.childNodes[0]):document.head.appendChild(a),m&&y("script");let d=document.createElement("noscript"),v=_(c,"noscript");d.innerHTML=`<iframe
src="https://${o}/ns.html?id=${t}${v}"
'${o}/${s}?id='+i+dl${l};f.parentNode.insertBefore(j,f);
})(window,document,'script','${n}','${t}');`,document.head.childNodes[0]?document.head.insertBefore(d,document.head.childNodes[0]):document.head.appendChild(d),m&&y("script");let a=document.createElement("noscript"),v=_(c,"noscript");a.innerHTML=`<iframe
src="${o}/ns.html?id=${t}${v}"
height="0"
width="0"
style="display:none;visibility:hidden"
/>`,document.body.childNodes[0]?document.body.insertBefore(d,document.body.childNodes[0]):document.body.appendChild(d),m&&y("noscript")};var M=()=>{let e=(0,i.useRef)(l),t=(0,i.useRef)(!1),o=(0,i.useCallback)(({tagId:n,dataLayerName:r,domain:c,environment:m,nonce:a,script:u,devMode:d})=>{d&&(console.log("\u{1F680} ~ useGTM ~ devMode:",d),t.current=!0),A({tagId:n,dataLayerName:r,domain:c,environment:m,nonce:a,script:u,devMode:d}),typeof r=="string"&&(e.current=r)},[]),s=(0,i.useCallback)((n,r)=>{if(e.current in window){let c=h({event:n},r);window[e.current].push(c),t.current&&console.info("\u{1F535} [gtm-react-hook] Event has sent! Payload:",c)}else console.warn("\u{1F534} [gtm-react-hook] Event didn't send! GTM is not initialized! Please, check its initialization")},[]);return(0,i.useMemo)(()=>({runGTM:o,eventGTM:s}),[o,s])};0&&(module.exports={useGTM});
/>`,document.body.childNodes[0]?document.body.insertBefore(a,document.body.childNodes[0]):document.body.appendChild(a),m&&y("noscript")};var M=()=>{let e=(0,i.useRef)(u),t=(0,i.useRef)(!1),o=(0,i.useCallback)(({tagId:n,dataLayerName:r,domain:c,environment:m,nonce:d,script:l,devMode:a})=>{a&&(t.current=!0),A({tagId:n,dataLayerName:r,domain:c,environment:m,nonce:d,script:l,devMode:a}),typeof r=="string"&&(e.current=r)},[]),s=(0,i.useCallback)((n,r)=>{if(e.current in window){let c=h({event:n},r);window[e.current].push(c),t.current&&console.info("\u{1F535} [gtm-react-hook] Event has sent! Payload:",c)}else console.warn("\u{1F534} [gtm-react-hook] Event didn't send! GTM is not initialized! Please, check its initialization")},[]);return(0,i.useMemo)(()=>({runGTM:o,eventGTM:s}),[o,s])};0&&(module.exports={useGTM});
{
"name": "gtm-react-hook",
"description": "Easy-to-use React hooks for Google Tag Management based on TypeScript",
"version": "0.0.4",
"version": "0.0.5",
"scripts": {

@@ -6,0 +6,0 @@ "start": "webpack serve --open",

@@ -62,3 +62,3 @@ import type { GTMConstructor, GTMEnvironment } from "@/typings/typedefs";

noScriptTag.innerHTML = `<iframe
src="https://${domain}/ns.html?id=${tagId}${iframeEnv}"
src="${domain}/ns.html?id=${tagId}${iframeEnv}"
height="0"

@@ -65,0 +65,0 @@ width="0"

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