diff --git a/bun.lock b/bun.lock index c69309c..2fe0ce9 100644 --- a/bun.lock +++ b/bun.lock @@ -6,6 +6,7 @@ "name": "subminer", "dependencies": { "@catppuccin/vitepress": "^0.1.2", + "@plausible-analytics/tracker": "^0.4.4", "axios": "^1.13.5", "commander": "^14.0.3", "discord-rpc": "^4.0.1", @@ -188,6 +189,8 @@ "@pkgjs/parseargs": ["@pkgjs/parseargs@0.11.0", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="], + "@plausible-analytics/tracker": ["@plausible-analytics/tracker@0.4.4", "", {}, "sha512-fz0NOYUEYXtg1TBaPEEvtcBq3FfmLFuTe1VZw4M8sTWX129br5dguu3M15+plOQnc181ShYe67RfwhKgK89VnA=="], + "@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.57.1", "", { "os": "android", "cpu": "arm" }, "sha512-A6ehUVSiSaaliTxai040ZpZ2zTevHYbvu/lDoeAteHI8QnaosIzm4qwtezfRg1jOYaUmnzLX1AOD6Z+UJjtifg=="], "@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.57.1", "", { "os": "android", "cpu": "arm64" }, "sha512-dQaAddCY9YgkFHZcFNS/606Exo8vcLHwArFZ7vxXq4rigo2bb494/xKMMwRRQW6ug7Js6yXmBZhSBRuBvCCQ3w=="], diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index ee87a73..99d6c7e 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -5,8 +5,25 @@ import '@catppuccin/vitepress/theme/macchiato/mauve.css'; import './mermaid-modal.css'; let mermaidLoader: Promise | null = null; +let plausibleTrackerInitialized = false; const MERMAID_MODAL_ID = 'mermaid-diagram-modal'; +async function initPlausibleTracker() { + if (typeof window === 'undefined' || plausibleTrackerInitialized) { + return; + } + + const { init } = await import('@plausible-analytics/tracker'); + init({ + domain: 'subminer.moe', + endpoint: 'https://worker.subminer.moe', + outboundLinks: true, + fileDownloads: true, + formSubmissions: true, + }); + plausibleTrackerInitialized = true; +} + function closeMermaidModal() { if (typeof document === 'undefined') { return; @@ -188,7 +205,12 @@ export default { }); }; - onMounted(render); + onMounted(() => { + initPlausibleTracker().catch((error) => { + console.error('Failed to initialize Plausible tracker:', error); + }); + render(); + }); watch(() => route.path, render); }, }; diff --git a/docs/plausible.test.ts b/docs/plausible.test.ts new file mode 100644 index 0000000..f9b7915 --- /dev/null +++ b/docs/plausible.test.ts @@ -0,0 +1,15 @@ +import { expect, test } from 'bun:test'; +import { readFileSync } from 'node:fs'; + +const docsThemePath = new URL('./.vitepress/theme/index.ts', import.meta.url); +const docsThemeContents = readFileSync(docsThemePath, 'utf8'); + +test('docs theme configures plausible tracker for subminer.moe via worker.subminer.moe', () => { + expect(docsThemeContents).toContain("@plausible-analytics/tracker"); + expect(docsThemeContents).toContain('const { init } = await import'); + expect(docsThemeContents).toContain("domain: 'subminer.moe'"); + expect(docsThemeContents).toContain("endpoint: 'https://worker.subminer.moe'"); + expect(docsThemeContents).toContain('outboundLinks: true'); + expect(docsThemeContents).toContain('fileDownloads: true'); + expect(docsThemeContents).toContain('formSubmissions: true'); +}); diff --git a/package.json b/package.json index 15b4794..862e69c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "subminer", - "version": "0.2.2", + "version": "0.2.3", "description": "All-in-one sentence mining overlay with AnkiConnect and dictionary integration", "packageManager": "bun@1.3.5", "main": "dist/main-entry.js", @@ -58,6 +58,7 @@ "license": "GPL-3.0-or-later", "dependencies": { "@catppuccin/vitepress": "^0.1.2", + "@plausible-analytics/tracker": "^0.4.4", "axios": "^1.13.5", "commander": "^14.0.3", "discord-rpc": "^4.0.1",