File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/* eslint-disable @typescript-eslint/naming-convention */
2+ import posthog from "posthog-js" ;
23import {
34 getAllDiscourseNodesSince ,
45 nodeTypeSince ,
@@ -390,6 +391,7 @@ export const setSyncActivity = (active: boolean) => {
390391export const createOrUpdateDiscourseEmbedding = async ( showToast = false ) => {
391392 if ( ! doSync ) return ;
392393 console . debug ( "starting createOrUpdateDiscourseEmbedding" ) ;
394+ const startTime = new Date ( ) . valueOf ( ) ;
393395 let success = true ;
394396 let claimed = false ;
395397 const worker = window . roamAlphaAPI . user . uid ( ) ;
@@ -453,10 +455,14 @@ export const createOrUpdateDiscourseEmbedding = async (showToast = false) => {
453455 } ) ;
454456 await cleanupOrphanedNodes ( supabaseClient , context ) ;
455457 await endSyncTask ( worker , "complete" , showToast ) ;
458+ const duration = ( new Date ( ) . valueOf ( ) - startTime ) / 1000.0 ;
459+ posthog . capture ( "Sync complete" , { duration } ) ;
456460 } catch ( error ) {
457461 console . error ( "createOrUpdateDiscourseEmbedding: Process failed:" , error ) ;
458462 success = false ;
459463 if ( worker && claimed ) await endSyncTask ( worker , "failed" , showToast ) ;
464+ const duration = ( new Date ( ) . valueOf ( ) - startTime ) / 1000.0 ;
465+ posthog . capture ( "Sync error" , { duration } ) ;
460466 if ( error instanceof FatalError ) {
461467 doSync = false ;
462468 return ;
You can’t perform that action at this time.
0 commit comments