ga-4-react
Advanced tools
Comparing version 0.1.241 to 0.1.242
@@ -47,8 +47,15 @@ 'use strict'; | ||
head.appendChild(scriptSync); | ||
resolve({ | ||
var resolved = { | ||
pageview: this.pageview, | ||
event: this.event, | ||
gtag: this.gtag, | ||
ga: this.ga | ||
}); | ||
gtag: this.gtag | ||
}; | ||
if (window.ga) { | ||
Object.assign(resolved, { | ||
ga: this.ga | ||
}); | ||
} | ||
resolve(resolved); | ||
}; | ||
@@ -55,0 +62,0 @@ |
@@ -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,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; | ||
"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);var i={pageview:this.pageview,event:this.event,gtag:this.gtag};window.ga&&Object.assign(i,{ga:this.ga}),e(i)},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 |
@@ -40,8 +40,15 @@ import React, { useState, useEffect } from 'react'; | ||
head.appendChild(scriptSync); | ||
resolve({ | ||
var resolved = { | ||
pageview: this.pageview, | ||
event: this.event, | ||
gtag: this.gtag, | ||
ga: this.ga | ||
}); | ||
gtag: this.gtag | ||
}; | ||
if (window.ga) { | ||
Object.assign(resolved, { | ||
ga: this.ga | ||
}); | ||
} | ||
resolve(resolved); | ||
}; | ||
@@ -48,0 +55,0 @@ |
@@ -5,2 +5,3 @@ import { ga4Config, GA4ReactInterface, GA4ReactResolveInterface, gtagAction, gtagCategory, gtagFunction, gtagLabel } from './gtagModels'; | ||
gtag: gtagFunction | Function; | ||
ga: Function; | ||
} | ||
@@ -7,0 +8,0 @@ } |
@@ -44,3 +44,3 @@ export declare type gtagEvent = 'event' | string; | ||
gtag(...args: any): any; | ||
ga(...args: any): any; | ||
ga?(...args: any): any; | ||
} | ||
@@ -47,0 +47,0 @@ /** |
{ | ||
"version": "0.1.241", | ||
"version": "0.1.242", | ||
"license": "MIT", | ||
@@ -20,3 +20,4 @@ "main": "dist/index.js", | ||
"size": "size-limit", | ||
"analyze": "size-limit --why" | ||
"analyze": "size-limit --why", | ||
"tsc-check": "./node_modules/typescript/bin/tsc -p ./tsconfig.json" | ||
}, | ||
@@ -26,3 +27,3 @@ "peerDependencies": {}, | ||
"hooks": { | ||
"pre-commit": "tsdx lint" | ||
"pre-commit": "npm run lint && npm run test && npm run tsc-check" | ||
} | ||
@@ -29,0 +30,0 @@ }, |
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
Sorry, the diff of this file is not supported yet
49228
673