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

ga-4-react

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ga-4-react - npm Package Compare versions

Comparing version 0.1.231 to 0.1.241

dist/example/InjectGAinChildrenComponents.d.ts

7

dist/components/GA4RComponents.d.ts
import React from 'react';
import { ga4Config } from '../lib/gtagModels';
export interface IGAReactConfig {
send_page_view: boolean;
groups: string;
}
export interface IGA4R {
code: string;
config?: ga4Config | object;
config?: IGAReactConfig;
additionalCode?: Array<string>;

@@ -7,0 +10,0 @@ children?: any;

@@ -50,3 +50,4 @@ 'use strict';

event: this.event,
gtag: this.gtag
gtag: this.gtag,
ga: this.ga
});

@@ -96,2 +97,12 @@ };

/**
* @desc direct access to ga
* @param args
*/
ga() {
//@ts-ignore
return window.ga(...arguments);
}
/**
* @desc direct access to gtag

@@ -116,3 +127,3 @@ * @param args

} = _ref;
var [components, setComponents] = React.useState(children);
var [components, setComponents] = React.useState(null);
React.useEffect(() => {

@@ -122,6 +133,16 @@ var ga4manager = new GA4React("" + code, config, additionalCode);

setComponents(React__default.Children.map(children, (child, index) => {
return React__default.cloneElement(child, {
ga4: ga4,
index
});
if (!React__default.isValidElement(child)) {
return React__default.createElement(React__default.Fragment, null, child);
} else {
//@ts-ignore
if (child.type && typeof child.type.name !== 'undefined') {
return React__default.cloneElement(child, {
//@ts-ignore
ga4: ga4,
index
});
} else {
return child;
}
}
}));

@@ -128,0 +149,0 @@ }, err => {

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;class n{constructor(e,t,a){this.gaCode=e,this.config=t,this.additionalGaCode=a,this.config=t||{},this.gaCode=e}initialize(){return new Promise((e,t)=>{var a=document.getElementsByTagName("head")[0],n=document.createElement("script");n.setAttribute("async",""),n.setAttribute("src","https://www.googletagmanager.com/gtag/js?id="+this.gaCode),n.onload=()=>{var t=document.createElement("script"),n="\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '"+this.gaCode+"', "+JSON.stringify(this.config)+");";this.additionalGaCode&&this.additionalGaCode.forEach(e=>{n+="gtag('config', '"+e+"');"}),t.innerHTML=n,a.appendChild(t),e({pageview:this.pageview,event:this.event,gtag:this.gtag})},n.onerror=e=>{t(e)},a.appendChild(n)})}pageview(e){return this.gtag("event","page_view",{page_path:e,page_location:window.location,page_title:document.title})}event(e,t,a,n){return void 0===n&&(n=!1),this.gtag("event",e,{event_label:t,event_category:a,non_interaction:n})}gtag(){return window.gtag(...arguments)}}exports.GA4R=e=>{var{code:i,config:o,additionalCode:r,children:g}=e,[d,s]=t.useState(g);return t.useEffect(()=>{new n(""+i,o,r).initialize().then(e=>{s(a.Children.map(g,(t,n)=>a.cloneElement(t,{ga4:e,index:n})))},e=>{console.error(e)})},[]),a.createElement(a.Fragment,null,d)},exports.default=n;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;class n{constructor(e,t,a){this.gaCode=e,this.config=t,this.additionalGaCode=a,this.config=t||{},this.gaCode=e}initialize(){return new Promise((e,t)=>{var a=document.getElementsByTagName("head")[0],n=document.createElement("script");n.setAttribute("async",""),n.setAttribute("src","https://www.googletagmanager.com/gtag/js?id="+this.gaCode),n.onload=()=>{var t=document.createElement("script"),n="\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '"+this.gaCode+"', "+JSON.stringify(this.config)+");";this.additionalGaCode&&this.additionalGaCode.forEach(e=>{n+="gtag('config', '"+e+"');"}),t.innerHTML=n,a.appendChild(t),e({pageview:this.pageview,event:this.event,gtag:this.gtag,ga:this.ga})},n.onerror=e=>{t(e)},a.appendChild(n)})}pageview(e){return this.gtag("event","page_view",{page_path:e,page_location:window.location,page_title:document.title})}event(e,t,a,n){return void 0===n&&(n=!1),this.gtag("event",e,{event_label:t,event_category:a,non_interaction:n})}ga(){return window.ga(...arguments)}gtag(){return window.gtag(...arguments)}}exports.GA4R=e=>{var{code:i,config:o,additionalCode:r,children:g}=e,[d,s]=t.useState(null);return t.useEffect(()=>{new n(""+i,o,r).initialize().then(e=>{s(a.Children.map(g,(t,n)=>a.isValidElement(t)?t.type&&void 0!==t.type.name?a.cloneElement(t,{ga4:e,index:n}):t:a.createElement(a.Fragment,null,t)))},e=>{console.error(e)})},[]),a.createElement(a.Fragment,null,d)},exports.default=n;
//# sourceMappingURL=ga-4-react.cjs.production.min.js.map

@@ -43,3 +43,4 @@ import React, { useState, useEffect } from 'react';

event: this.event,
gtag: this.gtag
gtag: this.gtag,
ga: this.ga
});

@@ -89,2 +90,12 @@ };

/**
* @desc direct access to ga
* @param args
*/
ga() {
//@ts-ignore
return window.ga(...arguments);
}
/**
* @desc direct access to gtag

@@ -109,3 +120,3 @@ * @param args

} = _ref;
var [components, setComponents] = useState(children);
var [components, setComponents] = useState(null);
useEffect(() => {

@@ -115,6 +126,16 @@ var ga4manager = new GA4React("" + code, config, additionalCode);

setComponents(React.Children.map(children, (child, index) => {
return React.cloneElement(child, {
ga4: ga4,
index
});
if (!React.isValidElement(child)) {
return React.createElement(React.Fragment, null, child);
} else {
//@ts-ignore
if (child.type && typeof child.type.name !== 'undefined') {
return React.cloneElement(child, {
//@ts-ignore
ga4: ga4,
index
});
} else {
return child;
}
}
}));

@@ -121,0 +142,0 @@ }, err => {

@@ -35,2 +35,7 @@ import { ga4Config, GA4ReactInterface, GA4ReactResolveInterface, gtagAction, gtagCategory, gtagFunction, gtagLabel } from './gtagModels';

/**
* @desc direct access to ga
* @param args
*/
ga(...args: any): any;
/**
* @desc direct access to gtag

@@ -37,0 +42,0 @@ * @param args

@@ -44,2 +44,3 @@ export declare type gtagEvent = 'event' | string;

gtag(...args: any): any;
ga(...args: any): any;
}

@@ -46,0 +47,0 @@ /**

{
"version": "0.1.231",
"version": "0.1.241",
"license": "MIT",

@@ -50,2 +50,3 @@ "main": "dist/index.js",

"@size-limit/preset-small-lib": "^4.7.0",
"@testing-library/react": "^11.1.2",
"@types/jest": "^26.0.15",

@@ -59,2 +60,3 @@ "@types/jsdom": "^16.2.5",

"react": "^17.0.1",
"react-dom": "^17.0.1",
"size-limit": "^4.7.0",

@@ -61,0 +63,0 @@ "tsdx": "^0.14.1",

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

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