Skip to content

Commit ead80dd

Browse files
authored
Merge pull request #90 from gephi/plugin-download-counter
Count plugin downloads with a Cloudflare Worker
2 parents 6341cae + 0aac07b commit ead80dd

9 files changed

Lines changed: 1658 additions & 3 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ pnpm-debug.log*
2323
# IDEs
2424
.idea/
2525
.vscode/
26+
27+
# wrangler local state
28+
.wrangler/

‎src/pages/desktop/plugins/[id].astro‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const topVersionIsLatestGephi = !!topVersionTag && topVersionTag === latestGephi
8888
topVersionIsLatestGephi && (
8989
<div>
9090
<a
91-
href={`https://raw.githubusercontent.com/gephi/gephi-plugins/gh-pages/plugins/${groupedVersions[topVersionTag].url}`}
91+
href={`https://gephi.org/gephi-plugins/plugins/${groupedVersions[topVersionTag].url}`}
9292
class="btn btn-white fs-4 fw-bold"
9393
>
9494
<Icon name="ph:download" />
@@ -198,7 +198,7 @@ const topVersionIsLatestGephi = !!topVersionTag && topVersionTag === latestGephi
198198
{modernVersionTags.map((v) => (
199199
<li>
200200
<a
201-
href={`https://raw.githubusercontent.com/gephi/gephi-plugins/gh-pages/plugins/${groupedVersions[v].url}`}
201+
href={`https://gephi.org/gephi-plugins/plugins/${groupedVersions[v].url}`}
202202
class="text-decoration-none"
203203
>
204204
<Icon name="ph:download" />
@@ -218,7 +218,7 @@ const topVersionIsLatestGephi = !!topVersionTag && topVersionTag === latestGephi
218218
{legacyVersionTags.map((v) => (
219219
<li>
220220
<a
221-
href={`https://raw.githubusercontent.com/gephi/gephi-plugins/gh-pages/plugins/${groupedVersions[v].url}`}
221+
href={`https://gephi.org/gephi-plugins/plugins/${groupedVersions[v].url}`}
222222
class="text-decoration-none"
223223
>
224224
<Icon name="ph:download" />

‎src/pages/legal/index.astro‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ import Layout from "../../layouts/Layout.astro";
7070
application logs only, with personal information such as the username removed. Sending reports is optional,
7171
and all tracking can be disabled in Gephi's Settings.
7272
</p>
73+
<p>
74+
When you download a plugin, from Gephi's Plugin Manager or this website, we count the download per plugin
75+
file, day, and client type (Gephi, browser, or other). No IP address or other personal data is stored.
76+
</p>
7377
</section>
7478

7579
<section id="security" class="mb-5">

‎workers/plugin-downloads/README.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Plugin download counter
2+
3+
Cloudflare Worker on `gephi.org/gephi-plugins/plugins/*`, where Gephi's Plugin Manager and the plugin pages of this
4+
website download plugins from. It passes every request through to GitHub Pages unchanged and counts `.nbm` and `.zip`
5+
downloads per file, client (`gephi`, `browser` or `other`) and day in a D1 database. Requests from the gephi-plugins
6+
release build are not counted.
7+
8+
## Deploy
9+
10+
```
11+
npm install
12+
npx wrangler login
13+
npx wrangler d1 create gephi-plugin-downloads # first time: put the returned database_id in wrangler.toml
14+
npx wrangler d1 execute gephi-plugin-downloads --remote --file schema.sql
15+
npm run deploy
16+
```
17+
18+
The route `gephi.org/gephi-plugins/plugins/*` is created once, outside wrangler (Workers Routes of the gephi.org zone in
19+
the Cloudflare dashboard, or the API), with its request limit failure mode set to "Fail open"
20+
(`request_limit_fail_open: true`), so plugin downloads keep working if the Workers Free daily limit is reached. It isn't
21+
in `wrangler.toml` because `wrangler deploy` recreates the routes it declares, which resets that setting.
22+
23+
## Query
24+
25+
```
26+
npx wrangler d1 execute gephi-plugin-downloads --remote --command \
27+
"SELECT file, client, SUM(count) AS downloads FROM downloads GROUP BY file, client ORDER BY downloads DESC"
28+
```

0 commit comments

Comments
 (0)