chore: adds ppt prepare and stream api call events
This commit is contained in:
parent
88bbff4998
commit
5f79275985
3 changed files with 12 additions and 5 deletions
|
|
@ -5,6 +5,7 @@ import { toast } from "sonner";
|
|||
import { clearPresentationData } from "@/store/slices/presentationGeneration";
|
||||
import { PresentationGenerationApi } from "../../services/api/presentation-generation";
|
||||
import { LayoutGroup, LoadingState, TABS } from "../types/index";
|
||||
import { MixpanelEvent, trackEvent } from "@/utils/mixpanel";
|
||||
|
||||
const DEFAULT_LOADING_STATE: LoadingState = {
|
||||
message: "",
|
||||
|
|
@ -37,7 +38,7 @@ export const usePresentationGeneration = (
|
|||
});
|
||||
return false;
|
||||
}
|
||||
if(!selectedLayoutGroup.slides.length){
|
||||
if (!selectedLayoutGroup.slides.length) {
|
||||
toast.error("No Slide Schema found", {
|
||||
description: "Please select a Group before generating presentation",
|
||||
});
|
||||
|
|
@ -63,7 +64,7 @@ export const usePresentationGeneration = (
|
|||
}
|
||||
if (!validateInputs()) return;
|
||||
|
||||
|
||||
|
||||
|
||||
setLoadingState({
|
||||
message: "Generating presentation data...",
|
||||
|
|
@ -74,8 +75,9 @@ export const usePresentationGeneration = (
|
|||
|
||||
try {
|
||||
const layoutData = prepareLayoutData();
|
||||
|
||||
|
||||
if (!layoutData) return;
|
||||
trackEvent(MixpanelEvent.Presentation_Prepare_API_Call);
|
||||
const response = await PresentationGenerationApi.presentationPrepare({
|
||||
presentation_id: presentationId,
|
||||
outlines: outlines,
|
||||
|
|
@ -84,7 +86,7 @@ export const usePresentationGeneration = (
|
|||
|
||||
if (response) {
|
||||
dispatch(clearPresentationData());
|
||||
router.replace(`/presentation?id=${presentationId}&stream=true`);
|
||||
router.replace(`/presentation?id=${presentationId}&stream=true`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('Error In Presentation Generation(prepare).', error);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import {
|
|||
} from "@/store/slices/presentationGeneration";
|
||||
import { jsonrepair } from "jsonrepair";
|
||||
import { toast } from "sonner";
|
||||
import { MixpanelEvent, trackEvent } from "@/utils/mixpanel";
|
||||
|
||||
export const usePresentationStreaming = (
|
||||
presentationId: string,
|
||||
|
|
@ -26,6 +27,8 @@ export const usePresentationStreaming = (
|
|||
dispatch(setStreaming(true));
|
||||
dispatch(clearPresentationData());
|
||||
|
||||
trackEvent(MixpanelEvent.Presentation_Stream_API_Call);
|
||||
|
||||
eventSource = new EventSource(
|
||||
`/api/v1/ppt/presentation/stream?presentation_id=${presentationId}`
|
||||
);
|
||||
|
|
@ -99,7 +102,7 @@ export const usePresentationStreaming = (
|
|||
setLoading(false);
|
||||
dispatch(setStreaming(false));
|
||||
setError(true);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ export enum MixpanelEvent {
|
|||
Outline_Generate_Presentation_Button_Clicked = 'Outline Generate Presentation Button Clicked',
|
||||
Outline_Select_Template_Button_Clicked = 'Outline Select Template Button Clicked',
|
||||
Outline_Add_Slide_Button_Clicked = 'Outline Add Slide Button Clicked',
|
||||
Presentation_Prepare_API_Call = 'Presentation Prepare API Call',
|
||||
Presentation_Stream_API_Call = 'Presentation Stream API Call',
|
||||
Group_Layout_Selected_Clicked = 'Group Layout Selected Clicked',
|
||||
Header_Export_PDF_Button_Clicked = 'Header Export PDF Button Clicked',
|
||||
Header_Export_PPTX_Button_Clicked = 'Header Export PPTX Button Clicked',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue