@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"),g=require("../conf/index.js"),C=require("@devgateway/wp-react-lib"),_=require("./internalTrafficUtils.js"),u=t.useRef(new Set),A=(f,R={})=>l=>{var c;const n=t.useContext(C.SettingsContext)??{},e=((c=n==null?void 0:n.data)==null?void 0:c.google_analytics_code)??g.Config.GA_CODE,r=p.useLocation(),i=t.useRef(!1);return t.useEffect(()=>{e&&e!=="#REACT_APP_GA_CODE#"&&!i.current&&(u.current.has(e)||(s.initialize(e),u.current.add(e),console.log("GA initialized with code:",e)),i.current=!0)},[e]),t.useEffect(()=>{if(e&&e!=="#REACT_APP_GA_CODE#"&&i.current){const o=r.pathname,a=_.isInternalTrafficEnabled()?"internal":"external";s.send({hitType:"pageview",page:o,traffic_type:a}),console.log("GA pageview sent:",{page:o,traffic_type:a})}},[r.pathname,e]),d.jsx(f,{...l})};exports.withTracker=A;
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 u } from "react/jsx-runtime";
2
- import C, { useRef as p, useEffect as c } from "react";
3
- import f from "react-ga4";
4
- import { useLocation as _ } from "react-router";
5
- import { Config as d } from "../conf/index.js";
6
- import { SettingsContext as A } from "@devgateway/wp-react-lib";
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 s = p(/* @__PURE__ */ new Set()), z = (l, h = {}) => (m) => {
8
+ const f = /* @__PURE__ */ new Set(), z = (p, h = {}) => (l) => {
9
9
  var n;
10
- const e = C.useContext(A) ?? {}, t = ((n = e == null ? void 0 : e.data) == null ? void 0 : n.google_analytics_code) ?? d.GA_CODE, i = _(), o = p(!1);
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 && (s.current.has(t) || (f.initialize(t), s.current.add(t), console.log("GA initialized with code:", t)), o.current = !0);
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
- f.send({
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__ */ u(l, { ...m });
22
+ }, [i.pathname, t]), /* @__PURE__ */ m(p, { ...l });
23
23
  };
24
24
  export {
25
25
  z as withTracker
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devgateway/dvz-ui-react",
3
- "version": "1.6.13",
3
+ "version": "1.6.14",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",