fix: remove unused eslint-disable directive; inject PostHog key in CI build

- posthog.ts: drop redundant no-console disable (project has no no-console rule;
  --report-unused-disable-directives failed CI lint)
- desktop-build.yml: pass VITE_PUBLIC_POSTHOG_KEY/HOST into the frontend build
  so released DMGs actually report analytics (was no-op without the key)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
周小舟
2026-06-03 19:47:18 +08:00
parent e25b062041
commit 2f7a4bf809
2 changed files with 8 additions and 1 deletions

View File

@@ -62,6 +62,14 @@ jobs:
run: cargo install tauri-cli --locked --version "^2.0"
- name: Build desktop app (PBS route)
env:
# PostHog analytics. The phc_ key is a public client key (it ships in
# the frontend bundle anyway), but we keep it in repo Secrets so it's
# easy to rotate and not hard-coded. Set this secret in
# Settings -> Secrets and variables -> Actions. If unset, the build
# still succeeds and analytics is a no-op at runtime.
VITE_PUBLIC_POSTHOG_KEY: ${{ secrets.VITE_PUBLIC_POSTHOG_KEY }}
VITE_PUBLIC_POSTHOG_HOST: ${{ vars.VITE_PUBLIC_POSTHOG_HOST || 'https://us.i.posthog.com' }}
run: bash scripts/build_macos_arm.sh
- name: Upload DMG artifact

View File

@@ -39,7 +39,6 @@ export function initAnalytics(): void {
if (initialized) return
if (!POSTHOG_KEY) {
if (import.meta.env.DEV) {
// eslint-disable-next-line no-console
console.info('[analytics] 未配置 VITE_PUBLIC_POSTHOG_KEY埋点已禁用')
}
return