Skip to content

Commit 69a5b48

Browse files
committed
fix: useEffect swetrix
1 parent 582b642 commit 69a5b48

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/components/analytics.jsx

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
'use client'
22

33
import * as Swetrix from 'swetrix'
4-
import { Suspense } from 'react'
4+
import { useEffect, Suspense } from 'react'
55
import { usePathname } from 'next/navigation'
66

77
function SwetrixComponent() {
88
const pathname = usePathname()
99

10-
if (window.location.host === 'briefkastenhq.com') {
11-
Swetrix.init(process.env.NEXT_PUBLIC_SWETRIX_PROJECT, {
12-
apiURL: process.env.NEXT_PUBLIC_SWETRIX_API_HOST,
13-
})
14-
let url = pathname
15-
Swetrix.trackPageview(url)
16-
}
10+
useEffect(() => {
11+
if (window.location.host === 'briefkastenhq.com') {
12+
Swetrix.init(process.env.NEXT_PUBLIC_SWETRIX_PROJECT, {
13+
apiURL: process.env.NEXT_PUBLIC_SWETRIX_API_HOST,
14+
})
15+
let url = pathname
16+
Swetrix.trackPageview(url)
17+
}
18+
}, [pathname])
1719
return <div></div>
1820
}
1921

0 commit comments

Comments
 (0)