Skip to content

Commit

Permalink
fix goatcounter tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-psi committed Jan 22, 2024
1 parent aa44a4f commit 35add88
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
3 changes: 2 additions & 1 deletion typings/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ declare namespace Goatcounter {
}

interface Goatcounter {
count: (vars: CountVars) => void;
no_onload?: boolean;
count?: (vars: CountVars) => void;
}
}

Expand Down
17 changes: 17 additions & 0 deletions website/.vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script setup lang="ts">
import { useRoute } from 'vitepress';
import DefaultTheme from 'vitepress/theme';
import { watch } from 'vue';
const route = useRoute();
watch(() => route.path, (_, path) => {
console.log(path);
window.goatcounter?.count?.({ path });
})
</script>

<template>
<DefaultTheme.Layout />
</template>
2 changes: 1 addition & 1 deletion website/.vitepress/theme/components/AddRepoButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ onMounted(() => {
});
function handleAnalytics() {
window.goatcounter?.count({
window.goatcounter?.count?.({
path: "/#add-to-tachiyomi",
title: "Add extension repository",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const iconUrl = `${GITHUB_EXTENSION_BASE}/icon/${props.item.pkg}.png`;
const apkUrl = `${GITHUB_EXTENSION_BASE}/apk/${props.item.apk}`;
function handleAnalytics(apk: string) {
window.goatcounter?.count({
window.goatcounter?.count?.({
path: `/extensions/apk/${apk}`
})
}
Expand Down
4 changes: 3 additions & 1 deletion website/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import goatcounter from './plugin/goatcounter';

import './styles/base.styl';
import 'element-plus/theme-chalk/dark/css-vars.css';
import Layout from './Layout.vue';

export default {
extends: DefaultTheme,
enhanceApp({ app }) {
app.use(VueQueryPlugin);
enhanceAppWithTabs(app);
goatcounter({ id: "keiyoushi" });
}
},
Layout,
} satisfies Theme
2 changes: 2 additions & 0 deletions website/.vitepress/theme/plugin/goatcounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function mountGoatcounter(id: string) {
script.async = true
script.src = "//gc.zgo.at/count.js"

window.goatcounter = { no_onload: true };

document.head.appendChild(script)
}

Expand Down
2 changes: 1 addition & 1 deletion website/add-repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ next: false

if (isAndroid.value) {
if (decodedUrl == GITHUB_EXTENSION_MIN_JSON) {
window.goatcounter?.count({
window.goatcounter?.count?.({
path: "/#add-to-tachiyomi",
title: "Add extension repository",
});
Expand Down

0 comments on commit 35add88

Please sign in to comment.