mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-28 18:36:23 +02:00
Merge remote-tracking branch 'upstream/dev' into fix/chatpage-ux
This commit is contained in:
commit
2cb5ce3aa9
17 changed files with 602 additions and 67 deletions
15
surfsense_web/components/providers/PostHogProvider.tsx
Normal file
15
surfsense_web/components/providers/PostHogProvider.tsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
"use client";
|
||||
|
||||
import { PostHogProvider as PHProvider } from "@posthog/react";
|
||||
import posthog from "posthog-js";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
interface PostHogProviderProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function PostHogProvider({ children }: PostHogProviderProps) {
|
||||
// posthog-js is already initialized in instrumentation-client.ts
|
||||
// We just need to wrap the app with the PostHogProvider for hook access
|
||||
return <PHProvider client={posthog}>{children}</PHProvider>;
|
||||
}
|
||||
|
|
@ -9,13 +9,17 @@ import { useCallback, useState } from "react";
|
|||
import { useDropzone } from "react-dropzone";
|
||||
import { toast } from "sonner";
|
||||
import { uploadDocumentMutationAtom } from "@/atoms/documents/document-mutation.atoms";
|
||||
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import {
|
||||
trackDocumentUploadFailure,
|
||||
trackDocumentUploadStarted,
|
||||
trackDocumentUploadSuccess,
|
||||
} from "@/lib/posthog/events";
|
||||
import { GridPattern } from "./GridPattern";
|
||||
|
||||
interface DocumentUploadTabProps {
|
||||
|
|
@ -154,6 +158,10 @@ export function DocumentUploadTab({ searchSpaceId }: DocumentUploadTabProps) {
|
|||
const handleUpload = async () => {
|
||||
setUploadProgress(0);
|
||||
|
||||
// Track upload started
|
||||
const totalSize = files.reduce((sum, file) => sum + file.size, 0);
|
||||
trackDocumentUploadStarted(Number(searchSpaceId), files.length, totalSize);
|
||||
|
||||
// Create a progress interval to simulate progress
|
||||
const progressInterval = setInterval(() => {
|
||||
setUploadProgress((prev) => {
|
||||
|
|
@ -172,6 +180,10 @@ export function DocumentUploadTab({ searchSpaceId }: DocumentUploadTabProps) {
|
|||
onSuccess: () => {
|
||||
clearInterval(progressInterval);
|
||||
setUploadProgress(100);
|
||||
|
||||
// Track upload success
|
||||
trackDocumentUploadSuccess(Number(searchSpaceId), files.length);
|
||||
|
||||
toast(t("upload_initiated"), {
|
||||
description: t("upload_initiated_desc"),
|
||||
});
|
||||
|
|
@ -180,6 +192,10 @@ export function DocumentUploadTab({ searchSpaceId }: DocumentUploadTabProps) {
|
|||
onError: (error: any) => {
|
||||
clearInterval(progressInterval);
|
||||
setUploadProgress(0);
|
||||
|
||||
// Track upload failure
|
||||
trackDocumentUploadFailure(Number(searchSpaceId), error.message || "Upload failed");
|
||||
|
||||
toast(t("upload_error"), {
|
||||
description: `${t("upload_error_desc")}: ${error.message || "Upload failed"}`,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue