Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/download-stats.yml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 9 additions & 3 deletions apps/desktop/src/features/registry/RegistryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down