Skip to content

Commit b84ec62

Browse files
Merge pull request #3 from DashAISoftware/download-track
Add click tracking request for downloads
2 parents 1aa5447 + 9b6fb1b commit b84ec62

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ concurrency:
1919
jobs:
2020
build:
2121
runs-on: ubuntu-latest
22+
env:
23+
NEXT_PUBLIC_TRACKER_URL: ${{ vars.NEXT_PUBLIC_TRACKER_URL }}
2224
steps:
2325
- name: Checkout
2426
uses: actions/checkout@v4

components/download-section.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next"
77

88
const downloads = [
99
{
10+
id: "mac_intel",
1011
icon: Package,
1112
key: "macIntel",
1213
defaultPlatform: "macOS Intel processors",
@@ -16,6 +17,7 @@ const downloads = [
1617
link: "https://dashai.nyc3.cdn.digitaloceanspaces.com/executables/DashAI-launcher-cpu-x86_64",
1718
},
1819
{
20+
id: "mac_arm",
1921
icon: Package,
2022
key: "macArm",
2123
defaultPlatform: "macOS ARM processors",
@@ -25,6 +27,7 @@ const downloads = [
2527
link: "https://dashai.nyc3.cdn.digitaloceanspaces.com/executables/DashAI-launcher-cpu-arm64",
2628
},
2729
{
30+
id: "windows",
2831
icon: Package,
2932
key: "windows",
3033
defaultPlatform: "Windows",
@@ -35,6 +38,19 @@ const downloads = [
3538
},
3639
]
3740

41+
const TRACKER_URL = process.env.NEXT_PUBLIC_TRACKER_URL
42+
43+
async function trackClick(buttonId: string) {
44+
if (!TRACKER_URL) return
45+
try {
46+
await fetch(`${TRACKER_URL}/click/${buttonId}`, {
47+
method: "POST",
48+
})
49+
} catch {
50+
// non-blocking — don't let tracking errors affect the download
51+
}
52+
}
53+
3854
export function DownloadSection() {
3955
const { t } = useTranslation()
4056
return (
@@ -57,7 +73,7 @@ export function DownloadSection() {
5773

5874
<div className="max-w-5xl mx-auto">
5975
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-12">
60-
{downloads.map((download, index) => {
76+
{downloads.map((download) => {
6177
const Icon = download.icon
6278
const platform = t(`download:cards.${download.key}.platform`, {
6379
defaultValue: download.defaultPlatform,
@@ -81,12 +97,12 @@ export function DownloadSection() {
8197
</p>
8298
<p className="text-xs text-muted-foreground font-mono">{format}</p>
8399
</div>
84-
<Button
85-
className="w-full bg-primary hover:bg-primary/90 text-primary-foreground cursor-pointer"
100+
<Button
101+
className="w-full bg-primary hover:bg-primary/90 text-primary-foreground cursor-pointer"
86102
size="sm"
87103
asChild
88104
>
89-
<a href={download.link} download>
105+
<a href={download.link} download onClick={() => trackClick(download.id)}>
90106
<Download className="mr-2 h-4 w-4" />
91107
{t("download:button", { defaultValue: "Download" })}
92108
</a>
@@ -124,4 +140,4 @@ export function DownloadSection() {
124140
</div>
125141
</section>
126142
)
127-
}
143+
}

0 commit comments

Comments
 (0)