install static method
DVCrashReporting?
install({
- required String appId,
- required String release,
- required DVProcessRole role,
- required DVCrashStore store,
- required String installId,
- DVCrashConfig config = const DVCrashConfig(),
- DVCrashSink? sink,
- String? platform,
- void onDiagnostic()?,
Installs the reporter for appId at release in a role process.
Returns null, having said DV-CRASH-009, when config disables this
build. store and installId come from the caller, because working
them out needs a file system this library does not assume.
Implementation
static DVCrashReporting? install({
required String appId,
required String release,
required DVProcessRole role,
required DVCrashStore store,
required String installId,
DVCrashConfig config = const DVCrashConfig(),
DVCrashSink? sink,
String? platform,
void Function(String code, String message)? onDiagnostic,
}) {
const bool product = bool.fromEnvironment('dart.vm.product');
const bool profile = bool.fromEnvironment('dart.vm.profile');
final DVCrashBuildMode mode = product
? DVCrashBuildMode.release
: profile
? DVCrashBuildMode.profile
: DVCrashBuildMode.debug;
if (!config.enabledIn(mode)) {
_reporter = null;
(onDiagnostic ?? dvLogCrashDiagnostic)(
'DV-CRASH-009',
'crash reporting is disabled for ${mode.name} builds of $appId, as '
'dartvel.crashes declares',
);
return null;
}
final DVCrashReporting reporter = DVCrashReporting(
store: store,
sink: sink,
context: () => DVCrashContext(
release: release,
installId: installId,
platform: platform,
deviceClass: 'server',
role: role.name,
),
breadcrumbs: config.breadcrumbs,
nonFatalSampleRate: config.nonFatalSampleRate,
fullReportsPerRelease: config.fullReportsPerRelease,
flags: dvCrashFlagsSnapshot,
onDiagnostic: onDiagnostic,
)..install();
_reporter = reporter;
_queueSend();
return reporter;
}