Skip to content

Commit

Permalink
fix: migrate to swetrix analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Jul 11, 2024
1 parent 2a36270 commit cdc0593
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
24 changes: 19 additions & 5 deletions src/components/meta.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import Head from 'next/head'
import Script from 'next/script'
import { usePathname, useSearchParams } from "next/navigation"
import * as Swetrix from "swetrix"

const Meta = () => {
const pathname = usePathname()
const searchParams = useSearchParams()

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
if (searchParams.toString() !== "") {
url += `?${searchParams.toString()}`
}

if (typeof document !== "undefined") {
Swetrix.trackPageview(url)
}
}

return (
<>
<Head>
Expand Down Expand Up @@ -47,11 +66,6 @@ const Meta = () => {
<meta name="darkreader-lock" />
<title>Briefkasten</title>
</Head>
{process.env.NODE_ENV === 'production' &&
typeof window !== 'undefined' &&
window.location.host === 'briefkastenhq.com' && (
<Script src="/p.js" data-domain="briefkastenhq.com" data-api="/a/e" />
)}
</>
)
}
Expand Down
6 changes: 0 additions & 6 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
]
}
],
"rewrites": [
{
"source": "/a/e",
"destination": "https://stats.ndo.dev/api/event"
}
],
"github": {
"autoJobCancelation": true
},
Expand Down

0 comments on commit cdc0593

Please sign in to comment.