From 38cfd4315dafbc3977156767ef6e0ae4f2626e3c Mon Sep 17 00:00:00 2001 From: Emily Date: Thu, 6 Feb 2025 15:23:38 +0100 Subject: [PATCH] fix ai UI + add domain filter on visits --- dashboard/layouts/dashboard.vue | 7 +++++-- dashboard/server/ai/functions/AI_Visits.ts | 14 +++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/dashboard/layouts/dashboard.vue b/dashboard/layouts/dashboard.vue index cc15f5c..1ceb293 100644 --- a/dashboard/layouts/dashboard.vue +++ b/dashboard/layouts/dashboard.vue @@ -107,9 +107,12 @@ const { isOpen, close, open } = useMenu(); - + + +
+ +
- diff --git a/dashboard/server/ai/functions/AI_Visits.ts b/dashboard/server/ai/functions/AI_Visits.ts index 495c201..38a242d 100644 --- a/dashboard/server/ai/functions/AI_Visits.ts +++ b/dashboard/server/ai/functions/AI_Visits.ts @@ -14,7 +14,8 @@ const getVisitsCountsTool: AIPlugin_TTool<'getVisitsCount'> = { from: { type: 'string', description: 'ISO string of start date' }, to: { type: 'string', description: 'ISO string of end date' }, website: { type: 'string', description: 'The website of the visits' }, - page: { type: 'string', description: 'The page of the visit' } + page: { type: 'string', description: 'The page of the visit' }, + domain: { type: 'string', description: 'Used only to filter a specific domain' } }, required: ['from', 'to'] } @@ -33,6 +34,7 @@ const getVisitsTimelineTool: AIPlugin_TTool<'getVisitsTimeline'> = { to: { type: 'string', description: 'ISO string of end date' }, website: { type: 'string', description: 'The website of the visits' }, page: { type: 'string', description: 'The page of the visit' }, + domain: { type: 'string', description: 'Used only to filter a specific domain' } }, required: ['from', 'to'] } @@ -45,14 +47,15 @@ export class AiVisits extends AIPlugin<['getVisitsCount', 'getVisitsTimeline']> super({ 'getVisitsCount': { - handler: async (data: { project_id: string, from: string, to: string, website?: string, page?: string }) => { + handler: async (data: { project_id: string, from: string, to: string, website?: string, page?: string, domain?: string }) => { const query: any = { project_id: data.project_id, created_at: { $gt: new Date(data.from), $lt: new Date(data.to), - } + }, + website: data.domain || { $ne: '_NODOMAIN_' } } if (data.website) query.website = data.website; @@ -67,7 +70,7 @@ export class AiVisits extends AIPlugin<['getVisitsCount', 'getVisitsTimeline']> tool: getVisitsCountsTool }, 'getVisitsTimeline': { - handler: async (data: { project_id: string, from: string, to: string, time_offset: number, website?: string, page?: string }) => { + handler: async (data: { project_id: string, from: string, to: string, time_offset: number, website?: string, page?: string, domain?: string }) => { const timelineData = await executeTimelineAggregation({ projectId: new Types.ObjectId(data.project_id), @@ -75,7 +78,8 @@ export class AiVisits extends AIPlugin<['getVisitsCount', 'getVisitsTimeline']> from: data.from, to: data.to, slice: 'day', - timeOffset: data.time_offset + timeOffset: data.time_offset, + domain: data.domain || { $ne: '_NODOMAIN_' } as any }); return { data: timelineData }; },