endFlow static method
Ends a tracked flow and records total duration.
success indicates if the flow completed successfully.
Implementation
static void endFlow(String flowName, {bool success = true}) {
final start = _activeFlows.remove(flowName);
if (start == null) {
AppConfig.logger.w('[FlowTracker] endFlow called for unstarted flow: $flowName');
return;
}
final durationMs = DateTime.now().difference(start).inMilliseconds;
AppConfig.logger.d('[FlowTracker] End: $flowName (${durationMs}ms, success=$success)');
_pendingFlows.add(_FlowEntry(
flowName: flowName,
stepName: success ? '_complete' : '_failed',
durationMs: durationMs,
userId: _userId,
timestamp: DateTime.now(),
));
_tryFlush();
}