mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 18:26:20 +01:00
Event Data maximum size.
This commit is contained in:
parent
db6a6d6055
commit
eb2f07c105
@ -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.');
|
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 ignoreIps = process.env.IGNORE_IP;
|
||||||
const ignoreHostnames = process.env.IGNORE_HOSTNAME;
|
const ignoreHostnames = process.env.IGNORE_HOSTNAME;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export interface WebsiteEventsRequestQuery {
|
|||||||
startAt: string;
|
startAt: string;
|
||||||
endAt: string;
|
endAt: string;
|
||||||
unit: string;
|
unit: string;
|
||||||
tz: string;
|
timezone: string;
|
||||||
url: string;
|
url: string;
|
||||||
eventName: string;
|
eventName: string;
|
||||||
}
|
}
|
||||||
@ -25,14 +25,14 @@ export default async (
|
|||||||
await useCors(req, res);
|
await useCors(req, res);
|
||||||
await useAuth(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 (req.method === 'GET') {
|
||||||
if (!(await canViewWebsite(req.auth, websiteId))) {
|
if (!(await canViewWebsite(req.auth, websiteId))) {
|
||||||
return unauthorized(res);
|
return unauthorized(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
if (!moment.tz.zone(timezone) || !unitTypes.includes(unit)) {
|
||||||
return badRequest(res);
|
return badRequest(res);
|
||||||
}
|
}
|
||||||
const startDate = new Date(+startAt);
|
const startDate = new Date(+startAt);
|
||||||
@ -41,7 +41,7 @@ export default async (
|
|||||||
const events = await getEventMetrics(websiteId, {
|
const events = await getEventMetrics(websiteId, {
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
timezone: tz,
|
timezone,
|
||||||
unit,
|
unit,
|
||||||
filters: {
|
filters: {
|
||||||
url,
|
url,
|
||||||
|
Loading…
Reference in New Issue
Block a user