@devgateway/dvz-ui-react 1.6.13 → 1.6.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),t=require("react"),s=require("react-ga4"),p=require("react-router"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),t=require("react"),s=require("react-ga4"),p=require("react-router"),C=require("../conf/index.js"),g=require("@devgateway/wp-react-lib"),A=require("./internalTrafficUtils.js"),u=new Set,_=(f,T={})=>l=>{var o;const i=t.useContext(g.SettingsContext)??{},e=((o=i==null?void 0:i.data)==null?void 0:o.google_analytics_code)??C.Config.GA_CODE,r=p.useLocation(),n=t.useRef(!1);return t.useEffect(()=>{e&&e!=="#REACT_APP_GA_CODE#"&&!n.current&&(u.has(e)||(s.initialize(e),u.add(e),console.log("GA initialized with code:",e)),n.current=!0)},[e]),t.useEffect(()=>{if(e&&e!=="#REACT_APP_GA_CODE#"&&n.current){const c=r.pathname,a=A.isInternalTrafficEnabled()?"internal":"external";s.send({hitType:"pageview",page:c,traffic_type:a}),console.log("GA pageview sent:",{page:c,traffic_type:a})}},[r.pathname,e]),d.jsx(f,{...l})};exports.withTracker=_;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useLocation as
|
|
5
|
-
import { Config as
|
|
6
|
-
import { SettingsContext as
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import d, { useRef as C, useEffect as c } from "react";
|
|
3
|
+
import s from "react-ga4";
|
|
4
|
+
import { useLocation as A } from "react-router";
|
|
5
|
+
import { Config as _ } from "../conf/index.js";
|
|
6
|
+
import { SettingsContext as u } from "@devgateway/wp-react-lib";
|
|
7
7
|
import { isInternalTrafficEnabled as g } from "./internalTrafficUtils.js";
|
|
8
|
-
const
|
|
8
|
+
const f = /* @__PURE__ */ new Set(), z = (p, h = {}) => (l) => {
|
|
9
9
|
var n;
|
|
10
|
-
const e =
|
|
10
|
+
const e = d.useContext(u) ?? {}, t = ((n = e == null ? void 0 : e.data) == null ? void 0 : n.google_analytics_code) ?? _.GA_CODE, i = A(), o = C(!1);
|
|
11
11
|
return c(() => {
|
|
12
|
-
t && t !== "#REACT_APP_GA_CODE#" && !o.current && (
|
|
12
|
+
t && t !== "#REACT_APP_GA_CODE#" && !o.current && (f.has(t) || (s.initialize(t), f.add(t), console.log("GA initialized with code:", t)), o.current = !0);
|
|
13
13
|
}, [t]), c(() => {
|
|
14
14
|
if (t && t !== "#REACT_APP_GA_CODE#" && o.current) {
|
|
15
15
|
const r = i.pathname, a = g() ? "internal" : "external";
|
|
16
|
-
|
|
16
|
+
s.send({
|
|
17
17
|
hitType: "pageview",
|
|
18
18
|
page: r,
|
|
19
19
|
traffic_type: a
|
|
20
20
|
}), console.log("GA pageview sent:", { page: r, traffic_type: a });
|
|
21
21
|
}
|
|
22
|
-
}, [i.pathname, t]), /* @__PURE__ */
|
|
22
|
+
}, [i.pathname, t]), /* @__PURE__ */ m(p, { ...l });
|
|
23
23
|
};
|
|
24
24
|
export {
|
|
25
25
|
z as withTracker
|