Recipes
Reveal safe diagnostic data
Opt in only the State and Command fields that are safe to inspect.
v0.1.0-dev.3Intermediateusecase_forge_devtools
Open source reference ↗Reveal safe diagnostic data
Technical lifecycle metadata is available automatically. Application values remain hidden until the UseCase explicitly encodes a JSON-safe representation.
dart
final class CartUseCase extends UseCase<CartState>
with UseCaseDiagnosticsDataProvider {
@override
Object? encodeUseCaseDiagnosticValue(
UseCaseDiagnosticValueKind kind,
Object? value,
) {
if (kind == UseCaseDiagnosticValueKind.state && value is CartState) {
return {'itemCount': value.itemCount};
}
return null;
}
}
Import package:usecase_forge/diagnostics.dart. Return null for secrets, tokens, personal data, large payloads, and types that are not needed for the investigation. A formatter failure is isolated from Command execution.