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

react-gtm-ts

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-gtm-ts - npm Package Compare versions

Comparing version 1.0.25 to 1.0.26

77

dist/index.js

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

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
ReactTagManager: () => ReactTagManager
});
module.exports = __toCommonJS(src_exports);
// src/features/init/index.ts
var init = ({ code, debug = false }) => {
if (typeof window === "undefined")
return;
const elScript = document.createElement("script");
const script = `(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='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','${code}');`;
elScript.innerHTML = script;
const elNoscript = document.createElement("noscript");
const noscript = `<iframe src="https://www.googletagmanager.com/ns.html?id=${code}" height="0" width="0" style="display:none;visibility:hidden"></iframe>`;
elNoscript.innerHTML = noscript;
document.head.insertBefore(elScript, document.head.childNodes[0]);
document.body.insertBefore(elNoscript, document.body.childNodes[0]);
if (debug) {
console.log(`\u{1F7E2} react-gtm-ts - init - ${code}`);
window.react_gtm_ts = {
debug: true
};
}
};
// src/features/action/index.ts
var action = ({ event, ...more }) => {
var _a, _b;
if (typeof ((_a = window == null ? void 0 : window.dataLayer) == null ? void 0 : _a.push) !== "undefined") {
window.dataLayer.push({
event,
...more
});
if ((_b = window == null ? void 0 : window.react_gtm_ts) == null ? void 0 : _b.debug) {
console.log("\u{1F7E2} react-gtm-ts - action - ", {
event,
...more
});
}
} else {
console.error(
"\u{1F6D1} react-gtm-ts - Add ReactTagManager.init passing GTM code in app or _app (nextjs), see more in the documentation https://github.com/jr-duarte/react-gtm-ts"
);
}
};
// src/features/index.ts
var ReactTagManager = {
init,
action
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ReactTagManager
});
"use strict";var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var n in e)r(t,n,{get:e[n],enumerable:!0})},w=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!p.call(t,o)&&o!==n&&r(t,o,{get:()=>e[o],enumerable:!(i=g(e,o))||i.enumerable});return t};var u=t=>w(r({},"__esModule",{value:!0}),t);var f={};l(f,{ReactTagManager:()=>c});module.exports=u(f);var a=({code:t,debug:e=!1})=>{if(typeof window>"u")return;let n=document.createElement("script"),i=`(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='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','${t}');`;n.innerHTML=i;let o=document.createElement("noscript"),d=`<iframe src="https://www.googletagmanager.com/ns.html?id=${t}" height="0" width="0" style="display:none;visibility:hidden"></iframe>`;o.innerHTML=d,document.head.insertBefore(n,document.head.childNodes[0]),document.body.insertBefore(o,document.body.childNodes[0]),e&&(console.log(`\u{1F7E2} react-gtm-ts - init - ${t}`),window.react_gtm_ts={debug:!0})};var s=({event:t,...e})=>{var n,i;typeof((n=window==null?void 0:window.dataLayer)==null?void 0:n.push)<"u"?(window.dataLayer.push({event:t,...e}),(i=window==null?void 0:window.react_gtm_ts)!=null&&i.debug&&console.log("\u{1F7E2} react-gtm-ts - action - ",{event:t,...e})):console.error("\u{1F6D1} react-gtm-ts - Add ReactTagManager.init passing GTM code in app or _app (nextjs), see more in the documentation https://github.com/jr-duarte/react-gtm-ts")};var c={init:a,action:s};0&&(module.exports={ReactTagManager});

6

package.json

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "1.0.25",
"version": "1.0.26",
"description": "This is a library to facilitate the implementation of Google Tag Manager.",

@@ -27,4 +27,4 @@ "main": "./dist/index.js",

"scripts": {
"build": "tsup src/index.ts --format esm,cjs --dts",
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
"build": "tsup src/index.ts --format esm,cjs --dts --minify",
"dev": "tsup src/index.ts --format esm,cjs --dts --minify --watch",
"prepare": "husky install",

@@ -31,0 +31,0 @@ "lint": "eslint ./",

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