v1.13.1-data: links/redirects, captions, partner picks, Plausible reports, migration baseline #28
1 changed files with 10 additions and 2 deletions
|
|
@ -80,8 +80,16 @@ redirects.get("/go/:id", (c, next) => {
|
||||||
|
|
||||||
db.prepare(`UPDATE redirects SET clicks = clicks + 1, last_clicked_at = datetime('now') WHERE id = ?`).run(row.id);
|
db.prepare(`UPDATE redirects SET clicks = clicks + 1, last_clicked_at = datetime('now') WHERE id = ?`).run(row.id);
|
||||||
|
|
||||||
const site = siteFor(db);
|
// site.json gives Plausible's domain and an origin to resolve paths
|
||||||
tellPlausible(c, site, row.id);
|
// against. Without it (SITE_CONFIG missing) the visitor still goes
|
||||||
|
// on; only the Plausible report is skipped.
|
||||||
|
let site = {};
|
||||||
|
try {
|
||||||
|
site = siteFor(db);
|
||||||
|
} catch (err) {
|
||||||
|
console.warn(`redirects: /go/${row.id} without site.json (${err.message}); not reported to Plausible`);
|
||||||
|
}
|
||||||
|
if (site.url) tellPlausible(c, site, row.id);
|
||||||
for (const [name, value] of Object.entries(NO_STORE)) c.header(name, value);
|
for (const [name, value] of Object.entries(NO_STORE)) c.header(name, value);
|
||||||
return c.redirect(destination(row, site.url || "http://localhost"), 302);
|
return c.redirect(destination(row, site.url || "http://localhost"), 302);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue