Skip to content

Commit

Permalink
Using @next/thirt-parties for GA, TS fix (#22)
Browse files Browse the repository at this point in the history
GA is not from from @next/third-parties
fixed window typescript error
  • Loading branch information
erikrakuscek authored Feb 22, 2024
1 parent ba06620 commit ced79b6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 80 deletions.
6 changes: 6 additions & 0 deletions pkgs/hanzo-ui/next/analytics/fpixel.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
declare global {
interface Window {
fbq: Function;
}
}

export const FB_PIXEL_ID = process.env.NEXT_PUBLIC_FACEBOOK_PIXEL_ID

export const pageview = () => {
Expand Down
47 changes: 0 additions & 47 deletions pkgs/hanzo-ui/next/analytics/google-analytics.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions pkgs/hanzo-ui/next/analytics/gtag.ts

This file was deleted.

5 changes: 2 additions & 3 deletions pkgs/hanzo-ui/next/root-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Header from '../common/header'
import type { SiteDef } from '../types'
import getAppRouterBodyFontClasses from './get-app-router-font-classes'
import { FacebookPixelHead, FacebookPixel } from './analytics/pixel-analytics'
import { GoogleAnalytics, GoogleAnalyticsHead } from './analytics/google-analytics'
import { GoogleAnalytics } from '@next/third-parties/google'

// Next 14: https://nextjs.org/docs/app/building-your-application/upgrading/codemods#use-viewport-export
const viewport = {
Expand Down Expand Up @@ -42,11 +42,10 @@ const RootLayout: React.FC<PropsWithChildren & {
{/* https://stackoverflow.com/a/75716588/11645689 */ }
<base target='_blank' />
<FacebookPixelHead/>
<GoogleAnalyticsHead/>
</head>
<body className={bodyClasses}>
<FacebookPixel />
<GoogleAnalytics />
<GoogleAnalytics gaId={process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID} />
{header && <Header siteDef={siteDef}/>}
{children}
</body>
Expand Down
1 change: 1 addition & 0 deletions pkgs/hanzo-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
},
"dependencies": {
"@hookform/resolvers": "^3.3.2",
"@next/third-parties": "^14.1.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-checkbox": "^1.0.4",
Expand Down
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ced79b6

Please sign in to comment.