Files
litlyx/dashboard/server/api/project/first_interaction.ts
2025-11-28 16:49:20 +01:00

17 lines
514 B
TypeScript

import { EventModel } from "~/shared/schema/metrics/EventSchema";
import { VisitModel } from "~/shared/schema/metrics/VisitSchema";
export default defineEventHandler(async event => {
const ctx = await getRequestContext(event, 'pid', 'permission:webAnalytics');
const { project_id } = ctx;
const hasEvents = await EventModel.exists({ project_id });
if (hasEvents) return true;
const hasVisits = await VisitModel.exists({ project_id });
if (hasVisits) return true;
return false;
});