-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
_app.tsx
101 lines (100 loc) · 3.34 KB
/
_app.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import { sendPageViewEvent } from '@nrwl/nx-dev/feature-analytics';
import { DefaultSeo } from 'next-seo';
import { AppProps } from 'next/app';
import { useRouter } from 'next/router';
import Script from 'next/script';
import { useEffect } from 'react';
import '../styles/main.css';
export default function CustomApp({
Component,
pageProps,
}: AppProps): JSX.Element {
const router = useRouter();
const gaMeasurementId = 'UA-88380372-10';
useEffect(() => {
const handleRouteChange = (url: URL) =>
sendPageViewEvent({ gaId: gaMeasurementId, path: url.toString() });
router.events.on('routeChangeStart', (url) => handleRouteChange(url));
return () => router.events.off('routeChangeStart', handleRouteChange);
}, [router]);
return (
<>
<DefaultSeo
title="Nx: Smart, Fast and Extensible Build System"
description="Next generation build system with first class monorepo support and powerful integrations."
openGraph={{
url: 'https://nx.dev' + router.asPath,
title: 'Nx: Smart, Fast and Extensible Build System',
description:
'Next generation build system with first class monorepo support and powerful integrations.',
images: [
{
url: 'https://nx.dev/images/nx-media.jpg',
width: 800,
height: 421,
alt: 'Nx: Smart, Fast and Extensible Build System',
type: 'image/jpeg',
},
],
siteName: 'Nx',
type: 'website',
}}
twitter={{
site: '@nxdevtools',
cardType: 'summary_large_image',
}}
/>
<a
id="skip-to-content-link"
href="#main"
tabIndex={0}
className="absolute top-3 left-8 -translate-y-24 rounded-md bg-green-400 px-4 py-2 text-white transition focus:translate-y-0"
>
Skip to content
</a>
<Component {...pageProps} />
{/* Global Site Tag (gtag.js) - Google Analytics */}
<Script
id="gtag-script-dependency"
strategy="afterInteractive"
src={`https://www.googletagmanager.com/gtag/js?id=${gaMeasurementId}`}
/>
<Script
id="gtag-script-loader"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', '${gaMeasurementId}', {
page_path: window.location.pathname,
});
`,
}}
/>
{/* HubSpot Analytics */}
<Script
id="hs-script-loader"
strategy="worker"
src="https://js.hs-scripts.com/2757427.js"
/>
{/* Hotjar Analytics */}
<Script
id="hotjar-script-loader"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
(function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid:2774127,hjsv:6};
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');`,
}}
/>
</>
);
}