mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 07:07:17 +01:00
update getSessionActivity / getWebsiteSession
This commit is contained in:
parent
c7d39a3e94
commit
a1c0ec9c81
7 changed files with 69 additions and 30 deletions
|
|
@ -9,12 +9,16 @@ import { getSessionActivity } from 'queries';
|
|||
export interface SessionActivityRequestQuery extends PageParams {
|
||||
websiteId: string;
|
||||
sessionId: string;
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
}
|
||||
|
||||
const schema = {
|
||||
GET: yup.object().shape({
|
||||
websiteId: yup.string().uuid().required(),
|
||||
sessionId: yup.string().uuid().required(),
|
||||
startDate: yup.string().required(),
|
||||
endDate: yup.string().required(),
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
@ -26,14 +30,19 @@ export default async (
|
|||
await useAuth(req, res);
|
||||
await useValidate(schema, req, res);
|
||||
|
||||
const { websiteId, sessionId } = req.query;
|
||||
const { websiteId, sessionId, startDate, endDate } = req.query;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (!(await canViewWebsite(req.auth, websiteId))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const data = await getSessionActivity(websiteId, sessionId);
|
||||
const data = await getSessionActivity(
|
||||
websiteId,
|
||||
sessionId,
|
||||
new Date(startDate),
|
||||
new Date(endDate),
|
||||
);
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export default async (
|
|||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const data = await getWebsiteSession(sessionId);
|
||||
const data = await getWebsiteSession(websiteId, sessionId);
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue