Skip to content

Commit

Permalink
Update _app.tsx (#2044)
Browse files Browse the repository at this point in the history
* Update _app.tsx

* Update _app.tsx

* Update _app.tsx

* fix lint
  • Loading branch information
mihaisc authored May 27, 2024
1 parent cb3a9ae commit 113af78
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,9 @@ import MarketMetadataProvider from '@context/MarketMetadata'
import { WagmiConfig } from 'wagmi'
import { ConnectKitProvider } from 'connectkit'
import { connectKitTheme, wagmiClient } from '@utils/wallet'
import posthog from 'posthog-js'
import { PostHogProvider } from 'posthog-js/react'
import { useRouter } from 'next/router'

// Check that PostHog is client-side (used to handle Next.js SSR)
if (typeof window !== 'undefined') {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || 'https://eu.posthog.com',
persistence: 'memory'
})
}

function MyApp({ Component, pageProps }: AppProps): ReactElement {
Decimal.set({ rounding: 1 })
const router = useRouter()

useEffect(() => {
// Track page views
const handleRouteChange = () => posthog?.capture('$pageview')
router.events.on('routeChangeComplete', handleRouteChange)

return () => {
router.events.off('routeChangeComplete', handleRouteChange)
}
}, [router.events])

return (
<>
Expand All @@ -55,11 +33,9 @@ function MyApp({ Component, pageProps }: AppProps): ReactElement {
<PricesProvider>
<ConsentProvider>
<OrbisProvider>
<PostHogProvider client={posthog}>
<App>
<Component {...pageProps} />
</App>
</PostHogProvider>
<App>
<Component {...pageProps} />
</App>
</OrbisProvider>
</ConsentProvider>
</PricesProvider>
Expand Down

0 comments on commit 113af78

Please sign in to comment.