fix: fix exceptional cases with docusaurus-fathom

This commit is contained in:
jinhojang6
2023-09-22 20:58:43 +09:00
parent 88f91589fb
commit 91d60aed3a
2 changed files with 13 additions and 7 deletions
+12 -6
View File
@@ -12,7 +12,13 @@ declare global {
}
}
if (ExecutionEnvironment.canUseDOM) {
const main = () => {
if (
HOSTNAMES.length > 0
? !HOSTNAMES.includes(window.location.hostname)
: window.location.hostname === 'localhost'
)
return
;(function (f: any, a: any, t: string, h: string) {
a[h] =
a[h] ||
@@ -32,15 +38,15 @@ if (ExecutionEnvironment.canUseDOM) {
fathom('trackPageview')
}
if (ExecutionEnvironment.canUseDOM) {
main()
}
export const onRouteDidUpdate: ClientModule['onRouteDidUpdate'] = ({
location,
previousLocation,
}) => {
if (HOSTNAMES.length > 0 && !HOSTNAMES.includes(window.location.hostname))
return
if (window.location.hostname === 'localhost') return
if (location.pathname !== previousLocation?.pathname) {
if (!!window.fathom && location.pathname !== previousLocation?.pathname) {
window.fathom('trackPageview')
}
}
@@ -75,7 +75,7 @@ const config = {
siteId: 'TEST',
scriptUrl: 'https://fathom.status.im/tracker.js',
disabled: true,
hostnames: ['waku.org'],
hostnames: ['localhost', 'waku.org'],
},
],
],