@@ -35,9 +35,11 @@ import {
3535 variables ,
3636} from 'shared/styles' ;
3737import {
38+ ExportDataSuccessfulEvent ,
3839 exportEncryptedDataSucceed ,
3940 Mixpanel ,
4041 MixpanelEventType ,
42+ MixpanelFeature ,
4143 MixpanelProps ,
4244 sendLogFile ,
4345} from 'shared/utils' ;
@@ -101,6 +103,11 @@ export const DataExportPopup = ({
101103 const executeAllPagesOfExportData = useCallback (
102104 async ( { appletId, targetSubjectIds } : ExecuteAllPagesOfExportData ) => {
103105 try {
106+ const analyticsEvent : ExportDataSuccessfulEvent = {
107+ action : MixpanelEventType . ExportDataSuccessful ,
108+ [ MixpanelProps . AppletId ] : appletId ,
109+ } ;
110+
104111 dataExportingRef . current = true ;
105112 setDataIsExporting ( true ) ;
106113
@@ -212,7 +219,7 @@ export const DataExportPopup = ({
212219 const respondentId = filters ?. sourceSubjectId ;
213220 const subjectId = targetSubjectIds ?? filters ?. targetSubjectId ;
214221
215- await new EHRDataExporter ( ) . exportData ( {
222+ const { size } = await new EHRDataExporter ( ) . exportData ( {
216223 appletId,
217224 fromDate,
218225 toDate,
@@ -221,13 +228,15 @@ export const DataExportPopup = ({
221228 respondentIds : respondentId ? [ respondentId ] : undefined ,
222229 subjectIds : subjectId ? [ subjectId ] : undefined ,
223230 } ) ;
231+
232+ if ( size ) {
233+ analyticsEvent [ MixpanelProps . Feature ] = [ MixpanelFeature . EHR ] ;
234+ analyticsEvent [ MixpanelProps . EHRFileSize ] = size ;
235+ }
224236 }
225237
238+ Mixpanel . track ( analyticsEvent ) ;
226239 handlePopupClose ( ) ;
227- Mixpanel . track ( {
228- action : MixpanelEventType . ExportDataSuccessful ,
229- [ MixpanelProps . AppletId ] : appletId ,
230- } ) ;
231240 } catch ( e ) {
232241 const error = e as TypeError ;
233242 console . warn ( 'Error while export data' , error ) ;
0 commit comments