dvCrashFlagsSnapshot function
Every declared flag's answer right now, for a crash report.
Through DVFlags.peek, so taking it records no exposure — a crash does not count somebody into an experiment — reports no diagnostic, and pins nothing. Enum values by name, so the report is JSON. Empty rather than a throw when the evaluation context cannot be read: this runs inside the handler.
Implementation
Map<String, Object?> dvCrashFlagsSnapshot() {
try {
final DVFlagContext context = DVFlags.context();
return <String, Object?>{
for (final DVFeatureFlag<Object?> flag in DVFlags.declared)
flag.key: switch (DVFlags.peek<Object?>(flag, context: context).value) {
final Enum value => value.name,
final Object? value => value,
},
};
} on Object {
return const <String, Object?>{};
}
}