Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6083ec0
Add support for Contexts interface
Jun 15, 2019
219ff4c
Remove print statement
Jun 16, 2019
66e0ca8
Apply dartfmt
Jun 16, 2019
3fa1985
Fix batteryLevel assert
Jun 16, 2019
ff823bb
Make batteryLevel assert clearer
Jun 16, 2019
8eab7fe
Remove unused var
Jun 16, 2019
f08ef81
Add null check for runtimes
Jun 16, 2019
754c294
Fix Browser not being serialized properly
Jun 16, 2019
d165cdd
Add trailing commas
Sep 12, 2019
1a72e89
Specify types explicitly
Sep 12, 2019
5206b76
Rename Os to OperatingSystem
Sep 12, 2019
eaac6f5
Add link to Sentry documentation
Sep 12, 2019
ef8173b
Add blank line after first paragraph
Sep 12, 2019
1fa38fa
Fix App documentation
Sep 12, 2019
a0df7b6
Add blank line between first and second paragraphs
Sep 12, 2019
bbdee84
Merge branch 'master' into contexts
maks Jan 10, 2020
8643fc7
move contexts implementation to new base class
maks Jan 10, 2020
08e51f3
contexts test, fix bug, missing field in device
maks Jan 10, 2020
f631cc2
Merge pull request #1 from maks/contexts
wilkomanger Jan 10, 2020
a124b0b
boottime test independent of test machine timezone
maks Jan 13, 2020
0084603
Merge pull request #2 from maks/context-fix-test
wilkomanger Jan 13, 2020
1bf165b
improve contexts test based on PR feedback
maks Jan 21, 2020
795975a
bump version to 3.0.1, update Changelog
maks Jan 21, 2020
56659ee
Merge pull request #3 from maks/context-fix-test
wilkomanger Jan 23, 2020
782143b
match reported SDK version to version in pubspec
maks Jan 23, 2020
d7d63d7
Merge pull request #4 from maks/context-fix-test
wilkomanger Jan 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply dartfmt
  • Loading branch information
Wilko Manger committed Jun 16, 2019
commit 66e0ca842d669c6bd0e7e4df87115fd025c56f01
158 changes: 66 additions & 92 deletions lib/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -300,22 +300,21 @@ class Event {
static const String defaultFingerprint = '{{ default }}';

/// Creates an event.
const Event({
this.loggerName,
this.serverName,
this.release,
this.environment,
this.message,
this.exception,
this.stackTrace,
this.level,
this.culprit,
this.tags,
this.extra,
this.fingerprint,
this.userContext,
this.contexts
});
const Event(
{this.loggerName,
this.serverName,
this.release,
this.environment,
this.message,
this.exception,
this.stackTrace,
this.level,
this.culprit,
this.tags,
this.extra,
this.fingerprint,
this.userContext,
this.contexts});

/// The logger that logged the event.
final String loggerName;
Expand Down Expand Up @@ -432,8 +431,7 @@ class Event {
if (extra != null && extra.isNotEmpty) json['extra'] = extra;

Map<String, dynamic> contextsMap;
if (contexts != null &&
(contextsMap = contexts.toJson()).isNotEmpty)
if (contexts != null && (contextsMap = contexts.toJson()).isNotEmpty)
json['contexts'] = contextsMap;

Map<String, dynamic> userContextMap;
Expand Down Expand Up @@ -535,18 +533,11 @@ class Contexts {
/// agent of a web request that triggered the event.
final Browser browser;

const Contexts({
this.device,
this.os,
this.runtimes,
this.app,
this.browser
});
const Contexts({this.device, this.os, this.runtimes, this.app, this.browser});

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {

final Map<String, dynamic > json = { };
final Map<String, dynamic> json = {};

Map<String, dynamic> deviceMap;
if (device != null && (deviceMap = device.toJson()).isNotEmpty) {
Expand Down Expand Up @@ -588,10 +579,7 @@ class Contexts {
}
}

json[key] = runtime.toJson()
..addAll({
"type": "runtime"
});
json[key] = runtime.toJson()..addAll({"type": "runtime"});

i++;
}
Expand Down Expand Up @@ -684,37 +672,36 @@ class Device {
/// The timezone of the device, e.g.: `Europe/Vienna`.
final String timezone;

const Device({
this.name,
this.family,
this.model,
this.modelId,
this.arch,
this.batteryLevel,
this.orientation,
this.manufacturer,
this.brand,
this.screenResolution,
this.screenDensity,
this.screenDpi,
this.online,
this.charging,
this.lowMemory,
this.simulator,
this.memorySize,
this.freeMemory,
this.usableMemory,
this.storageSize,
this.freeStorage,
this.externalStorageSize,
this.externalFreeStorage,
this.bootTime,
this.timezone
}) : assert(batteryLevel >= 0 && batteryLevel <= 100);
const Device(
{this.name,
this.family,
this.model,
this.modelId,
this.arch,
this.batteryLevel,
this.orientation,
this.manufacturer,
this.brand,
this.screenResolution,
this.screenDensity,
this.screenDpi,
this.online,
this.charging,
this.lowMemory,
this.simulator,
this.memorySize,
this.freeMemory,
this.usableMemory,
this.storageSize,
this.freeStorage,
this.externalStorageSize,
this.externalFreeStorage,
this.bootTime,
this.timezone})
: assert(batteryLevel >= 0 && batteryLevel <= 100);

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {

final Map<String, dynamic> json = {};

String orientation;
Expand Down Expand Up @@ -784,10 +771,7 @@ class Device {
}
}

enum Orientation {
portrait,
landscape
}
enum Orientation { portrait, landscape }

/// Describes the operating system on which the event was created.
/// In web contexts, this is the operating system of the browse
Expand All @@ -814,14 +798,13 @@ class Os {
/// version from this string, if they are not explicitly given.
final String rawDescription;

const Os({
this.name,
this.version,
this.build,
this.kernelVersion,
this.rooted,
this.rawDescription
});
const Os(
{this.name,
this.version,
this.build,
this.kernelVersion,
this.rooted,
this.rawDescription});

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
Expand All @@ -848,7 +831,6 @@ class Os {
/// are involved (for instance if you have a JavaScript application running
/// on top of JVM).
class Runtime {

/// Key used in the JSON and which will be displayed
/// in the Sentry UI. Defaults to lower case version of [name].
///
Expand All @@ -866,12 +848,8 @@ class Runtime {
/// and version from this string, if they are not explicitly given.
final String rawDescription;

const Runtime({
this.key,
this.name,
this.version,
this.rawDescription
}) : assert(key == null || key.length >= 1);
const Runtime({this.key, this.name, this.version, this.rawDescription})
: assert(key == null || key.length >= 1);

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
Expand Down Expand Up @@ -913,15 +891,14 @@ class App {
/// Application specific device identifier.
final String deviceAppHash;

const App({
this.name,
this.version,
this.identifier,
this.build,
this.buildType,
this.startTime,
this.deviceAppHash
});
const App(
{this.name,
this.version,
this.identifier,
this.build,
this.buildType,
this.startTime,
this.deviceAppHash});

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
Expand Down Expand Up @@ -955,10 +932,7 @@ class Browser {
/// Human readable application version, as it appears on the platform.
final String version;

const Browser({
this.name,
this.version
});
const Browser({this.name, this.version});

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
Expand All @@ -970,4 +944,4 @@ class Browser {

return json;
}
}
}