diff --git a/components/analytics/analytics.js b/components/analytics/analytics.js new file mode 100644 index 0000000000..2f0d90bdf0 --- /dev/null +++ b/components/analytics/analytics.js @@ -0,0 +1,45 @@ +import { useRouter } from 'next/router'; +import Script from 'next/script'; +import React, { useEffect } from 'react'; + +export const GTagManager = () => { + const router = useRouter(); + + useEffect(() => { + const handleRouteChange = (url) => { + pageview(url); + }; + + router.events.on('routeChangeComplete', handleRouteChange); + + return () => { + router.events.off('routeChangeComplete', handleRouteChange); + }; + }, [router.events]); + + useEffect(() => { + pageview(router.pathname); + }, []); + + const pageview = (url) => { + // eslint-disable-next-line no-console + window.gtag('config', 'G-FZJEC89ZVF', { + page_path: url + }); + }; + + return ( + <> + + + ); +}; diff --git a/components/lib/organizationchart/OrganizationChartBase.js b/components/lib/organizationchart/OrganizationChartBase.js index b44ef9b6ff..81098c79b2 100644 --- a/components/lib/organizationchart/OrganizationChartBase.js +++ b/components/lib/organizationchart/OrganizationChartBase.js @@ -71,7 +71,7 @@ const classes = { nodes: 'p-organizationchart-nodes', lines: 'p-organizationchart-lines', lineLeft: ({ index }) => classNames('p-organizationchart-line-left', { 'p-organizationchart-line-top': index !== 0 }), - lineRight: ({ index }) => classNames('p-organizationchart-line-right', { 'p-organizationchart-line-top': index !== nodeChildLength - 1 }), + lineRight: ({ index, nodeChildLength }) => classNames('p-organizationchart-line-right', { 'p-organizationchart-line-top': index !== nodeChildLength - 1 }), lineDown: 'p-organizationchart-line-down', nodeTogglerIcon: 'p-node-toggler-icon', nodeToggler: 'p-node-toggler' diff --git a/components/lib/organizationchart/OrganizationChartNode.js b/components/lib/organizationchart/OrganizationChartNode.js index 67f9c853a1..f375cedbc2 100644 --- a/components/lib/organizationchart/OrganizationChartNode.js +++ b/components/lib/organizationchart/OrganizationChartNode.js @@ -119,7 +119,7 @@ export const OrganizationChartNode = React.memo((props) => { ); const lineRightProps = mergeProps( { - className: cx('lineRight', { index }) + className: cx('lineRight', { index, nodeChildLength }) }, getNodePTOptions(index !== nodeChildLength - 1, 'lineRight') ); diff --git a/pages/_app.js b/pages/_app.js index 917e242f6f..80cb030dea 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -7,12 +7,11 @@ import '../styles/layout/layout.scss'; // prettier-ignore import '../styles/primereact.css'; // prettier-ignore -import { useRouter } from 'next/router'; -import Script from 'next/script'; import PrimeReact from '../components/lib/api/Api'; import { PrimeReactContext, PrimeReactProvider } from '../components/lib/api/PrimeReactContext'; import AnnouncementData from '../data/news.json'; import '../styles/demo/demo.scss'; +import { GTagManager } from '../components/analytics/analytics'; function Main({ component: Component }) { const [dark, setDark] = useState(false); @@ -22,31 +21,7 @@ function Main({ component: Component }) { const announcement = useRef(AnnouncementData); const context = useContext(PrimeReactContext); - const router = useRouter(); - useEffect(() => { - const handleRouteChange = (url) => { - pageview(url); - }; - - router.events.on('routeChangeComplete', handleRouteChange); - - return () => { - router.events.off('routeChangeComplete', handleRouteChange); - }; - }, [router.events]); - - const pageview = (url) => { - // eslint-disable-next-line no-console - console.log(url); - window.gtag('config', 'G-FZJEC89ZVF', { - page_path: url - }); - }; - - useEffect(() => { - pageview(router.pathname); - const itemString = localStorage.getItem(storageKey); if (itemString) { @@ -122,18 +97,11 @@ function Main({ component: Component }) { } export default function MyApp({ Component }) { + const isProduction = process.env.NODE_ENV === 'production'; + return ( <> - + {isProduction && }