@@ -42,8 +42,10 @@ import type { RumConfiguration, RumInitConfiguration } from '../domain/configura
4242import type { ViewOptions } from '../domain/view/trackViews'
4343import type {
4444 AddDurationVitalOptions ,
45- DurationVitalOptions ,
4645 DurationVitalReference ,
46+ DurationVitalOptions ,
47+ FeatureOperationOptions ,
48+ FailureReason ,
4749} from '../domain/vital/vitalCollection'
4850import { createCustomVitalsState } from '../domain/vital/vitalCollection'
4951import { callPluginsMethod } from '../domain/plugins'
@@ -424,9 +426,37 @@ export interface RumPublicApi extends PublicApi {
424426 *
425427 * @category Vital
426428 * @param nameOrRef - Name or reference of the custom vital
427- * @param options - Options for the custom vital (context, description)
429+ * @param options - Options for the custom vital (operationKey, context, description)
428430 */
429431 stopDurationVital : ( nameOrRef : string | DurationVitalReference , options ?: DurationVitalOptions ) => void
432+
433+ /**
434+ * [Experimental] start a feature operation
435+ *
436+ * @category Vital
437+ * @param name - Name of the operation step
438+ * @param options - Options for the operation step (operationKey, context, description)
439+ */
440+ startFeatureOperation : ( name : string , options ?: FeatureOperationOptions ) => void
441+
442+ /**
443+ * [Experimental] succeed a feature operation
444+ *
445+ * @category Vital
446+ * @param name - Name of the operation step
447+ * @param options - Options for the operation step (operationKey, context, description)
448+ */
449+ succeedFeatureOperation : ( name : string , options ?: FeatureOperationOptions ) => void
450+
451+ /**
452+ * [Experimental] fail a feature operation
453+ *
454+ * @category Vital
455+ * @param name - Name of the operation step
456+ * @param failureReason
457+ * @param options - Options for the operation step (operationKey, context, description)
458+ */
459+ failFeatureOperation : ( name : string , failureReaon : FailureReason , options ?: FeatureOperationOptions ) => void
430460}
431461
432462export interface RecorderApi {
@@ -494,6 +524,7 @@ export interface Strategy {
494524 startDurationVital : StartRumResult [ 'startDurationVital' ]
495525 stopDurationVital : StartRumResult [ 'stopDurationVital' ]
496526 addDurationVital : StartRumResult [ 'addDurationVital' ]
527+ addOperationStepVital : StartRumResult [ 'addOperationStepVital' ]
497528}
498529
499530export function makeRumPublicApi (
@@ -771,6 +802,21 @@ export function makeRumPublicApi(
771802 description : sanitize ( options && options . description ) as string | undefined ,
772803 } )
773804 } ) ,
805+
806+ startFeatureOperation : monitor ( ( name , options ) => {
807+ addTelemetryUsage ( { feature : 'add-operation-step-vital' , action_type : 'start' } )
808+ strategy . addOperationStepVital ( name , 'start' , options )
809+ } ) ,
810+
811+ succeedFeatureOperation : monitor ( ( name , options ) => {
812+ addTelemetryUsage ( { feature : 'add-operation-step-vital' , action_type : 'succeed' } )
813+ strategy . addOperationStepVital ( name , 'end' , options )
814+ } ) ,
815+
816+ failFeatureOperation : monitor ( ( name , failureReason , options ) => {
817+ addTelemetryUsage ( { feature : 'add-operation-step-vital' , action_type : 'fail' } )
818+ strategy . addOperationStepVital ( name , 'end' , options , failureReason )
819+ } ) ,
774820 } )
775821
776822 return rumPublicApi
0 commit comments