mirror of
https://github.com/Queer-Lexikon/regenbogenkarte
synced 2024-11-23 20:53:10 +00:00
feat: add goatcounter integration
To enable the goatcounter integration, the variable VITE_QUEER_LEXIKON_PRIVATE must be set to "true". This check is intentionally added for development environments so that all dev environments from possible forks do not modify the statistics by accident.
This commit is contained in:
parent
b0d3b0d205
commit
b15bfc0a73
5 changed files with 42 additions and 1 deletions
2
.env
Normal file
2
.env
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
VITE_QUEER_LEXIKON_PRIVATE=false
|
||||||
|
|
5
main.ts
5
main.ts
|
@ -5,6 +5,7 @@ import { initializeMap } from "./ts/map";
|
||||||
import "@fontsource/ubuntu/latin.css";
|
import "@fontsource/ubuntu/latin.css";
|
||||||
import { setupLegend } from "./ts/legend";
|
import { setupLegend } from "./ts/legend";
|
||||||
import { setupEmergencyButton } from "./ts/emergency-button";
|
import { setupEmergencyButton } from "./ts/emergency-button";
|
||||||
|
import { addGoatCounter } from "./ts/goatcounter";
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
initializeMap();
|
initializeMap();
|
||||||
|
@ -12,4 +13,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
setupHamburger();
|
setupHamburger();
|
||||||
setupLegend();
|
setupLegend();
|
||||||
setupEmergencyButton();
|
setupEmergencyButton();
|
||||||
|
|
||||||
|
if (import.meta.env.VITE_QUEER_LEXIKON_PRIVATE === "true") {
|
||||||
|
addGoatCounter();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
12
ts/env.d.ts
vendored
Normal file
12
ts/env.d.ts
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
}
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
// This variable is set in our GitHub Actions for adding additional features
|
||||||
|
// that should be only available on karte.queer-lexikon.net and not
|
||||||
|
// for development purposes.
|
||||||
|
//
|
||||||
|
// Although it's actually a boolean, all environment variables are strings, so we
|
||||||
|
// type it as string here as well.
|
||||||
|
readonly VITE_QUEER_LEXIKON_PRIVATE?: string;
|
||||||
|
}
|
22
ts/goatcounter.ts
Normal file
22
ts/goatcounter.ts
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
goatcounter: {
|
||||||
|
path: (p: any) => string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const addGoatCounter = () => {
|
||||||
|
window.goatcounter = {
|
||||||
|
path: function (p: any) {
|
||||||
|
return location.host + p;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let goatcounter = document.createElement("script");
|
||||||
|
goatcounter.src = "//ziege.queer-lexikon.net/count.js";
|
||||||
|
goatcounter.async = true;
|
||||||
|
goatcounter.setAttribute("data-goatcounter", "https://ziege.queer-lexikon.net/count");
|
||||||
|
|
||||||
|
document.head.appendChild(goatcounter);
|
||||||
|
};
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"exclude": ["/dist"],
|
"exclude": ["/dist"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "ES2015",
|
"module": "ES2020",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"lib": ["DOM", "ES2015"],
|
"lib": ["DOM", "ES2015"],
|
||||||
"target": "ES2015",
|
"target": "ES2015",
|
||||||
|
|
Loading…
Reference in a new issue