test: Booking flow App failure and ics file tests and improved logging (#11646)
This commit is contained in:
1 parent
07bfaec24e
commit
3ca7456885
17 files changed
+513
-239
No files matched your search
@@ -256,7 +256,10 @@ export const createEvent = async (
|
||||
if (error?.calError) {
|
||||
calError = error.calError;
|
||||
}
|
||||
log.error("createEvent failed", JSON.stringify(error), calEvent);
|
||||
log.error(
|
||||
"createEvent failed",
|
||||
safeStringify({ error, calEvent: getPiiFreeCalendarEvent(calEvent) })
|
||||
);
|
||||
// @TODO: This code will be off till we can investigate an error with it
|
||||
//https://github.com/calcom/cal.com/issues/3949
|
||||
// await sendBrokenIntegrationEmail(calEvent, "calendar");
|
||||
@@ -266,7 +269,13 @@ export const createEvent = async (
|
||||
if (!creationResult) {
|
||||
logger.silly("createEvent failed", { success, uid, creationResult, originalEvent: calEvent, calError });
|
||||
}
|
||||
|
||||
log.debug(
|
||||
"Created calendar event",
|
||||
JSON.stringify({
|
||||
calEvent: getPiiFreeCalendarEvent(calEvent),
|
||||
creationResult,
|
||||
})
|
||||
);
|
||||
return {
|
||||
appName: credential.appId || "",
|
||||
type: credential.type,
|
||||
|
||||
@@ -10,6 +10,7 @@ import { appKeysSchema as calVideoKeysSchema } from "@calcom/app-store/dailyvide
|
||||
import { getEventLocationTypeFromApp, MeetLocationType } from "@calcom/app-store/locations";
|
||||
import getApps from "@calcom/app-store/utils";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { getPiiFreeUser } from "@calcom/lib/piiFreeData";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
|
||||
@@ -27,6 +28,7 @@ import type {
|
||||
import { createEvent, updateEvent } from "./CalendarManager";
|
||||
import { createMeeting, updateMeeting } from "./videoClient";
|
||||
|
||||
const log = logger.getChildLogger({ prefix: ["EventManager"] });
|
||||
export const isDedicatedIntegration = (location: string): boolean => {
|
||||
return location !== MeetLocationType && location.includes("integrations:");
|
||||
};
|
||||
@@ -81,7 +83,7 @@ export default class EventManager {
|
||||
* @param user
|
||||
*/
|
||||
constructor(user: EventManagerUser) {
|
||||
logger.silly("Initializing EventManager", JSON.stringify({ user }));
|
||||
log.silly("Initializing EventManager", safeStringify({ user: getPiiFreeUser(user) }));
|
||||
const appCredentials = getApps(user.credentials, true).flatMap((app) =>
|
||||
app.credentials.map((creds) => ({ ...creds, appName: app.name }))
|
||||
);
|
||||
@@ -124,6 +126,7 @@ export default class EventManager {
|
||||
const [mainHostDestinationCalendar] =
|
||||
(evt.destinationCalendar as [undefined | NonNullable<typeof evt.destinationCalendar>[number]]) ?? [];
|
||||
if (evt.location === MeetLocationType && mainHostDestinationCalendar?.integration !== "google_calendar") {
|
||||
log.warn("Falling back to Cal Video integration as Google Calendar not installed");
|
||||
evt["location"] = "integrations:daily";
|
||||
}
|
||||
const isDedicated = evt.location ? isDedicatedIntegration(evt.location) : null;
|
||||
@@ -362,7 +365,7 @@ export default class EventManager {
|
||||
[] as DestinationCalendar[]
|
||||
);
|
||||
for (const destination of destinationCalendars) {
|
||||
logger.silly("Creating Calendar event", JSON.stringify({ destination }));
|
||||
log.silly("Creating Calendar event", JSON.stringify({ destination }));
|
||||
if (destination.credentialId) {
|
||||
let credential = this.calendarCredentials.find((c) => c.id === destination.credentialId);
|
||||
if (!credential) {
|
||||
@@ -402,7 +405,7 @@ export default class EventManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.silly(
|
||||
log.silly(
|
||||
"No destination Calendar found, falling back to first connected calendar",
|
||||
safeStringify({
|
||||
calendarCredentials: this.calendarCredentials,
|
||||
@@ -416,7 +419,7 @@ export default class EventManager {
|
||||
const [credential] = this.calendarCredentials.filter((cred) => !cred.type.endsWith("other_calendar"));
|
||||
if (credential) {
|
||||
const createdEvent = await createEvent(credential, event);
|
||||
logger.silly("Created Calendar event", { createdEvent });
|
||||
log.silly("Created Calendar event", safeStringify({ createdEvent }));
|
||||
if (createdEvent) {
|
||||
createdEvents.push(createdEvent);
|
||||
}
|
||||
@@ -465,7 +468,7 @@ export default class EventManager {
|
||||
* @todo remove location from event types that has missing credentials
|
||||
* */
|
||||
if (!videoCredential) {
|
||||
logger.warn(
|
||||
log.warn(
|
||||
'Falling back to "daily" video integration for event with location: ' +
|
||||
event.location +
|
||||
" because credential is missing for the app"
|
||||
@@ -513,7 +516,7 @@ export default class EventManager {
|
||||
): Promise<Array<EventResult<NewCalendarEventType>>> {
|
||||
let calendarReference: PartialReference[] | undefined = undefined,
|
||||
credential;
|
||||
logger.silly("updateAllCalendarEvents", JSON.stringify({ event, booking, newBookingId }));
|
||||
log.silly("updateAllCalendarEvents", JSON.stringify({ event, booking, newBookingId }));
|
||||
try {
|
||||
// If a newBookingId is given, update that calendar event
|
||||
let newBooking;
|
||||
@@ -575,7 +578,7 @@ export default class EventManager {
|
||||
(credential) => credential.type === reference?.type
|
||||
);
|
||||
for (const credential of credentials) {
|
||||
logger.silly("updateAllCalendarEvents-credential", JSON.stringify({ credentials }));
|
||||
log.silly("updateAllCalendarEvents-credential", JSON.stringify({ credentials }));
|
||||
result.push(updateEvent(credential, event, bookingRefUid, calenderExternalId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { SelectedCalendar } from "@prisma/client";
|
||||
import { getCalendar } from "@calcom/app-store/_utils/getCalendar";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { getPiiFreeCredential, getPiiFreeSelectedCalendar } from "@calcom/lib/piiFreeData";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import { performance } from "@calcom/lib/server/perfObserver";
|
||||
import type { EventBusyDate } from "@calcom/types/Calendar";
|
||||
import type { CredentialPayload } from "@calcom/types/Credential";
|
||||
@@ -35,6 +36,13 @@ const getCalendarsEvents = async (
|
||||
const selectedCalendarIds = passedSelectedCalendars.map((sc) => sc.externalId);
|
||||
/** If we don't then we actually fetch external calendars (which can be very slow) */
|
||||
performance.mark("eventBusyDatesStart");
|
||||
log.debug(
|
||||
`Getting availability for`,
|
||||
safeStringify({
|
||||
calendarService: c.constructor.name,
|
||||
selectedCalendars: passedSelectedCalendars.map(getPiiFreeSelectedCalendar),
|
||||
})
|
||||
);
|
||||
const eventBusyDates = await c.getAvailability(dateFrom, dateTo, passedSelectedCalendars);
|
||||
performance.mark("eventBusyDatesEnd");
|
||||
performance.measure(
|
||||
@@ -52,11 +60,14 @@ const getCalendarsEvents = async (
|
||||
"getBusyCalendarTimesStart",
|
||||
"getBusyCalendarTimesEnd"
|
||||
);
|
||||
log.debug({
|
||||
calendarCredentials: calendarCredentials.map(getPiiFreeCredential),
|
||||
selectedCalendars: selectedCalendars.map(getPiiFreeSelectedCalendar),
|
||||
calendarEvents: awaitedResults,
|
||||
});
|
||||
log.debug(
|
||||
"Result",
|
||||
safeStringify({
|
||||
calendarCredentials: calendarCredentials.map(getPiiFreeCredential),
|
||||
selectedCalendars: selectedCalendars.map(getPiiFreeSelectedCalendar),
|
||||
calendarEvents: awaitedResults,
|
||||
})
|
||||
);
|
||||
return awaitedResults;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getDailyAppKeys } from "@calcom/app-store/dailyvideo/lib/getDailyAppKey
|
||||
import { sendBrokenIntegrationEmail } from "@calcom/emails";
|
||||
import { getUid } from "@calcom/lib/CalEventParser";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { getPiiFreeCalendarEvent } from "@calcom/lib/piiFreeData";
|
||||
import { getPiiFreeCalendarEvent, getPiiFreeCredential } from "@calcom/lib/piiFreeData";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import type { GetRecordingsResponseSchema } from "@calcom/prisma/zod-utils";
|
||||
@@ -25,7 +25,7 @@ const getVideoAdapters = async (withCredentials: CredentialPayload[]): Promise<V
|
||||
|
||||
for (const cred of withCredentials) {
|
||||
const appName = cred.type.split("_").join(""); // Transform `zoom_video` to `zoomvideo`;
|
||||
logger.silly("getVideoAdapters", JSON.stringify({ appName, cred }));
|
||||
log.silly("Getting video adapter for", safeStringify({ appName, cred: getPiiFreeCredential(cred) }));
|
||||
const appImportFn = appStore[appName as keyof typeof appStore];
|
||||
|
||||
// Static Link Video Apps don't exist in packages/app-store/index.ts(it's manually maintained at the moment) and they aren't needed there anyway.
|
||||
@@ -55,7 +55,14 @@ const getBusyVideoTimes = async (withCredentials: CredentialPayload[]) =>
|
||||
|
||||
const createMeeting = async (credential: CredentialPayload, calEvent: CalendarEvent) => {
|
||||
const uid: string = getUid(calEvent);
|
||||
log.silly("videoClient:createMeeting", JSON.stringify({ credential, uid, calEvent }));
|
||||
log.silly(
|
||||
"createMeeting",
|
||||
safeStringify({
|
||||
credential: getPiiFreeCredential(credential),
|
||||
uid,
|
||||
calEvent: getPiiFreeCalendarEvent(calEvent),
|
||||
})
|
||||
);
|
||||
if (!credential || !credential.appId) {
|
||||
throw new Error(
|
||||
"Credentials must be set! Video platforms are optional, so this method shouldn't even be called when no video credentials are set."
|
||||
@@ -159,7 +166,10 @@ const updateMeeting = async (
|
||||
const deleteMeeting = async (credential: CredentialPayload | null, uid: string): Promise<unknown> => {
|
||||
if (credential) {
|
||||
const videoAdapter = (await getVideoAdapters([credential]))[0];
|
||||
logger.debug("videoAdapter inside deleteMeeting", { credential, uid });
|
||||
log.debug(
|
||||
"Calling deleteMeeting for",
|
||||
safeStringify({ credential: getPiiFreeCredential(credential), uid })
|
||||
);
|
||||
// There are certain video apps with no video adapter defined. e.g. riverby,whereby
|
||||
if (videoAdapter) {
|
||||
return videoAdapter.deleteMeeting(uid);
|
||||
|
||||
Reference in new issue
Block a user