feat: add Umami Analytics integration and widget (#5362)
Co-authored-by: Josh G <febrile42@users.noreply.github.com> Co-authored-by: Meier Lukas <meierschlumpf@gmail.com> Co-authored-by: Thomas <thomas@ajnart.fr>
This commit is contained in:
27 files changed
+1713
-2
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import type { useScopedI18n } from "@homarr/translation/client";
|
||||
|
||||
import { timeFrameValues } from "./index";
|
||||
|
||||
export const EVENT_COLORS = ["blue.5", "orange.5", "green.5", "red.5", "violet.5", "teal.5", "yellow.5", "pink.5"];
|
||||
|
||||
export function formatXLabel(timestamp: string, timeFrame: string): string {
|
||||
const date = new Date(timestamp);
|
||||
switch (timeFrame) {
|
||||
case "today":
|
||||
case "24h":
|
||||
return `${date.getHours().toString().padStart(2, "0")}:00`;
|
||||
case "7d":
|
||||
case "30d":
|
||||
case "month":
|
||||
case "lastMonth":
|
||||
return date.toLocaleDateString(undefined, { month: "short", day: "numeric" });
|
||||
default:
|
||||
return timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
export type TimeFrame = (typeof timeFrameValues)[number];
|
||||
|
||||
export function formatTimeFrameLabel(
|
||||
timeFrame: TimeFrame,
|
||||
t: ReturnType<typeof useScopedI18n<"widget.umami">>,
|
||||
): string {
|
||||
if (timeFrameValues.includes(timeFrame)) {
|
||||
return t(`option.timeFrame.option.${timeFrame}`);
|
||||
}
|
||||
return timeFrame;
|
||||
}
|
||||
Reference in new issue
Block a user