@elgorditosalsero/react-gtm-hook
Advanced tools
Comparing version 2.5.0 to 2.6.0
@@ -145,3 +145,2 @@ 'use strict'; | ||
customDomain = _ref.customDomain; | ||
console.log('CUSTOOOOM DOMAIN', customDomain); | ||
var gtm = setupGTM({ | ||
@@ -148,0 +147,0 @@ dataLayer: dataLayer, |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var a=function(e){var t=e.dataLayerName;window[t]?window[t].push(e.data):console.warn("dataLayer "+t+" does not exist, has script be initialized")},i={dataLayer:void 0,dataLayerName:"dataLayer",environment:void 0,nonce:void 0,id:"",injectScript:!0},o=t.createContext(i),d=t.createContext(void 0);function c(e,t){return a({data:t,dataLayerName:null==e?void 0:e.dataLayerName}),e}exports.GTMContext=o,exports.GTMContextDispatch=d,exports.GTMProvider=function(e){var a=e.state,s=e.children,u=t.useReducer(c,r({},i,a)),m=u[0],v=u[1];return t.useEffect((function(){a&&0!=a.injectScript&&function(e){var t=e.dataLayer,n=e.dataLayerName,r=e.environment,a=e.nonce,i=e.id,o=e.customDomain;console.log("CUSTOOOOM DOMAIN",o);var d,c=(d={dataLayer:t,dataLayerName:n,environment:r,nonce:a,id:i,customDomain:o},{getDataLayerScript:function(){var e,t,n=document.createElement("script");return d.nonce&&n.setAttribute("nonce",d.nonce),n.innerHTML=(void 0===(t=d.dataLayerName)&&(t="dataLayer"),"window."+t+" = window."+t+" || [];"+((e=d.dataLayer)?"window."+t+".push("+JSON.stringify(e)+")":"")),n},getNoScript:function(){var e=document.createElement("noscript");return e.innerHTML=function(e,t,n){void 0===n&&(n="https://www.googletagmanager.com");var r="";return t&&(r=">m_auth="+t.gtm_auth+">m_preview="+t.gtm_preview+">m_cookies_win=x"),'<iframe src="'+n+"/ns.html?id="+e+r+'" height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>'}(d.id,d.environment,d.customDomain),e},getScript:function(){var e=document.createElement("script");return d.nonce&&e.setAttribute("nonce",d.nonce),e.innerHTML=function(e,t,n,r){void 0===r&&(r="https://www.googletagmanager.com");var a="";return n&&(a='+">m_auth='+n.gtm_auth+">m_preview="+n.gtm_preview+'>m_cookies_win=x"'),"\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '"+r+"/gtm.js?id='+i+dl"+a+";f.parentNode.insertBefore(j,f);\n })(window,document,'script','"+e+"','"+t+"');\n "}(d.dataLayerName,d.id,d.environment,d.customDomain),e}}),s=c.getDataLayerScript(),u=c.getScript(),m=c.getNoScript();document.head.insertBefore(s,document.head.childNodes[0]),document.head.insertBefore(u,document.head.childNodes[1]),document.body.insertBefore(m,document.body.childNodes[0])}(r({},m,a))}),[JSON.stringify(a)]),n.createElement(o.Provider,{value:m},n.createElement(d.Provider,{value:v},s))},exports.initialState=i,exports.sendToGTM=a,exports.useGTMDispatch=function(){var e=t.useContext(d);if(void 0===e)throw new Error("dispatchGTMEvent must be used within a GTMProvider");return e}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var a=function(e){var t=e.dataLayerName;window[t]?window[t].push(e.data):console.warn("dataLayer "+t+" does not exist, has script be initialized")},i={dataLayer:void 0,dataLayerName:"dataLayer",environment:void 0,nonce:void 0,id:"",injectScript:!0},o=t.createContext(i),d=t.createContext(void 0);function c(e,t){return a({data:t,dataLayerName:null==e?void 0:e.dataLayerName}),e}exports.GTMContext=o,exports.GTMContextDispatch=d,exports.GTMProvider=function(e){var a=e.state,s=e.children,u=t.useReducer(c,r({},i,a)),m=u[0],v=u[1];return t.useEffect((function(){a&&0!=a.injectScript&&function(e){var t,n=(t={dataLayer:e.dataLayer,dataLayerName:e.dataLayerName,environment:e.environment,nonce:e.nonce,id:e.id,customDomain:e.customDomain},{getDataLayerScript:function(){var e,n,r=document.createElement("script");return t.nonce&&r.setAttribute("nonce",t.nonce),r.innerHTML=(void 0===(n=t.dataLayerName)&&(n="dataLayer"),"window."+n+" = window."+n+" || [];"+((e=t.dataLayer)?"window."+n+".push("+JSON.stringify(e)+")":"")),r},getNoScript:function(){var e=document.createElement("noscript");return e.innerHTML=function(e,t,n){void 0===n&&(n="https://www.googletagmanager.com");var r="";return t&&(r=">m_auth="+t.gtm_auth+">m_preview="+t.gtm_preview+">m_cookies_win=x"),'<iframe src="'+n+"/ns.html?id="+e+r+'" height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>'}(t.id,t.environment,t.customDomain),e},getScript:function(){var e=document.createElement("script");return t.nonce&&e.setAttribute("nonce",t.nonce),e.innerHTML=function(e,t,n,r){void 0===r&&(r="https://www.googletagmanager.com");var a="";return n&&(a='+">m_auth='+n.gtm_auth+">m_preview="+n.gtm_preview+'>m_cookies_win=x"'),"\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '"+r+"/gtm.js?id='+i+dl"+a+";f.parentNode.insertBefore(j,f);\n })(window,document,'script','"+e+"','"+t+"');\n "}(t.dataLayerName,t.id,t.environment,t.customDomain),e}}),r=n.getDataLayerScript(),a=n.getScript(),i=n.getNoScript();document.head.insertBefore(r,document.head.childNodes[0]),document.head.insertBefore(a,document.head.childNodes[1]),document.body.insertBefore(i,document.body.childNodes[0])}(r({},m,a))}),[JSON.stringify(a)]),n.createElement(o.Provider,{value:m},n.createElement(d.Provider,{value:v},s))},exports.initialState=i,exports.sendToGTM=a,exports.useGTMDispatch=function(){var e=t.useContext(d);if(void 0===e)throw new Error("dispatchGTMEvent must be used within a GTMProvider");return e}; | ||
//# sourceMappingURL=react-gtm-hook.cjs.production.min.js.map |
@@ -138,3 +138,2 @@ import React, { createContext, useReducer, useEffect, useContext } from 'react'; | ||
customDomain = _ref.customDomain; | ||
console.log('CUSTOOOOM DOMAIN', customDomain); | ||
var gtm = setupGTM({ | ||
@@ -141,0 +140,0 @@ dataLayer: dataLayer, |
@@ -14,3 +14,3 @@ { | ||
"description": "Easily manage the Google Tag Manager via Hook", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"license": "MIT", | ||
@@ -54,3 +54,3 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"react": "^16.13.1 || ^17.0.0" | ||
"react": "^16.13.1 || ^17.0.0 || 18" | ||
}, | ||
@@ -57,0 +57,0 @@ "husky": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69190
547