Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/more protocol #155

Merged
merged 53 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
11f62b6
add sentry protocol Request
rxlabz Oct 30, 2020
a237e0c
add sentry protocol Mechanism
rxlabz Oct 30, 2020
5c4c83d
fix helpLInk serialization key
rxlabz Nov 2, 2020
9065f48
use dynamic instead of Object
rxlabz Nov 2, 2020
cd3a749
add SentryException, SentryStrackTrace and SentryStackFrame
rxlabz Nov 2, 2020
f03bce5
add SentryExceptionFactory and SentryStrackTraceFactory
rxlabz Nov 2, 2020
93b98bc
feedbacks
rxlabz Nov 3, 2020
8dd353f
event throwable & stacktrace
rxlabz Nov 3, 2020
f84b1ec
- add a default stacktrace factory
rxlabz Nov 3, 2020
a2a9e9c
fix stackFrame lineNo & colNo case and type
rxlabz Nov 4, 2020
a1c1966
do not expose the stacktraceFactory
rxlabz Nov 4, 2020
efacef6
make SentryException fields final
rxlabz Nov 4, 2020
92f3ae5
- make SentryStackFrame immutable
rxlabz Nov 4, 2020
5b9065a
immutable SentryStackTrace
rxlabz Nov 4, 2020
5589888
SentryStackTrace.copyWith
rxlabz Nov 4, 2020
8fdafa5
SentryStackTraceFactory : docs and @visibleForTesting encodeStackTrac…
rxlabz Nov 5, 2020
0430bb5
remove origin field
rxlabz Nov 5, 2020
6eac349
SentryStackFrame.copyWith
rxlabz Nov 5, 2020
0a00d78
- immutable Mechanism
rxlabz Nov 5, 2020
b83c975
minor
rxlabz Nov 5, 2020
18a61e7
feedbacks
rxlabz Nov 5, 2020
ae98e29
Merge remote-tracking branch 'origin/main' into feat/more-protocol
rxlabz Nov 5, 2020
9772d29
immutable request
rxlabz Nov 5, 2020
f288106
immutable request.data if list or map
rxlabz Nov 5, 2020
0549a07
not override event.exception
rxlabz Nov 5, 2020
3ae8f50
- SentryStackTraceFactory : add _inAppExcludes & _inAppExcludes
rxlabz Nov 5, 2020
fe5f517
isInApp(frame.uri.scheme)
rxlabz Nov 5, 2020
2853bfc
SentryStackTraceFactory.isInApp
rxlabz Nov 5, 2020
ca307e0
SentryStackTraceFactory.isInApp & fix tests
rxlabz Nov 5, 2020
fa050f5
isInApp verification order
rxlabz Nov 5, 2020
ac07436
- add DebugMeta, DebugImage, SdkInfo classes
rxlabz Nov 6, 2020
76927a4
add SentryEvent.debugMeta
rxlabz Nov 6, 2020
f142a1b
add 'Sentry prefix' where missing
rxlabz Nov 6, 2020
4119eea
rename "exception" argument to "throwable"
rxlabz Nov 6, 2020
dabf285
add a sentryException to SentryClient ctor
rxlabz Nov 6, 2020
fcb2767
not send lineNo or ColNo < 0 + changelog
rxlabz Nov 6, 2020
eed8ddc
fix tests
rxlabz Nov 6, 2020
78894e0
non nullable options
rxlabz Nov 6, 2020
28ceb93
non nullable options in exception and stacktrace factories
rxlabz Nov 6, 2020
cc0327c
exception serialization
rxlabz Nov 6, 2020
1055820
ArgumentError.notNull to ArgumentError(msg)
rxlabz Nov 6, 2020
317eb6f
fix tests
rxlabz Nov 6, 2020
6e43709
add tests and fixes
rxlabz Nov 9, 2020
a814692
fix tests
rxlabz Nov 9, 2020
2898047
add debug meta serialization test
rxlabz Nov 9, 2020
25e42e8
add inApp includes & excludes tests
rxlabz Nov 9, 2020
7397402
add inApp includes precedence test + doc
rxlabz Nov 9, 2020
6f445cc
tests description rewording
rxlabz Nov 9, 2020
3719ed3
null pointer
rxlabz Nov 9, 2020
6f1babb
event.stacktrace should not be override test
rxlabz Nov 9, 2020
7d0c017
add event.stacktrace tests
rxlabz Nov 9, 2020
f63cd73
feedback : fix imports
rxlabz Nov 9, 2020
bf134b8
fix imports
rxlabz Nov 9, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
## 4.0.0-alpha.2

- feat: add contexts to scope
- feat: add missing protocol classes
- fix: logger method and refactoring little things
- fix: sentry protocol is v7

