From 1dfcacac98cc007d7b4f6069fcf31a5029fad5b5 Mon Sep 17 00:00:00 2001 From: Mohammod Al Amin Ashik Date: Fri, 20 Feb 2026 22:42:35 +0800 Subject: [PATCH 1/2] fix: debounce analytics search tracking to capture final query only The 300ms debounce meant every keystroke was tracked (g, gt, githu, github). Use a separate 1500ms debounce for analytics so only the final query is sent to PostHog. Signed-off-by: Mohammod Al Amin Ashik --- apps/desktop/src/features/registry/RegistryPage.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/features/registry/RegistryPage.tsx b/apps/desktop/src/features/registry/RegistryPage.tsx index 053ecc89..ebb5322f 100644 --- a/apps/desktop/src/features/registry/RegistryPage.tsx +++ b/apps/desktop/src/features/registry/RegistryPage.tsx @@ -86,14 +86,20 @@ export function RegistryPage() { const timer = setTimeout(() => { if (localSearch !== searchQuery) { search(localSearch); - if (localSearch.trim()) { - capture('registry_search', { query: localSearch.trim() }); - } } }, 300); return () => clearTimeout(timer); }, [localSearch, searchQuery, search]); + // Track search analytics with longer debounce to capture final query only + useEffect(() => { + if (!localSearch.trim()) return; + const timer = setTimeout(() => { + capture('registry_search', { query: localSearch.trim() }); + }, 1500); + return () => clearTimeout(timer); + }, [localSearch]); + const handleInstall = async (id: string) => { const server = servers.find(s => s.id === id); const serverName = server?.name || 'Server'; From 249429b834d05205fc423054b3204be83026e12c Mon Sep 17 00:00:00 2001 From: Mohammod Al Amin Ashik Date: Fri, 20 Feb 2026 22:57:43 +0800 Subject: [PATCH 2/2] chore: add daily GitHub download stats to PostHog Scheduled workflow runs daily at 06:00 UTC, queries GitHub Releases API for download counts per version/platform, and sends them to PostHog as release_downloads events. Can also be triggered manually. Signed-off-by: Mohammod Al Amin Ashik --- .github/workflows/download-stats.yml | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/download-stats.yml diff --git a/.github/workflows/download-stats.yml b/.github/workflows/download-stats.yml new file mode 100644 index 00000000..87fd39ee --- /dev/null +++ b/.github/workflows/download-stats.yml @@ -0,0 +1,61 @@ +name: Download Stats to PostHog + +on: + schedule: + # Run daily at 06:00 UTC + - cron: '0 6 * * *' + workflow_dispatch: # Allow manual trigger + +jobs: + report-downloads: + runs-on: ubuntu-latest + steps: + - name: Send download counts to PostHog + env: + POSTHOG_KEY: ${{ secrets.VITE_POSTHOG_KEY }} + POSTHOG_HOST: ${{ secrets.VITE_POSTHOG_HOST }} + GH_TOKEN: ${{ github.token }} + run: | + POSTHOG_HOST="${POSTHOG_HOST:-https://us.i.posthog.com}" + + # Fetch all releases + releases=$(gh api repos/${{ github.repository }}/releases --paginate) + + # Parse and send per-release download counts + echo "$releases" | jq -c '.[]' | while read -r release; do + tag=$(echo "$release" | jq -r '.tag_name') + published=$(echo "$release" | jq -r '.published_at') + + # Count real downloads (exclude .sig files and latest.json) + downloads=$(echo "$release" | jq '[.assets[] | select(.name | (endswith(".sig") or . == "latest.json") | not) | .download_count] | add // 0') + + # Per-platform counts + windows=$(echo "$release" | jq '[.assets[] | select(.name | test("\\.(msi|exe)$")) | select(.name | endswith(".sig") | not) | .download_count] | add // 0') + macos=$(echo "$release" | jq '[.assets[] | select(.name | endswith(".dmg")) | .download_count] | add // 0') + linux=$(echo "$release" | jq '[.assets[] | select(.name | test("\\.(deb|rpm|AppImage)$")) | .download_count] | add // 0') + + # latest.json hits (proxy for active installs checking for updates) + updater_checks=$(echo "$release" | jq '[.assets[] | select(.name == "latest.json") | .download_count] | add // 0') + + echo " $tag: $downloads downloads (win=$windows, mac=$macos, linux=$linux, updater=$updater_checks)" + + # Send to PostHog + curl -s -o /dev/null "${POSTHOG_HOST}/capture/" \ + -H 'Content-Type: application/json' \ + -d "{ + \"api_key\": \"${POSTHOG_KEY}\", + \"event\": \"release_downloads\", + \"distinct_id\": \"github-release-stats\", + \"properties\": { + \"version\": \"${tag}\", + \"published_at\": \"${published}\", + \"total_downloads\": ${downloads}, + \"windows_downloads\": ${windows}, + \"macos_downloads\": ${macos}, + \"linux_downloads\": ${linux}, + \"updater_checks\": ${updater_checks} + } + }" + done + + echo "Done reporting download stats to PostHog"