repos
/ analytics-django master

analytics-django

mirror archived upstream

Self-hostable website analytics on Django: a straightforward collector API, dashboards, a world map, and PDF reports.

analyticsdjangodockerhandcodedpythonself-hostedsqliteviteweb-analytics

557 B · 18 lines · JavaScript Raw History
 1document.addEventListener("DOMContentLoaded", function () {
 2  const form = document.getElementById("is-public-form");
 3  if (!form) { return; }
 4  form.addEventListener("change", function () {
 5    let url = new URL(window.location.href);
 6    url = url.origin + url.pathname + "is-public/";
 7    fetch(url, {
 8      method: "POST",
 9      headers: {
10        "Content-Type": "application/json",
11        "X-CSRFToken": form.querySelector("input[name=csrfmiddlewaretoken]").value,
12      },
13    }).then(function () {
14      window.location.reload();
15    });
16  });
17});