mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Add event type to event.
This commit is contained in:
parent
c90194dad4
commit
d85b2be5f8
4 changed files with 20 additions and 10 deletions
|
|
@ -29,6 +29,18 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const { type, payload } = getJsonBody(req);
|
||||
|
||||
const { referrer, event_name: eventName, event_data: eventData } = payload;
|
||||
let { url } = payload;
|
||||
|
||||
// Validate eventData is JSON
|
||||
const valid = eventData && typeof eventData === 'object' && !Array.isArray(eventData);
|
||||
|
||||
if (!valid) {
|
||||
return badRequest(res, 'Event Data must be in the form of a JSON Object.');
|
||||
}
|
||||
|
||||
const ignoreIps = process.env.IGNORE_IP;
|
||||
const ignoreHostnames = process.env.IGNORE_HOSTNAME;
|
||||
|
||||
|
|
@ -75,10 +87,6 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||
|
||||
const session = req.session;
|
||||
|
||||
const { type, payload } = getJsonBody(req);
|
||||
|
||||
let { url, referrer, event_name: eventName, event_data: eventData } = payload;
|
||||
|
||||
if (process.env.REMOVE_TRAILING_SLASH) {
|
||||
url = url.replace(/\/$/, '');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { allowQuery } from 'lib/auth';
|
|||
import { UmamiApi } from 'lib/constants';
|
||||
import { useAuth, useCors } from 'lib/middleware';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, serverError, unauthorized, badRequest } from 'next-basics';
|
||||
import { methodNotAllowed, ok, serverError, unauthorized } from 'next-basics';
|
||||
import { deleteWebsite, getWebsite, updateWebsite } from 'queries';
|
||||
|
||||
export interface WebsiteRequestQuery {
|
||||
|
|
@ -19,7 +19,7 @@ export interface WebsiteRequestBody {
|
|||
|
||||
export default async (
|
||||
req: NextApiRequestQueryBody<WebsiteRequestQuery, WebsiteRequestBody>,
|
||||
res: NextApiResponse<Website | any>,
|
||||
res: NextApiResponse<Website>,
|
||||
) => {
|
||||
await useCors(req, res);
|
||||
await useAuth(req, res);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue