-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize posthog loading for no consent
- Loading branch information
1 parent
f50f60c
commit ca84382
Showing
6 changed files
with
46 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,3 @@ MATOMO_API_KEY= | |
|
||
SENTRY_DSN= | ||
SENTRY_AUTH_TOKEN="" | ||
|
||
POSTHOG_PUBLIC_KEY=phc_... | ||
POSTHOG_HOST=https://eu.posthog.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<script setup> | ||
<script setup> | ||
const config = useRuntimeConfig() | ||
useHead({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {defineNuxtPlugin} from '#app' | ||
|
||
|
||
/** | ||
* Track page view using Posthog | ||
* For the Script, | ||
* @see nuxt.config.js | ||
* | ||
* @see https://posthog.com/docs/libraries/nuxt-js | ||
*/ | ||
export default defineNuxtPlugin(nuxtApp => { | ||
const router = useRouter() | ||
|
||
// Make sure that pageviews are captured with each route change | ||
router.afterEach((to) => { | ||
if (!window.posthog) { | ||
return | ||
} | ||
|
||
nextTick(() => { | ||
window.posthog.capture('$pageview', { | ||
current_url: to.fullPath | ||
}) | ||
}) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.