feat: Add framework to send all events fired for embed to Analytics Apps (#15173)
* Send all events to analytics apps * feat: Start sending all events fired for embed to Analytics Apps(GTM Support added) * Add tests
This commit is contained in:
1 parent
9e371ded90
commit
1730ef7d5d
11 files changed
+363
-21
No files matched your search
@@ -104,7 +104,15 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, teamMemb
|
||||
: duration && event.data?.metadata?.multipleDuration?.includes(duration)
|
||||
? duration
|
||||
: event.data?.length;
|
||||
|
||||
const eventPayload = {
|
||||
uid: responseData.uid,
|
||||
title: responseData.title,
|
||||
startTime: responseData.startTime,
|
||||
endTime: responseData.endTime,
|
||||
eventTypeId: responseData.eventTypeId,
|
||||
status: responseData.status,
|
||||
paymentRequired: responseData.paymentRequired,
|
||||
};
|
||||
if (isRescheduling) {
|
||||
sdkActionManager?.fire("rescheduleBookingSuccessful", {
|
||||
booking: responseData,
|
||||
@@ -118,6 +126,7 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, teamMemb
|
||||
},
|
||||
confirmed: !(responseData.status === BookingStatus.PENDING && event.data?.requiresConfirmation),
|
||||
});
|
||||
sdkActionManager?.fire("rescheduleBookingSuccessfulV2", eventPayload);
|
||||
} else {
|
||||
sdkActionManager?.fire("bookingSuccessful", {
|
||||
booking: responseData,
|
||||
@@ -131,6 +140,8 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, teamMemb
|
||||
},
|
||||
confirmed: !(responseData.status === BookingStatus.PENDING && event.data?.requiresConfirmation),
|
||||
});
|
||||
|
||||
sdkActionManager?.fire("bookingSuccessfulV2", eventPayload);
|
||||
}
|
||||
|
||||
if (paymentUid) {
|
||||
|
||||
@@ -3,6 +3,12 @@ import { post } from "@calcom/lib/fetch-wrapper";
|
||||
import type { BookingCreateBody, BookingResponse } from "../types";
|
||||
|
||||
export const createBooking = async (data: BookingCreateBody) => {
|
||||
const response = await post<BookingCreateBody, BookingResponse>("/api/book/event", data);
|
||||
const response = await post<
|
||||
Omit<BookingCreateBody, "startTime" | "endTime">,
|
||||
BookingResponse & {
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
}
|
||||
>("/api/book/event", data);
|
||||
return response;
|
||||
};
|
||||
@@ -1731,8 +1731,8 @@ async function handler(
|
||||
...newBooking.user,
|
||||
email: null,
|
||||
},
|
||||
paymentRequired: false,
|
||||
};
|
||||
|
||||
return {
|
||||
...bookingResponse,
|
||||
...luckyUserResponse,
|
||||
@@ -2348,7 +2348,7 @@ async function handler(
|
||||
req.statusCode = 201;
|
||||
// TODO: Refactor better so this booking object is not passed
|
||||
// all around and instead the individual fields are sent as args.
|
||||
const bookingReponse = {
|
||||
const bookingResponse = {
|
||||
...booking,
|
||||
user: {
|
||||
...booking.user,
|
||||
@@ -2357,9 +2357,10 @@ async function handler(
|
||||
};
|
||||
|
||||
return {
|
||||
...bookingReponse,
|
||||
...bookingResponse,
|
||||
...luckyUserResponse,
|
||||
message: "Payment required",
|
||||
paymentRequired: true,
|
||||
paymentUid: payment?.uid,
|
||||
paymentId: payment?.id,
|
||||
};
|
||||
@@ -2499,6 +2500,7 @@ async function handler(
|
||||
...booking.user,
|
||||
email: null,
|
||||
},
|
||||
paymentRequired: false,
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user