Files
calendar/packages/features/tasker/tasks/analytics/handleAnalyticsEvents.ts
T
Benny JooandGitHub 76332a759b refactor: circular deps between app store and lib [5] (#23936)
* getBulkEventTypes

* 2 eventtypes related utils to features

* locationsResolver

* checkForEmptyAssignment

* mv defaultEvents to features

* update imports

* PrismaAppRepository

* mv currencyConversions from appstore to lib

* useAppsData

* videoClient

* analytics files

* fix

* mv

* prettier

* use named import
2025-09-19 10:16:56 -03:00

46 lines
1.0 KiB
TypeScript

import type { CredentialForCalendarService } from "@calcom/types/Credential";
import { tasker } from "../../../tasker";
interface HandleAnalyticsEventsProps {
credentials: CredentialForCalendarService[];
rawBookingData: Record<string, any>;
bookingInfo: {
email: string;
name: string;
eventName: string;
};
isTeamEventType: boolean;
}
export const handleAnalyticsEvents = async ({
credentials,
rawBookingData,
bookingInfo,
isTeamEventType,
}: HandleAnalyticsEventsProps) => {
const { dub_id } = await rawBookingData;
if (!dub_id || typeof dub_id !== "string") return;
const dubCredential = credentials.find((cred) => {
if (cred.appId !== "dub") return false;
if (isTeamEventType && !cred.teamId) return false;
return true;
});
if (!dubCredential) return;
try {
await tasker.create("sendAnalyticsEvent", {
credentialId: dubCredential.id,
info: {
id: dub_id,
...bookingInfo,
},
});
} catch (err) {
console.error("Error sending dub lead: ", err);
}
};