Skip to content

Commit

Permalink
fix: useEffect swetrix
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Jul 11, 2024
1 parent 582b642 commit 69a5b48
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/components/analytics.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
'use client'

import * as Swetrix from 'swetrix'
import { Suspense } from 'react'
import { useEffect, Suspense } from 'react'
import { usePathname } from 'next/navigation'

function SwetrixComponent() {
const pathname = usePathname()

if (window.location.host === 'briefkastenhq.com') {
Swetrix.init(process.env.NEXT_PUBLIC_SWETRIX_PROJECT, {
apiURL: process.env.NEXT_PUBLIC_SWETRIX_API_HOST,
})
let url = pathname
Swetrix.trackPageview(url)
}
useEffect(() => {
if (window.location.host === 'briefkastenhq.com') {
Swetrix.init(process.env.NEXT_PUBLIC_SWETRIX_PROJECT, {
apiURL: process.env.NEXT_PUBLIC_SWETRIX_API_HOST,
})
let url = pathname
Swetrix.trackPageview(url)
}
}, [pathname])
return <div></div>
}

Expand Down

0 comments on commit 69a5b48

Please sign in to comment.