@devgateway/dvz-ui-react 1.6.12 → 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.
- package/dist/cjs/conf/index.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/tracker/InternalTrafficToggle.js +1 -0
- package/dist/cjs/tracker/index.js +1 -1
- package/dist/cjs/tracker/internalTrafficUtils.js +1 -0
- package/dist/cjs/tracker/withGoogleAnalytics.js +1 -1
- package/dist/esm/conf/index.js +2 -1
- package/dist/esm/index.js +62 -55
- package/dist/esm/tracker/InternalTrafficToggle.js +76 -0
- package/dist/esm/tracker/index.js +9 -2
- package/dist/esm/tracker/internalTrafficUtils.js +23 -0
- package/dist/esm/tracker/withGoogleAnalytics.js +20 -15
- package/dist/types/conf/index.d.ts +1 -0
- package/dist/types/tracker/InternalTrafficToggle.d.ts +6 -0
- package/dist/types/tracker/index.d.ts +2 -0
- package/dist/types/tracker/internalTrafficUtils.d.ts +24 -0
- package/package.json +1 -1
package/dist/cjs/conf/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _={REACT_APP_WP_API:process.env.VITE_REACT_APP_WP_API??"/wp/wp-json",REACT_APP_API_ROOT:process.env.VITE_REACT_APP_API_ROOT??null,GA_CODE:process.env.VITE_REACT_APP_GA_CODE??"",DEFAULT_LOCALE:process.env.VITE_REACT_APP_DEFAULT_LOCALE??"en"};exports.Config=_;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _={REACT_APP_WP_API:process.env.VITE_REACT_APP_WP_API??"/wp/wp-json",REACT_APP_API_ROOT:process.env.VITE_REACT_APP_API_ROOT??null,GA_CODE:process.env.VITE_REACT_APP_GA_CODE??"",DEFAULT_LOCALE:process.env.VITE_REACT_APP_DEFAULT_LOCALE??"en",INTERNAL_GA_TOKEN:process.env.VITE_INTERNAL_GA_TOKEN??""};exports.Config=_;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./embeddable/index.js"),s=require("./conf/index.js"),u=require("./layout/ResponsiveContainer.js"),l=require("./layout/ScrollTop.js"),c=require("./layout/containers/PreviewPageContainer.js"),d=require("./layout/containers/PreviewTypeContainer.js"),p=require("./layout/containers/SlugContainer.js"),f=require("./layout/containers/SlugPostContainer.js"),m=require("./layout/Customizer.js"),T=require("./layout/Layout.js"),q=require("./layout/PreviewComponent.js"),C=require("./layout/Favicon.js"),g=require("./layout/SSRFavicon.js"),S=require("./layout/Loading.js"),P=require("./layout/CustomSemanticSearch.js"),h=require("./layout/Header.js"),I=require("./layout/SearchControl.js"),v=require("./layout/LangSwitcher.js"),y=require("./layout/Footer.js"),A=require("./layout/ClassicHeader.js"),H=require("./layout/FlexWrapDetector.js"),w=require("./layout/FloatingMenuHeader.js"),R=require("./tracker/withGoogleAnalytics.js"),n=require("./tracker/internalTrafficUtils.js"),k=require("./tracker/InternalTrafficToggle.js"),x=require("./redux/store.js"),a=require("./redux/hooks.js"),o=require("./lib/react-intl-redux/index.js"),E=require("./lib/redux-immutable/index.js"),F=require("./translations/en.json.js"),M=require("./translations/fr.json.js"),O=require("./translations/af.json.js"),b=require("./translations/am.json.js"),L=require("./countries.js"),r=require("./utils/data.js"),i=require("./utils/AppMedia.js"),e=require("./utils/semanticUtils.js"),N=require("./lib/react-intl-redux/providers/Provider.js"),U=require("./lib/react-intl-redux/providers/IntlProvider.js");exports.components=t.components;exports.customizer=t.customizer;exports.getComponentByNameIgnoreCase=t.getComponentByNameIgnoreCase;exports.reducers=t.reducers;exports.Config=s.Config;exports.ResponsiveContainer=u.default;exports.ScrollToTop=l.default;exports.PreviewPageContainer=c.default;exports.PreviewTypeContainer=d.default;exports.SlugContainer=p.default;exports.SlugPostContainer=f.default;exports.CustomizerWrapper=m.CustomizerWrapper;exports.RootLayout=T.default;exports.PreviewComponent=q.default;exports.Favicon=C.default;exports.SSRFavicon=g.default;exports.Loading=S.default;exports.CustomSemanticSearch=P.default;exports.Header=h.default;exports.SearchControl=I.default;exports.LangSwitcher=v.default;exports.Footer=y.default;exports.ClassicHeader=A.default;exports.FlexWrapDetector=H.default;exports.FloatingMenuHeader=w.default;exports.withTracker=R.withTracker;exports.clearInternalTrafficCookie=n.clearInternalTrafficCookie;exports.isInternalTrafficEnabled=n.isInternalTrafficEnabled;exports.setInternalTrafficCookie=n.setInternalTrafficCookie;exports.validateToken=n.validateToken;exports.InternalTrafficToggle=k.default;exports.store=x.store;exports.useAppDispatch=a.useAppDispatch;exports.useAppSelector=a.useAppSelector;exports.UPDATE=o.UPDATE;exports.initialState=o.initialState;exports.intlReducer=o.intlReducer;exports.updateIntl=o.updateIntl;exports.combineReducers=E.combineReducers;exports.englishTranslations=F;exports.frenchTranslations=M;exports.afrikaansTranslations=O;exports.amharicTranslations=b;exports.COUNTRY_OPTIONS=L.COUNTRY_OPTIONS;exports.decodeHtmlEntitiesToHtml=r.decodeHtmlEntitiesToHtml;exports.decodeHtmlEntitiesToText=r.decodeHtmlEntitiesToText;exports.stringToArray=r.stringToArray;exports.toBoolean=r.toBoolean;exports.toNumber=r.toNumber;exports.uriStringToArray=r.uriStringToArray;exports.Media=i.Media;exports.MediaContextProvider=i.MediaContextProvider;exports.mediaStyle=i.mediaStyle;exports.getUnhandledProps=e.getUnhandledProps;exports.htmlImageProps=e.htmlImageProps;exports.htmlInputAttrs=e.htmlInputAttrs;exports.htmlInputEvents=e.htmlInputEvents;exports.htmlInputProps=e.htmlInputProps;exports.partitionHTMLProps=e.partitionHTMLProps;exports.useKeyOnly=e.useKeyOnly;exports.useValueAndKey=e.useValueAndKey;exports.Provider=N.default;exports.IntlProvider=U.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),l=require("react"),f=require("react-router"),g=require("./internalTrafficUtils.js"),x=({token:c})=>{const[a]=f.useSearchParams(),d=f.useNavigate(),[e,s]=l.useState("validating"),[u,n]=l.useState("Processing...");l.useEffect(()=>{const o=a.get("enable"),v=a.get("k");if(!g.validateToken(v,c)){s("error"),n("Invalid or missing token. Access denied."),console.error("Invalid token provided for internal traffic toggle");return}if(o!=="0"&&o!=="1"){s("error"),n("Invalid enable parameter. Use ?enable=0 or ?enable=1"),console.error("Invalid enable parameter:",o);return}try{const r=o==="1";g.setInternalTrafficCookie(r),s("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(()=>{d("/")},3e3)}catch(r){s("error"),n(`Error: ${r instanceof Error?r.message:"Unknown error"}`),console.error("Error setting internal traffic cookie:",r)}},[a,c,d]);const b={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"},m=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"},p={fontSize:"1.5rem",fontWeight:"600",margin:"0 0 1rem 0",color:e==="success"?"#059669":e==="error"?"#dc2626":"#1f2937"},y={fontSize:"1rem",margin:"1rem 0",color:e==="success"?"#047857":e==="error"?"#991b1b":"#374151",lineHeight:"1.5"},S={fontSize:"0.875rem",color:"#6b7280",marginTop:"1.5rem",fontStyle:"italic"};return t.jsx("div",{style:b,children:t.jsxs("div",{style:m,children:[t.jsx("h1",{style:p,children:e==="success"?"Success":e==="error"?"Error":"Processing"}),t.jsx("p",{style:y,children:u}),e==="success"&&t.jsx("p",{style:S,children:"Redirecting to home page in 3 seconds..."})]})})};exports.default=x;
|
|
@@ -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("./withGoogleAnalytics.js"),e=require("./internalTrafficUtils.js"),a=require("./InternalTrafficToggle.js");exports.withTracker=r.withTracker;exports.clearInternalTrafficCookie=e.clearInternalTrafficCookie;exports.isInternalTrafficEnabled=e.isInternalTrafficEnabled;exports.setInternalTrafficCookie=e.setInternalTrafficCookie;exports.validateToken=e.validateToken;exports.InternalTrafficToggle=a.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o="_ga_internal_traffic",i=365*24*60*60,c=e=>{if(typeof document>"u")return;const t=e?"1":"0",n="/";document.cookie=`${o}=${t}; max-age=${i}; path=${n}; SameSite=Lax`,console.log(`Internal traffic cookie ${e?"enabled":"disabled"}`)},r=()=>{if(typeof document>"u")return!1;const e=document.cookie.split(";");for(const t of e){const[n,a]=t.trim().split("=");if(n===o)return a==="1"}return!1},f=()=>{typeof document>"u"||(document.cookie=`${o}=; max-age=0; path=/; SameSite=Lax`,console.log("Internal traffic cookie cleared"))},l=(e,t)=>e?e===t:!1;exports.clearInternalTrafficCookie=f;exports.isInternalTrafficEnabled=r;exports.setInternalTrafficCookie=c;exports.validateToken=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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=_;
|
package/dist/esm/conf/index.js
CHANGED
|
@@ -2,7 +2,8 @@ const _ = {
|
|
|
2
2
|
REACT_APP_WP_API: process.env.VITE_REACT_APP_WP_API ?? "/wp/wp-json",
|
|
3
3
|
REACT_APP_API_ROOT: process.env.VITE_REACT_APP_API_ROOT ?? null,
|
|
4
4
|
GA_CODE: process.env.VITE_REACT_APP_GA_CODE ?? "",
|
|
5
|
-
DEFAULT_LOCALE: process.env.VITE_REACT_APP_DEFAULT_LOCALE ?? "en"
|
|
5
|
+
DEFAULT_LOCALE: process.env.VITE_REACT_APP_DEFAULT_LOCALE ?? "en",
|
|
6
|
+
INTERNAL_GA_TOKEN: process.env.VITE_INTERNAL_GA_TOKEN ?? ""
|
|
6
7
|
};
|
|
7
8
|
export {
|
|
8
9
|
_ as Config
|
package/dist/esm/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { components as
|
|
1
|
+
import { components as n, customizer as s, getComponentByNameIgnoreCase as p, reducers as m } from "./embeddable/index.js";
|
|
2
2
|
import { Config as l } from "./conf/index.js";
|
|
3
3
|
import { default as u } from "./layout/ResponsiveContainer.js";
|
|
4
4
|
import { default as c } from "./layout/ScrollTop.js";
|
|
5
5
|
import { default as C } from "./layout/containers/PreviewPageContainer.js";
|
|
6
6
|
import { default as P } from "./layout/containers/PreviewTypeContainer.js";
|
|
7
7
|
import { default as h } from "./layout/containers/SlugContainer.js";
|
|
8
|
-
import { default as
|
|
8
|
+
import { default as v } from "./layout/containers/SlugPostContainer.js";
|
|
9
9
|
import { CustomizerWrapper as A } from "./layout/Customizer.js";
|
|
10
10
|
import { default as R } from "./layout/Layout.js";
|
|
11
|
-
import { default as
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
11
|
+
import { default as w } from "./layout/PreviewComponent.js";
|
|
12
|
+
import { default as F } from "./layout/Favicon.js";
|
|
13
|
+
import { default as M } from "./layout/SSRFavicon.js";
|
|
14
|
+
import { default as O } from "./layout/Loading.js";
|
|
15
|
+
import { default as D } from "./layout/CustomSemanticSearch.js";
|
|
16
16
|
import { default as z } from "./layout/Header.js";
|
|
17
17
|
import { default as K } from "./layout/SearchControl.js";
|
|
18
18
|
import { default as V } from "./layout/LangSwitcher.js";
|
|
@@ -21,77 +21,84 @@ import { default as q } from "./layout/ClassicHeader.js";
|
|
|
21
21
|
import { default as J } from "./layout/FlexWrapDetector.js";
|
|
22
22
|
import { default as X } from "./layout/FloatingMenuHeader.js";
|
|
23
23
|
import { withTracker as $ } from "./tracker/withGoogleAnalytics.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
24
|
+
import { clearInternalTrafficCookie as re, isInternalTrafficEnabled as oe, setInternalTrafficCookie as te, validateToken as ae } from "./tracker/internalTrafficUtils.js";
|
|
25
|
+
import { default as ne } from "./tracker/InternalTrafficToggle.js";
|
|
26
|
+
import { store as pe } from "./redux/store.js";
|
|
27
|
+
import { useAppDispatch as ie, useAppSelector as le } from "./redux/hooks.js";
|
|
28
|
+
import { UPDATE as ue, initialState as xe, intlReducer as ce, updateIntl as Te } from "./lib/react-intl-redux/index.js";
|
|
29
|
+
import { combineReducers as ge } from "./lib/redux-immutable/index.js";
|
|
28
30
|
import * as e from "./translations/en.json.js";
|
|
29
31
|
import * as r from "./translations/fr.json.js";
|
|
30
32
|
import * as o from "./translations/af.json.js";
|
|
31
33
|
import * as t from "./translations/am.json.js";
|
|
32
|
-
import { COUNTRY_OPTIONS as
|
|
33
|
-
import { decodeHtmlEntitiesToHtml as
|
|
34
|
-
import { Media as
|
|
35
|
-
import { getUnhandledProps as
|
|
36
|
-
import { default as
|
|
37
|
-
import { default as
|
|
34
|
+
import { COUNTRY_OPTIONS as Se } from "./countries.js";
|
|
35
|
+
import { decodeHtmlEntitiesToHtml as Ie, decodeHtmlEntitiesToText as ve, stringToArray as ye, toBoolean as Ae, toNumber as He, uriStringToArray as Re } from "./utils/data.js";
|
|
36
|
+
import { Media as we, MediaContextProvider as Ee, mediaStyle as Fe } from "./utils/AppMedia.js";
|
|
37
|
+
import { getUnhandledProps as Me, htmlImageProps as Ne, htmlInputAttrs as Oe, htmlInputEvents as be, htmlInputProps as De, partitionHTMLProps as Ue, useKeyOnly as ze, useValueAndKey as Be } from "./utils/semanticUtils.js";
|
|
38
|
+
import { default as We } from "./lib/react-intl-redux/providers/Provider.js";
|
|
39
|
+
import { default as Ye } from "./lib/react-intl-redux/providers/IntlProvider.js";
|
|
38
40
|
export {
|
|
39
|
-
|
|
41
|
+
Se as COUNTRY_OPTIONS,
|
|
40
42
|
q as ClassicHeader,
|
|
41
43
|
l as Config,
|
|
42
|
-
|
|
44
|
+
D as CustomSemanticSearch,
|
|
43
45
|
A as CustomizerWrapper,
|
|
44
|
-
|
|
46
|
+
F as Favicon,
|
|
45
47
|
J as FlexWrapDetector,
|
|
46
48
|
X as FloatingMenuHeader,
|
|
47
49
|
_ as Footer,
|
|
48
50
|
z as Header,
|
|
49
|
-
|
|
51
|
+
ne as InternalTrafficToggle,
|
|
52
|
+
Ye as IntlProvider,
|
|
50
53
|
V as LangSwitcher,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
O as Loading,
|
|
55
|
+
we as Media,
|
|
56
|
+
Ee as MediaContextProvider,
|
|
57
|
+
w as PreviewComponent,
|
|
55
58
|
C as PreviewPageContainer,
|
|
56
59
|
P as PreviewTypeContainer,
|
|
57
|
-
|
|
60
|
+
We as Provider,
|
|
58
61
|
u as ResponsiveContainer,
|
|
59
62
|
R as RootLayout,
|
|
60
|
-
|
|
63
|
+
M as SSRFavicon,
|
|
61
64
|
c as ScrollToTop,
|
|
62
65
|
K as SearchControl,
|
|
63
66
|
h as SlugContainer,
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
v as SlugPostContainer,
|
|
68
|
+
ue as UPDATE,
|
|
66
69
|
o as afrikaansTranslations,
|
|
67
70
|
t as amharicTranslations,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
re as clearInternalTrafficCookie,
|
|
72
|
+
ge as combineReducers,
|
|
73
|
+
n as components,
|
|
74
|
+
s as customizer,
|
|
75
|
+
Ie as decodeHtmlEntitiesToHtml,
|
|
76
|
+
ve as decodeHtmlEntitiesToText,
|
|
73
77
|
e as englishTranslations,
|
|
74
78
|
r as frenchTranslations,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
79
|
+
p as getComponentByNameIgnoreCase,
|
|
80
|
+
Me as getUnhandledProps,
|
|
81
|
+
Ne as htmlImageProps,
|
|
82
|
+
Oe as htmlInputAttrs,
|
|
83
|
+
be as htmlInputEvents,
|
|
84
|
+
De as htmlInputProps,
|
|
85
|
+
xe as initialState,
|
|
86
|
+
ce as intlReducer,
|
|
87
|
+
oe as isInternalTrafficEnabled,
|
|
88
|
+
Fe as mediaStyle,
|
|
89
|
+
Ue as partitionHTMLProps,
|
|
90
|
+
m as reducers,
|
|
91
|
+
te as setInternalTrafficCookie,
|
|
92
|
+
pe as store,
|
|
93
|
+
ye as stringToArray,
|
|
94
|
+
Ae as toBoolean,
|
|
95
|
+
He as toNumber,
|
|
96
|
+
Te as updateIntl,
|
|
97
|
+
Re as uriStringToArray,
|
|
98
|
+
ie as useAppDispatch,
|
|
99
|
+
le as useAppSelector,
|
|
100
|
+
ze as useKeyOnly,
|
|
101
|
+
Be as useValueAndKey,
|
|
102
|
+
ae as validateToken,
|
|
96
103
|
$ as withTracker
|
|
97
104
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as n, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useEffect as p } from "react";
|
|
3
|
+
import { useSearchParams as y, useNavigate as S } from "react-router";
|
|
4
|
+
import { validateToken as h, setInternalTrafficCookie as v } from "./internalTrafficUtils.js";
|
|
5
|
+
const w = ({ token: l }) => {
|
|
6
|
+
const [a] = y(), c = S(), [e, s] = d("validating"), [f, t] = d("Processing...");
|
|
7
|
+
p(() => {
|
|
8
|
+
const o = a.get("enable"), b = a.get("k");
|
|
9
|
+
if (!h(b, l)) {
|
|
10
|
+
s("error"), t("Invalid or missing token. Access denied."), console.error("Invalid token provided for internal traffic toggle");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (o !== "0" && o !== "1") {
|
|
14
|
+
s("error"), t("Invalid enable parameter. Use ?enable=0 or ?enable=1"), console.error("Invalid enable parameter:", o);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const r = o === "1";
|
|
19
|
+
v(r), s("success"), t(
|
|
20
|
+
r ? "✓ Internal traffic enabled. GA4 events will be tagged as internal." : "✓ Internal traffic disabled. GA4 events will be tagged as external."
|
|
21
|
+
), console.log(`Internal traffic ${r ? "enabled" : "disabled"} successfully`), setTimeout(() => {
|
|
22
|
+
c("/");
|
|
23
|
+
}, 3e3);
|
|
24
|
+
} catch (r) {
|
|
25
|
+
s("error"), t(`Error: ${r instanceof Error ? r.message : "Unknown error"}`), console.error("Error setting internal traffic cookie:", r);
|
|
26
|
+
}
|
|
27
|
+
}, [a, l, c]);
|
|
28
|
+
const g = {
|
|
29
|
+
display: "flex",
|
|
30
|
+
justifyContent: "center",
|
|
31
|
+
alignItems: "center",
|
|
32
|
+
minHeight: "100vh",
|
|
33
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
|
|
34
|
+
}, i = {
|
|
35
|
+
textAlign: "center",
|
|
36
|
+
padding: "2rem",
|
|
37
|
+
borderRadius: "8px",
|
|
38
|
+
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)",
|
|
39
|
+
maxWidth: "500px"
|
|
40
|
+
}, m = e === "success" ? {
|
|
41
|
+
...i,
|
|
42
|
+
backgroundColor: "#f0f9ff",
|
|
43
|
+
borderLeft: "4px solid #10b981"
|
|
44
|
+
} : e === "error" ? {
|
|
45
|
+
...i,
|
|
46
|
+
backgroundColor: "#fef2f2",
|
|
47
|
+
borderLeft: "4px solid #ef4444"
|
|
48
|
+
} : {
|
|
49
|
+
...i,
|
|
50
|
+
backgroundColor: "#f3f4f6",
|
|
51
|
+
borderLeft: "4px solid #3b82f6"
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ n("div", { style: g, children: /* @__PURE__ */ u("div", { style: m, children: [
|
|
54
|
+
/* @__PURE__ */ n("h1", { style: {
|
|
55
|
+
fontSize: "1.5rem",
|
|
56
|
+
fontWeight: "600",
|
|
57
|
+
margin: "0 0 1rem 0",
|
|
58
|
+
color: e === "success" ? "#059669" : e === "error" ? "#dc2626" : "#1f2937"
|
|
59
|
+
}, children: e === "success" ? "Success" : e === "error" ? "Error" : "Processing" }),
|
|
60
|
+
/* @__PURE__ */ n("p", { style: {
|
|
61
|
+
fontSize: "1rem",
|
|
62
|
+
margin: "1rem 0",
|
|
63
|
+
color: e === "success" ? "#047857" : e === "error" ? "#991b1b" : "#374151",
|
|
64
|
+
lineHeight: "1.5"
|
|
65
|
+
}, children: f }),
|
|
66
|
+
e === "success" && /* @__PURE__ */ n("p", { style: {
|
|
67
|
+
fontSize: "0.875rem",
|
|
68
|
+
color: "#6b7280",
|
|
69
|
+
marginTop: "1.5rem",
|
|
70
|
+
fontStyle: "italic"
|
|
71
|
+
}, children: "Redirecting to home page in 3 seconds..." })
|
|
72
|
+
] }) });
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
w as default
|
|
76
|
+
};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { withTracker as
|
|
1
|
+
import { withTracker as a } from "./withGoogleAnalytics.js";
|
|
2
|
+
import { clearInternalTrafficCookie as o, isInternalTrafficEnabled as t, setInternalTrafficCookie as n, validateToken as i } from "./internalTrafficUtils.js";
|
|
3
|
+
import { default as T } from "./InternalTrafficToggle.js";
|
|
2
4
|
export {
|
|
3
|
-
|
|
5
|
+
T as InternalTrafficToggle,
|
|
6
|
+
o as clearInternalTrafficCookie,
|
|
7
|
+
t as isInternalTrafficEnabled,
|
|
8
|
+
n as setInternalTrafficCookie,
|
|
9
|
+
i as validateToken,
|
|
10
|
+
a as withTracker
|
|
4
11
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const o = "_ga_internal_traffic";
|
|
2
|
+
const c = (e) => {
|
|
3
|
+
if (typeof document > "u") return;
|
|
4
|
+
const t = e ? "1" : "0", n = "/";
|
|
5
|
+
document.cookie = `${o}=${t}; max-age=31536000; path=${n}; SameSite=Lax`, console.log(`Internal traffic cookie ${e ? "enabled" : "disabled"}`);
|
|
6
|
+
}, i = () => {
|
|
7
|
+
if (typeof document > "u") return !1;
|
|
8
|
+
const e = document.cookie.split(";");
|
|
9
|
+
for (const t of e) {
|
|
10
|
+
const [n, a] = t.trim().split("=");
|
|
11
|
+
if (n === o)
|
|
12
|
+
return a === "1";
|
|
13
|
+
}
|
|
14
|
+
return !1;
|
|
15
|
+
}, r = () => {
|
|
16
|
+
typeof document > "u" || (document.cookie = `${o}=; max-age=0; path=/; SameSite=Lax`, console.log("Internal traffic cookie cleared"));
|
|
17
|
+
}, f = (e, t) => e ? e === t : !1;
|
|
18
|
+
export {
|
|
19
|
+
r as clearInternalTrafficCookie,
|
|
20
|
+
i as isInternalTrafficEnabled,
|
|
21
|
+
c as setInternalTrafficCookie,
|
|
22
|
+
f as validateToken
|
|
23
|
+
};
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useLocation as
|
|
5
|
-
import { Config as
|
|
6
|
-
import { SettingsContext as
|
|
7
|
-
|
|
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
|
+
import { isInternalTrafficEnabled as g } from "./internalTrafficUtils.js";
|
|
8
|
+
const f = /* @__PURE__ */ new Set(), z = (p, h = {}) => (l) => {
|
|
8
9
|
var n;
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (t) {
|
|
14
|
-
const
|
|
15
|
-
|
|
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
|
+
return c(() => {
|
|
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
|
+
}, [t]), c(() => {
|
|
14
|
+
if (t && t !== "#REACT_APP_GA_CODE#" && o.current) {
|
|
15
|
+
const r = i.pathname, a = g() ? "internal" : "external";
|
|
16
|
+
s.send({
|
|
17
|
+
hitType: "pageview",
|
|
18
|
+
page: r,
|
|
19
|
+
traffic_type: a
|
|
20
|
+
}), console.log("GA pageview sent:", { page: r, traffic_type: a });
|
|
16
21
|
}
|
|
17
|
-
}, [
|
|
22
|
+
}, [i.pathname, t]), /* @__PURE__ */ m(p, { ...l });
|
|
18
23
|
};
|
|
19
24
|
export {
|
|
20
|
-
|
|
25
|
+
z as withTracker
|
|
21
26
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for managing internal traffic detection via first-party cookies
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Set a first-party cookie to mark this session as internal traffic
|
|
6
|
+
* @param enable - Whether to enable (true) or disable (false) internal traffic tracking
|
|
7
|
+
*/
|
|
8
|
+
export declare const setInternalTrafficCookie: (enable: boolean) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Check if internal traffic cookie is enabled
|
|
11
|
+
* @returns true if the internal traffic cookie is set to '1', false otherwise
|
|
12
|
+
*/
|
|
13
|
+
export declare const isInternalTrafficEnabled: () => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Clear the internal traffic cookie
|
|
16
|
+
*/
|
|
17
|
+
export declare const clearInternalTrafficCookie: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Validate the token against the expected value
|
|
20
|
+
* @param providedToken - The token from query params
|
|
21
|
+
* @param expectedToken - The expected token from environment
|
|
22
|
+
* @returns true if tokens match, false otherwise
|
|
23
|
+
*/
|
|
24
|
+
export declare const validateToken: (providedToken: string | null, expectedToken: string) => boolean;
|