@@ -4,6 +4,7 @@ import axios from 'axios';
44import {
55 Upload , AlertCircle , CheckCircle2 , Plus , X ,
66} from 'lucide-react' ;
7+ import { usePostHog } from '@posthog/react' ;
78import LabelPreview from './LabelPreview' ;
89
910interface BackendUploadResponse {
@@ -24,6 +25,7 @@ interface PreviewData {
2425}
2526
2627function LabelUploader ( ) {
28+ const posthog = usePostHog ( ) ;
2729 const [ file , setFile ] = useState < File | null > ( null ) ;
2830 const [ loading , setLoading ] = useState ( false ) ;
2931 const [ error , setError ] = useState ( '' ) ;
@@ -111,7 +113,15 @@ function LabelUploader() {
111113 setProcessingStatus ( 'Processing complete!' ) ;
112114 setUploadProgress ( 100 ) ;
113115 setSuccess ( response . data . message ) ;
114- console . log ( `Total time: ${ ( ( Date . now ( ) - startTime ) / 1000 ) . toFixed ( 2 ) } s` ) ;
116+ posthog . capture ( 'label_generation_completed' , {
117+ duration_ms : Date . now ( ) - startTime ,
118+ label_count : response . data . label_count ,
119+ sheet_count : response . data . sheet_count ,
120+ total_size_bytes : response . data . total_size ,
121+ template_id : selectedTemplate ,
122+ barcode_type : barcodeType ,
123+ file_size_bytes : file . size ,
124+ } ) ;
115125 setFile ( null ) ; setPreviewData ( null ) ;
116126 if ( fileInputRef . current ) fileInputRef . current . value = '' ;
117127 setTimeout ( ( ) => { setSuccess ( '' ) ; setUploadProgress ( 0 ) ; setProcessingStatus ( '' ) ; } , 5000 ) ;
0 commit comments