@autobusal/common 1.11.0 → 1.13.0
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/Meta.tsx +19 -15
- package/UnderConstruction/UnderConstruction.tsx +4 -27
- package/Viewer/Data.tsx +19 -1
- package/package.json +1 -1
package/Meta.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { useLocation } from 'react-router-dom';
|
|
3
|
-
import
|
|
3
|
+
import { pageview } from '@autobusal/providers/Setup/analytics';
|
|
4
4
|
import { useGetSettings } from '@autobusal/providers/services';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
@@ -124,28 +124,32 @@ const useCanonicalUrl = (explicit?: string): string => {
|
|
|
124
124
|
return explicit ?? `${ window.location.origin }${ location.pathname }`;
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
//
|
|
127
|
+
// A single-page app never reloads, so GTM's page-load trigger fires exactly
|
|
128
|
+
// once per session - every client-side route change after that is invisible
|
|
129
|
+
// unless it is announced. Meta is the one component rendered on nearly every
|
|
130
|
+
// real page (136 call sites across both apps), already tracks the canonical
|
|
131
|
+
// path via useLocation, and mounts fresh on every navigation - the natural
|
|
132
|
+
// place to fire the pageview React Router itself has no dedicated hook for.
|
|
133
|
+
// The 2-3 truly Meta-less pages (a redirect-only auth callback, an
|
|
134
|
+
// invalid-signature bounce) aren't meaningful page views anyway.
|
|
135
|
+
//
|
|
136
|
+
// Edited: Ferjolt Ozuni - Date: 2026-08-01
|
|
137
|
+
// Pushes to the GTM dataLayer rather than calling GA4 directly. The brand's
|
|
138
|
+
// container decides what to do with it, so switching or adding an analytics
|
|
139
|
+
// product is a change in GTM rather than in this file.
|
|
137
140
|
const usePageviewTracking = (path: string, title: string): void => {
|
|
138
141
|
const { data: settings } = useGetSettings();
|
|
139
|
-
|
|
142
|
+
|
|
143
|
+
const container = settings.analytics?.gtm_id;
|
|
140
144
|
|
|
141
145
|
useEffect(() => {
|
|
142
|
-
if (
|
|
146
|
+
if (!container) {
|
|
143
147
|
return;
|
|
144
148
|
}
|
|
145
149
|
|
|
146
|
-
|
|
150
|
+
pageview(path, title);
|
|
147
151
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
148
|
-
}, [
|
|
152
|
+
}, [container, path]);
|
|
149
153
|
};
|
|
150
154
|
|
|
151
155
|
const Meta = ({ title, keywords, description, image, url, type = 'website', noIndex = false, children }: Props): JSX.Element => {
|
|
@@ -23,10 +23,10 @@ interface Props {
|
|
|
23
23
|
* prerendered snapshot may have baked in, so an older "index" directive
|
|
24
24
|
* cannot win by being first in the document.
|
|
25
25
|
*
|
|
26
|
-
* - Google Tag Manager
|
|
27
|
-
*
|
|
28
|
-
* interest
|
|
29
|
-
*
|
|
26
|
+
* - Google Tag Manager still runs, because Providers loads it before this
|
|
27
|
+
* renders - a pre-launch page is exactly when a brand wants to measure
|
|
28
|
+
* interest. It uses the brand's ONE container (admin > Analytics), not a
|
|
29
|
+
* separate id of its own; nothing extra is needed here.
|
|
30
30
|
*/
|
|
31
31
|
const UnderConstruction = ({ t }: Props): JSX.Element => {
|
|
32
32
|
const { data: settings } = useGetSettings();
|
|
@@ -51,29 +51,6 @@ const UnderConstruction = ({ t }: Props): JSX.Element => {
|
|
|
51
51
|
};
|
|
52
52
|
}, []);
|
|
53
53
|
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
const container = construction?.gtm_id;
|
|
56
|
-
|
|
57
|
-
if (!container) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Guard against a double insert - this component can re-render, and two
|
|
62
|
-
// GTM containers on one page double-count everything they measure.
|
|
63
|
-
if (document.getElementById('gtm-container')) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
(window as any).dataLayer = (window as any).dataLayer || [];
|
|
68
|
-
(window as any).dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
|
|
69
|
-
|
|
70
|
-
const script = document.createElement('script');
|
|
71
|
-
script.id = 'gtm-container';
|
|
72
|
-
script.async = true;
|
|
73
|
-
script.src = `https://www.googletagmanager.com/gtm.js?id=${ encodeURIComponent(container) }`;
|
|
74
|
-
document.head.appendChild(script);
|
|
75
|
-
}, [construction?.gtm_id]);
|
|
76
|
-
|
|
77
54
|
const title = construction?.title || t('under_construction.title', { ns: 'common', company });
|
|
78
55
|
|
|
79
56
|
const message = construction?.message || t('under_construction.message', { ns: 'common' });
|
package/Viewer/Data.tsx
CHANGED
|
@@ -32,7 +32,25 @@ const Data = ({ id, item, refs, t, onUpdate }: Props): (JSX.Element | null) => {
|
|
|
32
32
|
|
|
33
33
|
switch (item.type) {
|
|
34
34
|
case 'checkbox':
|
|
35
|
-
|
|
35
|
+
// Edited: Ferjolt Ozuni - Date: 2026-08-01
|
|
36
|
+
// Honour item.onChange, which only 'select' supported before (see
|
|
37
|
+
// Items/Dropdown). Without it a checkbox could not drive which OTHER
|
|
38
|
+
// fields are shown - the caller's handler simply never fired - so a
|
|
39
|
+
// form like "enable analytics, then ask for the container id" had no
|
|
40
|
+
// way to reveal the second field. Reports the CHECKED state rather
|
|
41
|
+
// than the input's value attribute, which is the constant 1 and would
|
|
42
|
+
// tell the caller nothing.
|
|
43
|
+
return (
|
|
44
|
+
<input
|
|
45
|
+
type="checkbox"
|
|
46
|
+
value={ 1 }
|
|
47
|
+
defaultChecked={ Number(item.value) === 1 }
|
|
48
|
+
{ ...refs(item.name, {
|
|
49
|
+
...Validate(String(item.rules), t),
|
|
50
|
+
...(item.onChange ? { onChange: (event: any) => item.onChange!(event.target.checked ? 1 : 0) } : {})
|
|
51
|
+
}) }
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
36
54
|
|
|
37
55
|
case 'checkbox-list':
|
|
38
56
|
case 'checkbox-list-all':
|