Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Event Data maximum size.

Brian Caoeb2f07c10526
diff --git a/pages/api/collect.ts b/pages/api/collect.ts
index ab817ef13..68c4afb2f 100644
--- a/pages/api/collect.ts
+++ b/pages/api/collect.ts
@@ -39,6 +39,11 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
return badRequest(res, 'Event Data must be in the form of a JSON Object.');
}
+ // Validate eventData is less than 100kB
+ if (eventData && new TextEncoder().encode(eventData).length / 1024 > 100) {
+ return badRequest(res, 'Event Data exceeds maximum size of 100 kB.');
+ }
+
const ignoreIps = process.env.IGNORE_IP;
const ignoreHostnames = process.env.IGNORE_HOSTNAME;
diff --git a/pages/api/websites/[id]/events.ts b/pages/api/websites/[id]/events.ts
index 918a95421..12473da0e 100644
--- a/pages/api/websites/[id]/events.ts
+++ b/pages/api/websites/[id]/events.ts
@@ -13,7 +13,7 @@ export interface WebsiteEventsRequestQuery {
startAt: string;
endAt: string;
unit: string;
- tz: string;
+ timezone: string;
url: string;
eventName: string;
}
@@ -25,14 +25,14 @@ export default async (
await useCors(req, res);
await useAuth(req, res);
- const { id: websiteId, startAt, endAt, unit, tz, url, eventName } = req.query;
+ const { id: websiteId, startAt, endAt, unit, timezone, url, eventName } = req.query;
if (req.method === 'GET') {
if (!(await canViewWebsite(req.auth, websiteId))) {
return unauthorized(res);
}
- if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
+ if (!moment.tz.zone(timezone) || !unitTypes.includes(unit)) {
return badRequest(res);
}
const startDate = new Date(+startAt);
@@ -41,7 +41,7 @@ export default async (
const events = await getEventMetrics(websiteId, {
startDate,
endDate,
- timezone: tz,
+ timezone,
unit,
filters: {
url,