update funnels for CH. Add wildcards and event steps

This commit is contained in:
Francis Cao 2024-04-02 00:19:15 -07:00
parent 6767f95c0d
commit 05079f3810
3 changed files with 80 additions and 50 deletions

View file

@ -8,7 +8,7 @@ import * as yup from 'yup';
export interface FunnelRequestBody {
websiteId: string;
urls: string[];
steps: { type: string; value: string }[];
window: number;
dateRange: {
startDate: string;
@ -17,7 +17,7 @@ export interface FunnelRequestBody {
}
export interface FunnelResponse {
urls: string[];
steps: { type: string; value: string }[];
window: number;
startAt: number;
endAt: number;
@ -26,7 +26,15 @@ export interface FunnelResponse {
const schema = {
POST: yup.object().shape({
websiteId: yup.string().uuid().required(),
urls: yup.array().min(2).of(yup.string()).required(),
steps: yup
.array()
.of(
yup.object().shape({
type: yup.string().required(),
value: yup.string().required(),
}),
)
.min(2),
window: yup.number().positive().required(),
dateRange: yup
.object()
@ -49,7 +57,7 @@ export default async (
if (req.method === 'POST') {
const {
websiteId,
urls,
steps,
window,
dateRange: { startDate, endDate },
} = req.body;
@ -61,7 +69,7 @@ export default async (
const data = await getFunnel(websiteId, {
startDate: new Date(startDate),
endDate: new Date(endDate),
urls,
steps,
windowMinutes: +window,
});