mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-24 20:03:41 +03:00
perf(analytics): added tracking for file upload and chat (#376)
This commit is contained in:
parent
97d2c9de10
commit
bdccdf1a0a
@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
|
||||
|
||||
import { useBrainConfig } from "@/lib/context/BrainConfigProvider/hooks/useBrainConfig";
|
||||
import { useToast } from "@/lib/hooks";
|
||||
import { useEventTracking } from "@/services/analytics/useEventTracking";
|
||||
|
||||
import { useChatService } from "./useChatService";
|
||||
import { useChatContext } from "../context/ChatContext";
|
||||
@ -11,6 +12,7 @@ import { ChatQuestion } from "../types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export const useChat = () => {
|
||||
const { track } = useEventTracking();
|
||||
const params = useParams();
|
||||
const [chatId, setChatId] = useState<string | undefined>(
|
||||
params?.chatId as string | undefined
|
||||
@ -54,6 +56,7 @@ export const useChat = () => {
|
||||
};
|
||||
|
||||
try {
|
||||
void track("QUESTION_ASKED");
|
||||
setGeneratingAnswer(true);
|
||||
const currentChatId =
|
||||
chatId ??
|
||||
|
@ -6,8 +6,10 @@ import { FileRejection, useDropzone } from "react-dropzone";
|
||||
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
||||
import { useAxios } from "@/lib/hooks";
|
||||
import { useToast } from "@/lib/hooks/useToast";
|
||||
import { useEventTracking } from "@/services/analytics/useEventTracking";
|
||||
|
||||
export const useFileUploader = () => {
|
||||
const { track} = useEventTracking();
|
||||
const [isPending, setIsPending] = useState(false);
|
||||
const { publish } = useToast();
|
||||
const [files, setFiles] = useState<File[]>([]);
|
||||
@ -25,7 +27,7 @@ export const useFileUploader = () => {
|
||||
formData.append("file", file);
|
||||
try {
|
||||
const response = await axiosInstance.post(`/upload`, formData);
|
||||
|
||||
track("FILE_UPLOADED");
|
||||
publish({
|
||||
variant: response.data.type,
|
||||
text:
|
||||
|
@ -4,14 +4,13 @@ import { useSupabase } from "@/lib/context/SupabaseProvider";
|
||||
|
||||
import { useJune } from "./useJune";
|
||||
|
||||
type TrackedEvent = "SIGNED_IN";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export const useEventTracking = () => {
|
||||
const analytics = useJune();
|
||||
const { session } = useSupabase();
|
||||
|
||||
const track = async (event: TrackedEvent): Promise<void> => {
|
||||
const track = async (event: string): Promise<void> => {
|
||||
await analytics?.identify(session?.user.id);
|
||||
await analytics?.track(event);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user