datadog-ux-utils
Version:
Datadog RUM focused UX & performance toolkit: API guards (retry, breaker, rate), React telemetry (error boundary, profiler, Suspense), web vitals & resource observers, offline queues.
47 lines • 1.71 kB
TypeScript
/**
* Starts a flow timer for a named user or app flow (e.g., "checkout", "search_to_results").
* Returns an object with `end()` and `fail()` methods to mark completion or failure.
*
* @param name - A unique name for this flow type (e.g., "checkout", "search_to_results")
* @param ctx - Optional initial context to include in all events for this flow
* @returns An object with `end()` and `fail()` methods
*
* @example
* ```ts
* const flow = startFlow("checkout", { userId });
* // ... user completes checkout
* flow.end({ orderId });
* // or, on error:
* flow.fail(new Error("Payment failed"), { step: "payment" });
* ```
*/
export declare function startFlow(name: string, ctx?: Record<string, unknown>): {
/**
* Ends the flow successfully and sends a `flow_end` action.
*
* @param extra - Optional extra context to include in the event
* @example
* flow.end({ orderId });
*/
end(extra?: Record<string, unknown>): void;
/**
* Marks the flow as failed and sends a `flow_fail` action and error telemetry.
*
* @param err - The error or reason for failure
* @param extra - Optional extra context to include in the event
* @example
* flow.fail(new Error("Payment failed"), { step: "payment" });
*/
fail(err: unknown, extra?: Record<string, unknown>): void;
};
/**
* Force-end all active flows, e.g., on route change or app teardown.
* Sends a `flow_cancel` action for each active flow.
*
* @param reason - Reason for cancellation (default: "cancelled")
*
* @example
* cancelAllFlows("route_change");
*/
export declare function cancelAllFlows(reason?: string): void;
//# sourceMappingURL=flowTimer.d.ts.map