Add Plausible analytics with JSON Upload custom event.

Load tagged-events from plausible.elpatron.me on all pages, allow it in CSP, and track successful save uploads with import status.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-19 16:58:58 +02:00
parent 5c87df1e5e
commit 810ad67ab6
5 changed files with 12 additions and 2 deletions
+7
View File
@@ -42,6 +42,12 @@ function getViewerId() {
return document.body?.dataset?.viewerId || "";
}
function trackEvent(name, props) {
if (typeof window.plausible === "function") {
window.plausible(name, props ? { props } : undefined);
}
}
function apiBase() {
const vid = getViewerId();
return vid ? `/v/${vid}/api` : "/api";
@@ -143,6 +149,7 @@ function setupUpload() {
e.target.value = "";
return;
}
trackEvent("JSON Upload", { status: result.imported ? "imported" : result.reason || "ok" });
if (result.imported) {
await loadData();
notifyImportSuccess(result);