Update report parameters.

This commit is contained in:
Mike Cao 2023-05-30 16:49:22 -07:00
parent e9b0d3f796
commit 43f5854f15
5 changed files with 27 additions and 20 deletions

View file

@ -40,6 +40,9 @@ export default async (
if (req.method === 'POST') {
const { id: reportId } = req.query;
const {
user: { id: userId },
} = req.auth;
const { websiteId, type, name, description, parameters } = req.body;
@ -52,6 +55,7 @@ export default async (
const result = await updateReport(
{
websiteId,
userId,
type,
name,
description,

View file

@ -9,8 +9,10 @@ export interface FunnelRequestBody {
websiteId: string;
urls: string[];
window: number;
startAt: number;
endAt: number;
dateRange: {
startDate: string;
endDate: string;
};
}
export interface FunnelResponse {
@ -28,18 +30,20 @@ export default async (
await useAuth(req, res);
if (req.method === 'POST') {
const { websiteId, urls, window, startAt, endAt } = req.body;
const {
websiteId,
urls,
window,
dateRange: { startDate, endDate },
} = req.body;
if (!(await canViewWebsite(req.auth, websiteId))) {
return unauthorized(res);
}
const startDate = new Date(+startAt);
const endDate = new Date(+endAt);
const data = await getPageviewFunnel(websiteId, {
startDate,
endDate,
startDate: new Date(startDate),
endDate: new Date(endDate),
urls,
windowMinutes: +window,
});