diff --git a/src/queries/analytics/events/getEvents.ts b/src/queries/analytics/events/getEvents.ts index b727540d62..c333242e35 100644 --- a/src/queries/analytics/events/getEvents.ts +++ b/src/queries/analytics/events/getEvents.ts @@ -13,17 +13,26 @@ export function getEvents(...args: [websiteId: string, filters: QueryFilters]) { function relationalQuery(websiteId: string, filters: QueryFilters) { const { startDate } = filters; - return prisma.client.websiteEvent.findMany({ - where: { - websiteId, - createdAt: { - gte: startDate, + return prisma.client.websiteEvent + .findMany({ + where: { + websiteId, + createdAt: { + gte: startDate, + }, }, - }, - orderBy: { - createdAt: 'desc', - }, - }); + orderBy: { + createdAt: 'desc', + }, + }) + .then(a => { + return Object.values(a).map(a => { + return { + ...a, + timestamp: new Date(a.createdAt).getTime() / 1000, + }; + }); + }); } function clickhouseQuery(websiteId: string, filters: QueryFilters) { diff --git a/src/queries/analytics/sessions/getSessions.ts b/src/queries/analytics/sessions/getSessions.ts index 71a5bee618..a11edd39bd 100644 --- a/src/queries/analytics/sessions/getSessions.ts +++ b/src/queries/analytics/sessions/getSessions.ts @@ -13,17 +13,26 @@ export async function getSessions(...args: [websiteId: string, filters: QueryFil async function relationalQuery(websiteId: string, filters: QueryFilters) { const { startDate } = filters; - return prisma.client.session.findMany({ - where: { - websiteId, - createdAt: { - gte: startDate, + return prisma.client.session + .findMany({ + where: { + websiteId, + createdAt: { + gte: startDate, + }, }, - }, - orderBy: { - createdAt: 'desc', - }, - }); + orderBy: { + createdAt: 'desc', + }, + }) + .then(a => { + return Object.values(a).map(a => { + return { + ...a, + timestamp: new Date(a.createdAt).getTime() / 1000, + }; + }); + }); } async function clickhouseQuery(websiteId: string, filters: QueryFilters) {