@@ -9,6 +9,7 @@ import UserMenu from './UserMenu/UserMenu';
99import { useSession } from 'next-auth/react' ;
1010import { useState } from 'react' ;
1111import {
12+ < << << << HEAD
1213 Bullseye ,
1314 Spinner ,
1415 Masthead ,
@@ -32,6 +33,14 @@ import {
3233import { BarsIcon } from '@patternfly/react-icons' ;
3334import ThemePreference from '@/components/ThemePreference/ThemePreference' ;
3435import '../styles/globals.scss' ;
36+ = === ===
37+ PROD_DEPLOYMENT_ENVIRONMENT ,
38+ PROD_METRICS_WEBSITE_ID ,
39+ QA_DEPLOYMENT_ENVIRONMENT ,
40+ QA_METRICS_WEBSITE_ID ,
41+ UMAMI_METRICS_SCRIPT_SOURCE
42+ } from '../types/const' ;
43+ > >>> >>> 1 d9ee15 ( add umami tracking codes via script tags )
3544
3645interface IAppLayout {
3746 children : React . ReactNode ;
@@ -50,6 +59,31 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children }) => {
5059 const router = useRouter ( ) ;
5160 const pathname = usePathname ( ) ;
5261
62+ React . useEffect ( ( ) => {
63+ if ( typeof window === 'undefined' ) return ;
64+
65+ const hostname = window . location . hostname ;
66+ const isProd = hostname === PROD_DEPLOYMENT_ENVIRONMENT ;
67+ const isQA = hostname === QA_DEPLOYMENT_ENVIRONMENT ;
68+
69+ const scriptSource = isQA || isProd ? UMAMI_METRICS_SCRIPT_SOURCE : '' ;
70+ const websiteId = isProd ? PROD_METRICS_WEBSITE_ID : isQA ? QA_METRICS_WEBSITE_ID : null ;
71+
72+ if ( scriptSource && websiteId ) {
73+ const script = document . createElement ( 'script' ) ;
74+ script . async = true ;
75+ script . defer = true ;
76+ script . dataset . websiteId = websiteId ;
77+ script . src = scriptSource ;
78+
79+ document . head . appendChild ( script ) ;
80+
81+ return ( ) => {
82+ document . head . removeChild ( script ) ;
83+ } ;
84+ }
85+ } , [ ] ) ;
86+
5387 React . useEffect ( ( ) => {
5488 // Fetch the experimental feature flag
5589 const fetchExperimentalFeature = async ( ) => {
0 commit comments