@devgateway/dvz-ui-react 1.6.14 → 1.6.16
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.
- package/dist/cjs/layout/Layout.js +1 -1
- package/dist/cjs/tracker/InternalTrafficToggle.js +1 -1
- package/dist/cjs/tracker/withGoogleAnalytics.js +1 -1
- package/dist/esm/layout/Layout.js +20 -19
- package/dist/esm/tracker/InternalTrafficToggle.js +23 -23
- package/dist/esm/tracker/withGoogleAnalytics.js +86 -22
- package/dist/types/layout/Layout.d.ts +5 -2
- package/dist/types/tracker/InternalTrafficToggle.d.ts +1 -0
- package/dist/types/tracker/withGoogleAnalytics.d.ts +4 -5
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),o=require("react"),t=require("react-router"),m=require("../embeddable/index.js"),f=require("react-intl"),s=require("@devgateway/wp-react-lib"),g=require("react-redux");require("semantic-ui-react");require("../utils/AppMedia.js");require("./Footer.js");require("./Header.js");const p=require("./Customizer.js")
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),o=require("react"),t=require("react-router"),m=require("../embeddable/index.js"),f=require("react-intl"),s=require("@devgateway/wp-react-lib"),g=require("react-redux");require("semantic-ui-react");require("../utils/AppMedia.js");require("./Footer.js");require("./Header.js");const p=require("./Customizer.js");require("./Favicon.js");require("clsx");require("../utils/semanticUtils.js");require("./SearchControl.js");const h=require("../conf/index.js");require("./ClassicHeader.js");require("./FloatingMenuHeader.js");const x=require("../translations/en.json.js"),v=require("../translations/fr.json.js"),j=require("../translations/af.json.js"),w=require("../translations/am.json.js"),C=require("../lib/react-intl-redux/index.js");require("immutable");const n=require("../redux/store.js"),y=require("../tracker/withGoogleAnalytics.js"),i={en:x,fr:v,am:w,af:j},I=()=>{const a=t.useParams(),l=t.useLocation(),u=h.Config.DEFAULT_LOCALE,[b,d]=o.useState(!1),e=a.lan,q=l.pathname;return o.useEffect(()=>{d(!0),process.env.NODE_ENV==="development"&&(console.log("----------.env-----------"),console.log(process.env),console.log("----------.env-----------")),typeof window<"u"&&window.setTimeout(()=>{if(window.location.hash){const c=document.getElementById(window.location.hash.substring(1));c&&c.scrollIntoView({behavior:"auto",block:"start"})}},2e3)},[]),o.useEffect(()=>{n.store.dispatch(C.updateIntl({locale:e,formats:{},messages:i[e??"en"]}))},[e]),e?Object.keys(i).includes(e)?r.jsx(g.Provider,{store:n.store,children:r.jsx(f.IntlProvider,{locale:e,messages:i[e],children:r.jsx(s.AppContextProvider,{getComponent:m.getComponentByNameIgnoreCase,store:n.store,locale:e,children:r.jsx(s.SettingProvider,{locale:e,changeUUID:null,children:r.jsxs(s.SettingsConsumer,{children:[r.jsx(p.CustomizerWrapper,{}),r.jsx(t.Outlet,{})]})})})},e)}):r.jsx(t.Navigate,{to:`/${u}${q}`,replace:!0}):r.jsx(t.Navigate,{to:u,replace:!0})},L=y.withTracker(I);exports.default=L;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),l=require("react"),g=require("react-router"),u=require("./internalTrafficUtils.js"),h=({token:c,redirectTo:d="/"})=>{const[a]=g.useSearchParams(),f=g.useNavigate(),[e,t]=l.useState("validating"),[b,n]=l.useState("Processing...");l.useEffect(()=>{const o=a.get("enable"),x=a.get("k");if(!u.validateToken(x,c)){t("error"),n("Invalid or missing token. Access denied."),console.error("Invalid token provided for internal traffic toggle");return}if(o!=="0"&&o!=="1"){t("error"),n("Invalid enable parameter. Use ?enable=0 or ?enable=1"),console.error("Invalid enable parameter:",o);return}try{const r=o==="1";u.setInternalTrafficCookie(r),t("success"),n(r?"✓ Internal traffic enabled. GA4 events will be tagged as internal.":"✓ Internal traffic disabled. GA4 events will be tagged as external."),console.log(`Internal traffic ${r?"enabled":"disabled"} successfully`),setTimeout(()=>{f(d)},3e3)}catch(r){t("error"),n(`Error: ${r instanceof Error?r.message:"Unknown error"}`),console.error("Error setting internal traffic cookie:",r)}},[a,c,f,d]);const m={display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},i={textAlign:"center",padding:"2rem",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",maxWidth:"500px"},p=e==="success"?{...i,backgroundColor:"#f0f9ff",borderLeft:"4px solid #10b981"}:e==="error"?{...i,backgroundColor:"#fef2f2",borderLeft:"4px solid #ef4444"}:{...i,backgroundColor:"#f3f4f6",borderLeft:"4px solid #3b82f6"},y={fontSize:"1.5rem",fontWeight:"600",margin:"0 0 1rem 0",color:e==="success"?"#059669":e==="error"?"#dc2626":"#1f2937"},S={fontSize:"1rem",margin:"1rem 0",color:e==="success"?"#047857":e==="error"?"#991b1b":"#374151",lineHeight:"1.5"},v={fontSize:"0.875rem",color:"#6b7280",marginTop:"1.5rem",fontStyle:"italic"};return s.jsx("div",{style:m,children:s.jsxs("div",{style:p,children:[s.jsx("h1",{style:y,children:e==="success"?"Success":e==="error"?"Error":"Processing"}),s.jsx("p",{style:S,children:b}),e==="success"&&s.jsx("p",{style:v,children:"Redirecting to home page in 3 seconds..."})]})})};exports.default=h;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react/jsx-runtime"),i=require("react"),c=require("react-ga4"),x=require("react-router"),P=require("../conf/index.js"),b=require("@devgateway/wp-react-lib"),E=require("./internalTrafficUtils.js"),C=new Set;let s=!1;const L=l=>{const f=T=>{var m;const d=i.useContext(b.SettingsContext)??{},e=((m=d==null?void 0:d.data)==null?void 0:m.google_analytics_code)??P.Config.GA_CODE,a=x.useLocation(),_=i.useRef(null),u=i.useRef(!1),g=i.useRef(!1);if(typeof window<"u"&&!s&&e&&e!=="#REACT_APP_GA_CODE#"){if(!C.has(e))try{c.initialize(e),C.add(e),console.log("GA initialized with code:",e)}catch(t){console.error("Failed to initialize GA:",t)}s=!0}return i.useEffect(()=>{if(typeof window>"u"||!e||e==="#REACT_APP_GA_CODE#"||!s)return;const t=a.pathname;if(_.current!==t){_.current=t,u.current=!1;try{const r=E.isInternalTrafficEnabled()?"internal":"external";c.event("page_view",{page_path:t,traffic_type:r}),console.log("GA pageview sent:",{page:t,traffic_type:r})}catch(r){console.error("Failed to send pageview:",r)}}},[a.pathname,e]),i.useEffect(()=>{if(typeof window>"u"||!e||e==="#REACT_APP_GA_CODE#"||!s||g.current)return;const t=E.isInternalTrafficEnabled()?"internal":"external",r=()=>{if(u.current)return;const n=Math.round(window.scrollY/(document.documentElement.scrollHeight-window.innerHeight)*100);if(n>10)try{c.event("scroll",{engagement_type:"scroll",scroll_depth:n,traffic_type:t}),console.log("GA scroll event sent:",{scrollPercentage:n,traffic_type:t}),u.current=!0}catch(o){console.error("Failed to send scroll event:",o)}},p=n=>{var A;const o=n.target,h=((A=o.textContent)==null?void 0:A.substring(0,50))||"",v=o.id||"",y=o.className||"";if(!(!h&&!v&&!y))try{c.event("element_click",{element_id:v,element_class:y,element_text:h.substring(0,50),traffic_type:t})}catch{}},G=Date.now(),w=()=>{const n=Math.round((Date.now()-G)/1e3);if(n>3)try{c.event("time_on_page",{page_path:a.pathname,duration_seconds:n,traffic_type:t}),console.log("GA time_on_page event sent:",{timeOnPage:n,path:a.pathname})}catch(o){console.error("Failed to send time_on_page event:",o)}};return window.addEventListener("scroll",r,{passive:!0}),document.addEventListener("click",p),window.addEventListener("beforeunload",w),g.current=!0,()=>{window.removeEventListener("scroll",r),document.removeEventListener("click",p),window.removeEventListener("beforeunload",w)}},[a.pathname,e]),R.jsx(l,{...T})};return f.displayName=`withTracker(${l.displayName||l.name||"Component"})`,f};exports.withTracker=L;
|
|
@@ -2,15 +2,21 @@ import { jsx as t, jsxs as f } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState as u, useEffect as m } from "react";
|
|
3
3
|
import { useParams as d, useLocation as g, Navigate as s, Outlet as h } from "react-router";
|
|
4
4
|
import { getComponentByNameIgnoreCase as v } from "../embeddable/index.js";
|
|
5
|
-
import { IntlProvider as
|
|
6
|
-
import { AppContextProvider as
|
|
7
|
-
import { Provider as
|
|
5
|
+
import { IntlProvider as w } from "react-intl";
|
|
6
|
+
import { AppContextProvider as C, SettingProvider as I, SettingsConsumer as L } from "@devgateway/wp-react-lib";
|
|
7
|
+
import { Provider as y } from "react-redux";
|
|
8
8
|
import "semantic-ui-react";
|
|
9
9
|
import "../utils/AppMedia.js";
|
|
10
10
|
import "./Footer.js";
|
|
11
11
|
import "./Header.js";
|
|
12
|
-
import { CustomizerWrapper as
|
|
13
|
-
import
|
|
12
|
+
import { CustomizerWrapper as E } from "./Customizer.js";
|
|
13
|
+
import "./Favicon.js";
|
|
14
|
+
import "clsx";
|
|
15
|
+
import "../utils/semanticUtils.js";
|
|
16
|
+
import "./SearchControl.js";
|
|
17
|
+
import { Config as P } from "../conf/index.js";
|
|
18
|
+
import "./ClassicHeader.js";
|
|
19
|
+
import "./FloatingMenuHeader.js";
|
|
14
20
|
import * as b from "../translations/en.json.js";
|
|
15
21
|
import * as x from "../translations/fr.json.js";
|
|
16
22
|
import * as N from "../translations/af.json.js";
|
|
@@ -18,21 +24,16 @@ import * as O from "../translations/am.json.js";
|
|
|
18
24
|
import { updateIntl as j } from "../lib/react-intl-redux/index.js";
|
|
19
25
|
import "immutable";
|
|
20
26
|
import { store as e } from "../redux/store.js";
|
|
21
|
-
import "
|
|
22
|
-
import "clsx";
|
|
23
|
-
import "../utils/semanticUtils.js";
|
|
24
|
-
import "./SearchControl.js";
|
|
25
|
-
import "./ClassicHeader.js";
|
|
26
|
-
import "./FloatingMenuHeader.js";
|
|
27
|
+
import { withTracker as k } from "../tracker/withGoogleAnalytics.js";
|
|
27
28
|
const r = {
|
|
28
29
|
en: b,
|
|
29
30
|
fr: x,
|
|
30
31
|
am: O,
|
|
31
32
|
af: N
|
|
32
|
-
},
|
|
33
|
-
const a = d(), p = g(), i =
|
|
33
|
+
}, A = () => {
|
|
34
|
+
const a = d(), p = g(), i = P.DEFAULT_LOCALE, [D, c] = u(!1), o = a.lan, l = p.pathname;
|
|
34
35
|
return m(() => {
|
|
35
|
-
|
|
36
|
+
c(!0), process.env.NODE_ENV === "development" && (console.log("----------.env-----------"), console.log(process.env), console.log("----------.env-----------")), typeof window < "u" && window.setTimeout(() => {
|
|
36
37
|
if (window.location.hash) {
|
|
37
38
|
const n = document.getElementById(window.location.hash.substring(1));
|
|
38
39
|
n && n.scrollIntoView({ behavior: "auto", block: "start" });
|
|
@@ -40,11 +41,11 @@ const r = {
|
|
|
40
41
|
}, 2e3);
|
|
41
42
|
}, []), m(() => {
|
|
42
43
|
e.dispatch(j({ locale: o, formats: {}, messages: r[o ?? "en"] }));
|
|
43
|
-
}, [o]), o ? Object.keys(r).includes(o) ? /* @__PURE__ */ t(
|
|
44
|
-
/* @__PURE__ */ t(
|
|
44
|
+
}, [o]), o ? Object.keys(r).includes(o) ? /* @__PURE__ */ t(y, { store: e, children: /* @__PURE__ */ t(w, { locale: o, messages: r[o], children: /* @__PURE__ */ t(C, { getComponent: v, store: e, locale: o, children: /* @__PURE__ */ t(I, { locale: o, changeUUID: null, children: /* @__PURE__ */ f(L, { children: [
|
|
45
|
+
/* @__PURE__ */ t(E, {}),
|
|
45
46
|
/* @__PURE__ */ t(h, {})
|
|
46
|
-
] }) }) }) }, o) }) : /* @__PURE__ */ t(s, { to: `/${i}${
|
|
47
|
-
};
|
|
47
|
+
] }) }) }) }, o) }) : /* @__PURE__ */ t(s, { to: `/${i}${l}`, replace: !0 }) : /* @__PURE__ */ t(s, { to: i, replace: !0 });
|
|
48
|
+
}, eo = k(A);
|
|
48
49
|
export {
|
|
49
|
-
|
|
50
|
+
eo as default
|
|
50
51
|
};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as d, useEffect as
|
|
3
|
-
import { useSearchParams as
|
|
4
|
-
import { validateToken as
|
|
5
|
-
const
|
|
6
|
-
const [a] =
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
1
|
+
import { jsx as o, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useEffect as y } from "react";
|
|
3
|
+
import { useSearchParams as S, useNavigate as h } from "react-router";
|
|
4
|
+
import { validateToken as v, setInternalTrafficCookie as x } from "./internalTrafficUtils.js";
|
|
5
|
+
const M = ({ token: l, redirectTo: c = "/" }) => {
|
|
6
|
+
const [a] = S(), f = h(), [e, s] = d("validating"), [g, t] = d("Processing...");
|
|
7
|
+
y(() => {
|
|
8
|
+
const n = a.get("enable"), u = a.get("k");
|
|
9
|
+
if (!v(u, l)) {
|
|
10
10
|
s("error"), t("Invalid or missing token. Access denied."), console.error("Invalid token provided for internal traffic toggle");
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
if (
|
|
14
|
-
s("error"), t("Invalid enable parameter. Use ?enable=0 or ?enable=1"), console.error("Invalid enable parameter:",
|
|
13
|
+
if (n !== "0" && n !== "1") {
|
|
14
|
+
s("error"), t("Invalid enable parameter. Use ?enable=0 or ?enable=1"), console.error("Invalid enable parameter:", n);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
try {
|
|
18
|
-
const r =
|
|
19
|
-
|
|
18
|
+
const r = n === "1";
|
|
19
|
+
x(r), s("success"), t(
|
|
20
20
|
r ? "✓ Internal traffic enabled. GA4 events will be tagged as internal." : "✓ Internal traffic disabled. GA4 events will be tagged as external."
|
|
21
21
|
), console.log(`Internal traffic ${r ? "enabled" : "disabled"} successfully`), setTimeout(() => {
|
|
22
|
-
c
|
|
22
|
+
f(c);
|
|
23
23
|
}, 3e3);
|
|
24
24
|
} catch (r) {
|
|
25
25
|
s("error"), t(`Error: ${r instanceof Error ? r.message : "Unknown error"}`), console.error("Error setting internal traffic cookie:", r);
|
|
26
26
|
}
|
|
27
|
-
}, [a, l, c]);
|
|
28
|
-
const
|
|
27
|
+
}, [a, l, f, c]);
|
|
28
|
+
const m = {
|
|
29
29
|
display: "flex",
|
|
30
30
|
justifyContent: "center",
|
|
31
31
|
alignItems: "center",
|
|
@@ -37,7 +37,7 @@ const w = ({ token: l }) => {
|
|
|
37
37
|
borderRadius: "8px",
|
|
38
38
|
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)",
|
|
39
39
|
maxWidth: "500px"
|
|
40
|
-
},
|
|
40
|
+
}, b = e === "success" ? {
|
|
41
41
|
...i,
|
|
42
42
|
backgroundColor: "#f0f9ff",
|
|
43
43
|
borderLeft: "4px solid #10b981"
|
|
@@ -50,20 +50,20 @@ const w = ({ token: l }) => {
|
|
|
50
50
|
backgroundColor: "#f3f4f6",
|
|
51
51
|
borderLeft: "4px solid #3b82f6"
|
|
52
52
|
};
|
|
53
|
-
return /* @__PURE__ */
|
|
54
|
-
/* @__PURE__ */
|
|
53
|
+
return /* @__PURE__ */ o("div", { style: m, children: /* @__PURE__ */ p("div", { style: b, children: [
|
|
54
|
+
/* @__PURE__ */ o("h1", { style: {
|
|
55
55
|
fontSize: "1.5rem",
|
|
56
56
|
fontWeight: "600",
|
|
57
57
|
margin: "0 0 1rem 0",
|
|
58
58
|
color: e === "success" ? "#059669" : e === "error" ? "#dc2626" : "#1f2937"
|
|
59
59
|
}, children: e === "success" ? "Success" : e === "error" ? "Error" : "Processing" }),
|
|
60
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ o("p", { style: {
|
|
61
61
|
fontSize: "1rem",
|
|
62
62
|
margin: "1rem 0",
|
|
63
63
|
color: e === "success" ? "#047857" : e === "error" ? "#991b1b" : "#374151",
|
|
64
64
|
lineHeight: "1.5"
|
|
65
|
-
}, children:
|
|
66
|
-
e === "success" && /* @__PURE__ */
|
|
65
|
+
}, children: g }),
|
|
66
|
+
e === "success" && /* @__PURE__ */ o("p", { style: {
|
|
67
67
|
fontSize: "0.875rem",
|
|
68
68
|
color: "#6b7280",
|
|
69
69
|
marginTop: "1.5rem",
|
|
@@ -72,5 +72,5 @@ const w = ({ token: l }) => {
|
|
|
72
72
|
] }) });
|
|
73
73
|
};
|
|
74
74
|
export {
|
|
75
|
-
|
|
75
|
+
M as default
|
|
76
76
|
};
|
|
@@ -1,26 +1,90 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useLocation as
|
|
5
|
-
import { Config as
|
|
6
|
-
import { SettingsContext as
|
|
7
|
-
import { isInternalTrafficEnabled as
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { jsx as P } from "react/jsx-runtime";
|
|
2
|
+
import L, { useRef as f, useEffect as E } from "react";
|
|
3
|
+
import a from "react-ga4";
|
|
4
|
+
import { useLocation as k } from "react-router";
|
|
5
|
+
import { Config as D } from "../conf/index.js";
|
|
6
|
+
import { SettingsContext as O } from "@devgateway/wp-react-lib";
|
|
7
|
+
import { isInternalTrafficEnabled as C } from "./internalTrafficUtils.js";
|
|
8
|
+
const G = /* @__PURE__ */ new Set();
|
|
9
|
+
let c = !1;
|
|
10
|
+
const M = (l) => {
|
|
11
|
+
const m = (T) => {
|
|
12
|
+
var _;
|
|
13
|
+
const s = L.useContext(O) ?? {}, e = ((_ = s == null ? void 0 : s.data) == null ? void 0 : _.google_analytics_code) ?? D.GA_CODE, i = k(), u = f(null), d = f(!1), p = f(!1);
|
|
14
|
+
if (typeof window < "u" && !c && e && e !== "#REACT_APP_GA_CODE#") {
|
|
15
|
+
if (!G.has(e))
|
|
16
|
+
try {
|
|
17
|
+
a.initialize(e), G.add(e), console.log("GA initialized with code:", e);
|
|
18
|
+
} catch (t) {
|
|
19
|
+
console.error("Failed to initialize GA:", t);
|
|
20
|
+
}
|
|
21
|
+
c = !0;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
return E(() => {
|
|
24
|
+
if (typeof window > "u" || !e || e === "#REACT_APP_GA_CODE#" || !c) return;
|
|
25
|
+
const t = i.pathname;
|
|
26
|
+
if (u.current !== t) {
|
|
27
|
+
u.current = t, d.current = !1;
|
|
28
|
+
try {
|
|
29
|
+
const r = C() ? "internal" : "external";
|
|
30
|
+
a.event("page_view", {
|
|
31
|
+
page_path: t,
|
|
32
|
+
traffic_type: r
|
|
33
|
+
}), console.log("GA pageview sent:", { page: t, traffic_type: r });
|
|
34
|
+
} catch (r) {
|
|
35
|
+
console.error("Failed to send pageview:", r);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}, [i.pathname, e]), E(() => {
|
|
39
|
+
if (typeof window > "u" || !e || e === "#REACT_APP_GA_CODE#" || !c || p.current) return;
|
|
40
|
+
const t = C() ? "internal" : "external", r = () => {
|
|
41
|
+
if (d.current) return;
|
|
42
|
+
const n = Math.round(
|
|
43
|
+
window.scrollY / (document.documentElement.scrollHeight - window.innerHeight) * 100
|
|
44
|
+
);
|
|
45
|
+
if (n > 10)
|
|
46
|
+
try {
|
|
47
|
+
a.event("scroll", {
|
|
48
|
+
engagement_type: "scroll",
|
|
49
|
+
scroll_depth: n,
|
|
50
|
+
traffic_type: t
|
|
51
|
+
}), console.log("GA scroll event sent:", { scrollPercentage: n, traffic_type: t }), d.current = !0;
|
|
52
|
+
} catch (o) {
|
|
53
|
+
console.error("Failed to send scroll event:", o);
|
|
54
|
+
}
|
|
55
|
+
}, g = (n) => {
|
|
56
|
+
var A;
|
|
57
|
+
const o = n.target, h = ((A = o.textContent) == null ? void 0 : A.substring(0, 50)) || "", v = o.id || "", y = o.className || "";
|
|
58
|
+
if (!(!h && !v && !y))
|
|
59
|
+
try {
|
|
60
|
+
a.event("element_click", {
|
|
61
|
+
element_id: v,
|
|
62
|
+
element_class: y,
|
|
63
|
+
element_text: h.substring(0, 50),
|
|
64
|
+
traffic_type: t
|
|
65
|
+
});
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
}, x = Date.now(), w = () => {
|
|
69
|
+
const n = Math.round((Date.now() - x) / 1e3);
|
|
70
|
+
if (n > 3)
|
|
71
|
+
try {
|
|
72
|
+
a.event("time_on_page", {
|
|
73
|
+
page_path: i.pathname,
|
|
74
|
+
duration_seconds: n,
|
|
75
|
+
traffic_type: t
|
|
76
|
+
}), console.log("GA time_on_page event sent:", { timeOnPage: n, path: i.pathname });
|
|
77
|
+
} catch (o) {
|
|
78
|
+
console.error("Failed to send time_on_page event:", o);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return window.addEventListener("scroll", r, { passive: !0 }), document.addEventListener("click", g), window.addEventListener("beforeunload", w), p.current = !0, () => {
|
|
82
|
+
window.removeEventListener("scroll", r), document.removeEventListener("click", g), window.removeEventListener("beforeunload", w);
|
|
83
|
+
};
|
|
84
|
+
}, [i.pathname, e]), /* @__PURE__ */ P(l, { ...T });
|
|
85
|
+
};
|
|
86
|
+
return m.displayName = `withTracker(${l.displayName || l.name || "Component"})`, m;
|
|
23
87
|
};
|
|
24
88
|
export {
|
|
25
|
-
|
|
89
|
+
M as withTracker
|
|
26
90
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export declare const withTracker: <T extends WithGoogleAnalyticsProps>(WrappedComponent: React.ComponentType<T>, options?: {}) => (props: T) => React.JSX.Element;
|
|
2
|
+
export declare const withTracker: <P extends Record<string, any>>(WrappedComponent: React.ComponentType<P>) => {
|
|
3
|
+
(props: P): React.JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devgateway/dvz-ui-react",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.16",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"vite-plugin-env-compatible": "^2.0.1",
|
|
123
123
|
"vite-plugin-eslint": "^1.8.1",
|
|
124
124
|
"vite-tsconfig-paths": "^5.1.4",
|
|
125
|
-
"@devgateway/wp-react-lib": "0.
|
|
125
|
+
"@devgateway/wp-react-lib": "0.5.1"
|
|
126
126
|
},
|
|
127
127
|
"peerDependencies": {
|
|
128
128
|
"react": "^18.3.1",
|