WORST ANALYTICS EVER BIGGEST UPDATE
This commit is contained in:
parent
6b77dd40e9
commit
2911d4f0e7
1 changed files with 14 additions and 2 deletions
|
|
@ -66,7 +66,7 @@ client.collectDefaultMetrics({ register });
|
||||||
const eventCounter = new client.Counter({
|
const eventCounter = new client.Counter({
|
||||||
name: "web_event_total",
|
name: "web_event_total",
|
||||||
help: "Aggregated event counts",
|
help: "Aggregated event counts",
|
||||||
labelNames: ["site", "type", "country", "device", "browser", "os"],
|
labelNames: ["site", "type", "path", "country", "device", "browser", "os"],
|
||||||
});
|
});
|
||||||
|
|
||||||
const durationHist = new client.Histogram({
|
const durationHist = new client.Histogram({
|
||||||
|
|
@ -147,7 +147,19 @@ app.post("/some-cool-endpoint", (req, res) => {
|
||||||
return res.sendStatus(403);
|
return res.sendStatus(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
eventCounter.labels(site, e.type, country, device, browser, os).inc();
|
let path = "/";
|
||||||
|
if (typeof e.path === "string" && e.path) {
|
||||||
|
path = e.path.startsWith("/") ? e.path : `/${e.path}`;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
if (e.url) {
|
||||||
|
path = new URL(e.url).pathname || "/";
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eventCounter.labels(site, e.type, path, country, device, browser, os).inc();
|
||||||
|
|
||||||
if (e.type === "click" && e.label) {
|
if (e.type === "click" && e.label) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue