@hanzo/ui 0.5.17 → 0.5.20
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/next/analytics/fpixel.ts
CHANGED
package/next/root-layout.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import Header from '../common/header'
|
|
|
4
4
|
import type { SiteDef } from '../types'
|
|
5
5
|
import getAppRouterBodyFontClasses from './get-app-router-font-classes'
|
|
6
6
|
import { FacebookPixelHead, FacebookPixel } from './analytics/pixel-analytics'
|
|
7
|
-
import { GoogleAnalytics
|
|
7
|
+
import { GoogleAnalytics } from '@next/third-parties/google'
|
|
8
8
|
|
|
9
9
|
// Next 14: https://nextjs.org/docs/app/building-your-application/upgrading/codemods#use-viewport-export
|
|
10
10
|
const viewport = {
|
|
@@ -42,11 +42,10 @@ const RootLayout: React.FC<PropsWithChildren & {
|
|
|
42
42
|
{/* https://stackoverflow.com/a/75716588/11645689 */ }
|
|
43
43
|
<base target='_blank' />
|
|
44
44
|
<FacebookPixelHead/>
|
|
45
|
-
<GoogleAnalyticsHead/>
|
|
46
45
|
</head>
|
|
47
46
|
<body className={bodyClasses}>
|
|
48
47
|
<FacebookPixel />
|
|
49
|
-
<GoogleAnalytics />
|
|
48
|
+
<GoogleAnalytics gaId={process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID} />
|
|
50
49
|
{header && <Header siteDef={siteDef}/>}
|
|
51
50
|
{children}
|
|
52
51
|
</body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/ui",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.20",
|
|
4
4
|
"description": "Library that contains shared UI primitives, support for a common design system, and other boilerplate support.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@hookform/resolvers": "^3.3.2",
|
|
47
|
+
"@next/third-parties": "^14.1.0",
|
|
47
48
|
"@radix-ui/react-accordion": "^1.1.2",
|
|
48
49
|
"@radix-ui/react-avatar": "^1.0.3",
|
|
49
50
|
"@radix-ui/react-checkbox": "^1.0.4",
|
|
@@ -91,6 +92,8 @@
|
|
|
91
92
|
"@mdx-js/esbuild": "^3.0.0",
|
|
92
93
|
"@mdx-js/loader": "^3.0.0",
|
|
93
94
|
"@mdx-js/react": "^3.0.0",
|
|
95
|
+
"@types/facebook-pixel": "^0.0.30",
|
|
96
|
+
"@types/gtag.js": "^0.0.19",
|
|
94
97
|
"@types/lodash.merge": "^4.6.9",
|
|
95
98
|
"@types/mdx": "^2.0.9",
|
|
96
99
|
"@types/react": "^18.2.48",
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from 'react'
|
|
4
|
-
import * as gtag from './gtag'
|
|
5
|
-
import Script from 'next/script'
|
|
6
|
-
import { usePathname } from 'next/navigation'
|
|
7
|
-
|
|
8
|
-
const GoogleAnalyticsHead = () => {
|
|
9
|
-
return (
|
|
10
|
-
<script
|
|
11
|
-
dangerouslySetInnerHTML={{
|
|
12
|
-
__html: `
|
|
13
|
-
window.dataLayer = window.dataLayer || [];
|
|
14
|
-
function gtag(){dataLayer.push(arguments);}
|
|
15
|
-
gtag('js', new Date());
|
|
16
|
-
|
|
17
|
-
gtag('config', '${gtag.GA_TRACKING_ID}', {
|
|
18
|
-
page_path: window.location.pathname,
|
|
19
|
-
});
|
|
20
|
-
`,
|
|
21
|
-
}}
|
|
22
|
-
/>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const GoogleAnalytics = () => {
|
|
27
|
-
const [loaded, setLoaded] = useState(false)
|
|
28
|
-
const pathname = usePathname()
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (!loaded) return
|
|
32
|
-
|
|
33
|
-
gtag.pageview(pathname)
|
|
34
|
-
}, [pathname, loaded])
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div>
|
|
38
|
-
<Script
|
|
39
|
-
strategy='afterInteractive'
|
|
40
|
-
onLoad={() => setLoaded(true)}
|
|
41
|
-
src={`https://www.googletagmanager.com/gtag/js?id=${gtag.GA_TRACKING_ID}`}
|
|
42
|
-
/>
|
|
43
|
-
</div>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export {GoogleAnalyticsHead, GoogleAnalytics}
|
package/next/analytics/gtag.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID
|
|
2
|
-
|
|
3
|
-
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
|
|
4
|
-
export const pageview = (url: string) => {
|
|
5
|
-
window.gtag('config', GA_TRACKING_ID, {
|
|
6
|
-
page_path: url,
|
|
7
|
-
})
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// https://developers.google.com/analytics/devguides/collection/gtagjs/events
|
|
11
|
-
export const event = ({ action, category, label, value }: {action: string, category: string, label: string, value: string}) => {
|
|
12
|
-
window.gtag('event', action, {
|
|
13
|
-
event_category: category,
|
|
14
|
-
event_label: label,
|
|
15
|
-
value: value,
|
|
16
|
-
})
|
|
17
|
-
}
|