SentryEvent.fromJson constructor
Deserializes a SentryEvent from JSON Map.
Implementation
factory SentryEvent.fromJson(Map<String, dynamic> data) {
final json = AccessAwareMap(data);
final breadcrumbsJson = json['breadcrumbs'] as List<dynamic>?;
final breadcrumbs = breadcrumbsJson
?.map((e) => Breadcrumb.fromJson(e))
.toList(growable: false);
final threadValues = json['threads']?['values'] as List<dynamic>?;
final threads = threadValues
?.map((e) => SentryThread.fromJson(e))
.toList(growable: false);
final exceptionValues = json['exception']?['values'] as List<dynamic>?;
final exceptions = exceptionValues
?.map((e) => SentryException.fromJson(e))
.toList(growable: false);
final modules = json['modules']?.cast<String, String>();
final tags = json['tags']?.cast<String, String>();
final timestampJson = json['timestamp'];
final levelJson = json['level'];
final fingerprintJson = json['fingerprint'] as List<dynamic>?;
final sdkVersionJson = json['sdk'] as Map<String, dynamic>?;
final messageJson = json['message'] as Map<String, dynamic>?;
final userJson = json['user'] as Map<String, dynamic>?;
final contextsJson = json['contexts'] as Map<String, dynamic>?;
final requestJson = json['request'] as Map<String, dynamic>?;
final debugMetaJson = json['debug_meta'] as Map<String, dynamic>?;
var extra = json['extra'];
if (extra != null) {
extra = Map<String, dynamic>.from(extra as Map);
}
return SentryEvent(
eventId: SentryId.fromId(json['event_id']),
timestamp:
timestampJson != null ? DateTime.tryParse(timestampJson) : null,
modules: modules,
tags: tags,
// ignore: deprecated_member_use_from_same_package
extra: extra,
fingerprint:
fingerprintJson?.map((e) => e as String).toList(growable: false),
breadcrumbs: breadcrumbs,
sdk: sdkVersionJson != null && sdkVersionJson.isNotEmpty
? SdkVersion.fromJson(sdkVersionJson)
: null,
platform: json['platform'],
logger: json['logger'],
serverName: json['server_name'],
release: json['release'],
dist: json['dist'],
environment: json['environment'],
message: messageJson != null && messageJson.isNotEmpty
? SentryMessage.fromJson(messageJson)
: null,
transaction: json['transaction'],
threads: threads,
level: levelJson != null ? SentryLevel.fromName(levelJson) : null,
culprit: json['culprit'],
user: userJson != null && userJson.isNotEmpty
? SentryUser.fromJson(userJson)
: null,
contexts: contextsJson != null && contextsJson.isNotEmpty
? Contexts.fromJson(contextsJson)
: null,
request: requestJson != null && requestJson.isNotEmpty
? SentryRequest.fromJson(requestJson)
: null,
debugMeta: debugMetaJson != null && debugMetaJson.isNotEmpty
? DebugMeta.fromJson(debugMetaJson)
: null,
exceptions: exceptions,
type: json['type'],
unknown: json.notAccessed(),
);
}