Expand Down
2 changes: 1 addition & 1 deletion dart/example/event_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final event = SentryEvent(
'Linux version 3.4.39-5726670 (dpi@SWHC3807) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Thu Dec 1 19:42:39 KST 2016',
rooted: false,
),
runtimes: [const Runtime(name: 'ART', version: '5')],
runtimes: [const SentryRuntime(name: 'ART', version: '5')],
app: App(
name: 'Example Dart App',
version: '1.42.0',
Expand Down
2 changes: 1 addition & 1 deletion dart/example_web/web/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final event = SentryEvent(
'Linux version 3.4.39-5726670 (dpi@SWHC3807) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Thu Dec 1 19:42:39 KST 2016',
rooted: false,
),
runtimes: [const Runtime(name: 'ART', version: '5')],
runtimes: [const SentryRuntime(name: 'ART', version: '5')],
app: App(
name: 'Example Dart App',
version: '1.42.0',
Expand Down
12 changes: 6 additions & 6 deletions dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class Hub {

static void _validateOptions(SentryOptions options) {
if (options == null) {
throw ArgumentError.notNull('SentryOptions is required.');
throw ArgumentError('SentryOptions is required.');
}

if (options.dsn?.isNotEmpty != true) {
throw ArgumentError.notNull('DSN is required.');
throw ArgumentError('DSN is required.');
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ class Hub {

/// Captures the exception
Future<SentryId> captureException(
dynamic exception, {
dynamic throwable, {
dynamic stackTrace,
dynamic hint,
}) async {
Expand All @@ -107,7 +107,7 @@ class Hub {
SentryLevel.warning,
"Instance is disabled and this 'captureException' call is a no-op.",
);
} else if (exception == null) {
} else if (throwable == null) {
_options.logger(
SentryLevel.warning,
'captureException called with null parameter.',
Expand All @@ -117,15 +117,15 @@ class Hub {
if (item != null) {
try {
sentryId = await item.client.captureException(
exception,
throwable,
stackTrace: stackTrace,
scope: item.scope,
hint: hint,
);
} catch (err) {
_options.logger(
SentryLevel.error,
'Error while capturing exception : ${exception}',
'Error while capturing exception : ${throwable}',
);
} finally {
_lastEventId = sentryId;
Expand Down
4 changes: 2 additions & 2 deletions dart/lib/src/hub_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class HubAdapter implements Hub {

@override
Future<SentryId> captureException(
dynamic exception, {
dynamic throwable, {
dynamic stackTrace,
dynamic hint,
}) =>
Sentry.captureException(
exception,
throwable,
stackTrace: stackTrace,
hint: hint,
);
Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/noop_hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NoOpHub implements Hub {

@override
Future<SentryId> captureException(
dynamic exception, {
dynamic throwable, {
dynamic stackTrace,
dynamic hint,
}) =>
Expand Down
15 changes: 11 additions & 4 deletions dart/lib/src/protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ export 'protocol/app.dart';
export 'protocol/breadcrumb.dart';
export 'protocol/browser.dart';
export 'protocol/contexts.dart';
export 'protocol/debug_image.dart';
export 'protocol/debug_meta.dart';
export 'protocol/device.dart';
export 'protocol/dsn.dart';
export 'protocol/gpu.dart';
export 'protocol/mechanism.dart';
export 'protocol/message.dart';
export 'protocol/package.dart';
export 'protocol/runtime.dart';
export 'protocol/sdk.dart';
export 'protocol/operating_system.dart';
export 'protocol/sdk_info.dart';
export 'protocol/sdk_version.dart';
export 'protocol/sentry_event.dart';
export 'protocol/sentry_exception.dart';
export 'protocol/sentry_id.dart';
export 'protocol/sentry_level.dart';
export 'protocol/system.dart';
export 'protocol/sentry_package.dart';
export 'protocol/sentry_runtime.dart';
export 'protocol/sentry_stack_frame.dart';
export 'protocol/sentry_stack_trace.dart';
export 'protocol/user.dart';
25 changes: 14 additions & 11 deletions dart/lib/src/protocol/contexts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'app.dart';
import 'browser.dart';
import 'device.dart';
import 'gpu.dart';
import 'runtime.dart';
import 'sentry_runtime.dart';

/// The context interfaces provide additional context data.
///
Expand All @@ -17,14 +17,14 @@ class Contexts extends MapView<String, dynamic> {
Contexts({
Device device,
OperatingSystem operatingSystem,
List<Runtime> runtimes,
List<SentryRuntime> runtimes,
App app,
Browser browser,
Gpu gpu,
}) : super({
Device.type: device,
OperatingSystem.type: operatingSystem,
Runtime.listType: runtimes ?? [],
SentryRuntime.listType: runtimes ?? [],
App.type: app,
Browser.type: browser,
Gpu.type: gpu,
Expand All @@ -47,11 +47,14 @@ class Contexts extends MapView<String, dynamic> {
/// Describes a list of runtimes in more detail
/// (for instance if you have a Flutter application running
/// on top of Android).
List<Runtime> get runtimes => List.unmodifiable(this[Runtime.listType]);
List<SentryRuntime> get runtimes =>
List.unmodifiable(this[SentryRuntime.listType]);

void addRuntime(Runtime runtime) => this[Runtime.listType].add(runtime);
void addRuntime(SentryRuntime runtime) =>
this[SentryRuntime.listType].add(runtime);

void removeRuntime(Runtime runtime) => this[Runtime.listType].remove(runtime);
void removeRuntime(SentryRuntime runtime) =>
this[SentryRuntime.listType].remove(runtime);

/// App context describes the application.
///
Expand Down Expand Up @@ -116,12 +119,12 @@ class Contexts extends MapView<String, dynamic> {
}
break;

case Runtime.listType:
case SentryRuntime.listType:
if (runtimes != null) {
if (runtimes.length == 1) {
final runtime = runtimes[0];
if (runtime != null) {
final key = runtime.key ?? Runtime.type;
final key = runtime.key ?? SentryRuntime.type;
json[key] = runtime.toJson();
}
} else if (runtimes.length > 1) {
Expand All @@ -138,7 +141,7 @@ class Contexts extends MapView<String, dynamic> {
}

json[key] = runtime.toJson()
..addAll(<String, String>{'type': Runtime.type});
..addAll(<String, String>{'type': SentryRuntime.type});
}
}
}
Expand Down Expand Up @@ -173,8 +176,8 @@ class Contexts extends MapView<String, dynamic> {
App.type,
Device.type,
OperatingSystem.type,
Runtime.listType,
Runtime.type,
SentryRuntime.listType,
SentryRuntime.type,
Gpu.type,
Browser.type,
];
Expand Down
113 changes: 113 additions & 0 deletions dart/lib/src/protocol/debug_image.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/// The list of debug images contains all dynamic libraries loaded into
/// the process and their memory addresses.
/// Instruction addresses in the Stack Trace are mapped into the list of debug
/// images in order to retrieve debug files for symbolication.
/// There are two kinds of debug images:
//
/// Native debug images with types macho, elf, and pe
/// Android debug images with type proguard
/// more details : https://develop.sentry.dev/sdk/event-payloads/debugmeta/
class DebugImage {
final String uuid;

/// Required. Type of the debug image. Must be "macho".
final String type;

/// Required. Identifier of the dynamic library or executable. It is the value of the LC_UUID load command in the Mach header, formatted as UUID.
final String debugId;

/// Required. Memory address, at which the image is mounted in the virtual address space of the process.
/// Should be a string in hex representation prefixed with "0x".
final String imageAddr;

/// Required. The size of the image in virtual memory. If missing, Sentry will assume that the image spans up to the next image, which might lead to invalid stack traces.
final int imageSize;

/// OptionalName or absolute path to the dSYM file containing debug information for this image. This value might be required to retrieve debug files from certain symbol servers.
final String debugFile;

/// Optional. The absolute path to the dynamic library or executable. This helps to locate the file if it is missing on Sentry.
final String codeFile;

/// Optional Architecture of the module. If missing, this will be backfilled by Sentry.
final String arch;

/// Optional. Identifier of the dynamic library or executable. It is the value of the LC_UUID load command in the Mach header, formatted as UUID. Can be empty for Mach images, as it is equivalent to the debug identifier.
final String codeId;

DebugImage({
this.type,
this.imageAddr,
this.debugId,
this.debugFile,
this.imageSize,
this.uuid,
this.codeFile,
this.arch,
this.codeId,
});

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

if (uuid != null) {
json['uuid'] = uuid;
}

if (type != null) {
json['type'] = type;
}

if (debugId != null) {
json['debug_id'] = debugId;
}

if (debugFile != null) {
json['debug_file'] = debugFile;
}

if (codeFile != null) {
json['codeFile'] = codeFile;
}

if (imageAddr != null) {
json['image_addr'] = imageAddr;
}

if (imageSize != null) {
json['imageSize'] = imageSize;
}

if (arch != null) {
json['arch'] = arch;
}

if (codeId != null) {
json['codeId'] = codeId;
}

return json;
}

DebugImage copyWith({
String uuid,
String type,
String debugId,
String debugFile,
String codeFile,
String imageAddr,
int imageSize,
String arch,
String codeId,
}) =>
DebugImage(
uuid: uuid ?? this.uuid,
type: type ?? this.type,
debugId: debugId ?? this.debugId,
codeFile: codeFile ?? this.codeFile,
imageAddr: imageAddr ?? this.imageAddr,
imageSize: imageSize ?? this.imageSize,
arch: arch ?? this.arch,
codeId: codeId ?? this.codeId,
);
}
31 changes: 31 additions & 0 deletions dart/lib/src/protocol/debug_meta.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import '../protocol.dart';

/// The debug meta interface carries debug information for processing errors and crash reports.
class DebugMeta {
/// An object describing the system SDK.
final SdkInfo sdk;

final List<DebugImage> _images;

/// An immutable list of dynamic libraries loaded into the process (see below).
List<DebugImage> get images => List.unmodifiable(_images);

DebugMeta({this.sdk, List<DebugImage> images}) : _images = images;

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

if (sdk != null) {
json['sdk_info'] = sdk.toJson();
}

if (_images != null && _images.isNotEmpty) {
json['images'] = _images.map((e) => e.toJson());
}

return json;
}

DebugMeta copyWith({SdkVersion sdk, List<DebugImage> images}) =>
DebugMeta(sdk: sdk ?? this.sdk, images: images ?? _images);
}
Loading