Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6fcd45f
draft
marandaneto Nov 3, 2020
4077a7b
fix conflict
marandaneto Nov 3, 2020
9fd04ba
set staging if not release mode
marandaneto Nov 3, 2020
d748ec4
clean up
marandaneto Nov 3, 2020
84d9559
Update flutter/lib/sentry_flutter.dart
marandaneto Nov 3, 2020
103bded
remove comment
marandaneto Nov 3, 2020
0a999f3
set flutter sdk on options
marandaneto Nov 4, 2020
b6e4967
Merge branch 'main' into feat/flutter-native
marandaneto Nov 4, 2020
319f89d
Merge branch 'feat/flutter-native' of github.com:getsentry/sentry-dar…
marandaneto Nov 4, 2020
d26c716
draft
marandaneto Nov 4, 2020
9b250b3
remove
marandaneto Nov 4, 2020
59f7ea7
fix
marandaneto Nov 4, 2020
9133a3e
init native sdk draft
marandaneto Nov 5, 2020
c96db31
write envelope
marandaneto Nov 5, 2020
1a2c2f3
stack trace fixes
marandaneto Nov 5, 2020
6242992
fixes
marandaneto Nov 6, 2020
eaad8ef
upgrade versions
marandaneto Nov 6, 2020
93517d4
fix
marandaneto Nov 6, 2020
e5aab67
bump android
marandaneto Nov 6, 2020
6d7821d
fix git conflict
marandaneto Nov 10, 2020
f8bd11d
fix tests
marandaneto Nov 10, 2020
3d7055a
fixes
marandaneto Nov 10, 2020
25edde3
fix
marandaneto Nov 10, 2020
81ddf3e
clean up
marandaneto Nov 10, 2020
a16e4a1
ref
marandaneto Nov 10, 2020
d879c50
debug
marandaneto Nov 11, 2020
a860ee3
fix
marandaneto Nov 11, 2020
7562bf4
Merge remote-tracking branch 'origin/main' into feat/flutter-native
rxlabz Nov 12, 2020
1bd8324
post conflict dartformt
rxlabz Nov 12, 2020
27b8ee9
fix import
rxlabz Nov 12, 2020
e48f974
fix: android native integration (#163)
marandaneto Nov 17, 2020
158c963
Fix: Handled mechanism is true and fix samples (#165)
marandaneto Nov 18, 2020
4486897
Fix: Flutter Web does not require a native integration (#166)
marandaneto Nov 18, 2020
0d13722
Tests: unit tests for the native integrations (#167)
marandaneto Nov 19, 2020
8c073bf
Ref: remove lock files (#168)
marandaneto Nov 20, 2020
bcfcc07
Fix: set Dart and Flutter min version (#170)
marandaneto Nov 20, 2020
457435b
Fix: read system variables for mobile too (#169)
marandaneto Nov 20, 2020
b75d9d4
Fix: README on Dart and Flutter SDKs (#171)
marandaneto Nov 20, 2020
c05fcbf
flutter native ios (#161)
rxlabz Nov 20, 2020
e34fd3c
Fix: CHANGELOG for sentry and sentry_flutter (#173)
marandaneto Nov 20, 2020
f8d38d8
Fix: Changelog and READMEs (#174)
marandaneto Nov 20, 2020
07b462c
fix readme
marandaneto Nov 20, 2020
eed57c0
add known limitations section
marandaneto Nov 20, 2020
960946b
remove deadcode
marandaneto Nov 20, 2020
9d4a7c8
Fix: flutter versioniong and its dependency version (#172)
marandaneto Nov 20, 2020
b199361
hack pass CI
marandaneto Nov 20, 2020
f36fb53
fix main.dart example and update readme (#176)
rxlabz Nov 20, 2020
8ea9a69
Ref: create a export file for sentry_flutter (#175)
marandaneto Nov 20, 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
debug
  • Loading branch information
marandaneto committed Nov 11, 2020
commit d879c504c09ce85392a89e7cca62d1cb28517ec1
5 changes: 4 additions & 1 deletion dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ class SentryClient {
);
}
if (event == null) {
_options.logger(SentryLevel.debug, 'Event was dropped by a processor');
_options.logger(
SentryLevel.debug,
'Event was dropped by BeforeSend callback',
);
return _sentryId;
}
}
Expand Down
2 changes: 2 additions & 0 deletions dart/lib/src/sentry_exception_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'throwable_mechanism.dart';
/// class to convert Dart Error and exception to SentryException
class SentryExceptionFactory {
SentryStackTraceFactory _stacktraceFactory;
SentryOptions _options;

SentryExceptionFactory({
SentryStackTraceFactory stacktraceFactory,
Expand All @@ -17,6 +18,7 @@ class SentryExceptionFactory {
throw ArgumentError('SentryOptions is required.');
}

_options = options;
_stacktraceFactory = stacktraceFactory ?? SentryStackTraceFactory(options);
}

Expand Down
55 changes: 38 additions & 17 deletions dart/lib/src/sentry_stack_trace_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,13 @@ import 'sentry_options.dart';

/// converts [StackTrace] to [SentryStackFrames]
class SentryStackTraceFactory {
/// A list of string prefixes of module names that do not belong to the app, but rather third-party
/// packages. Modules considered not to be part of the app will be hidden from stack traces by
/// default.
List<String> _inAppExcludes;

/// A list of string prefixes of module names that belong to the app. This option takes precedence
/// over inAppExcludes.
List<String> _inAppIncludes;
SentryOptions _options;

SentryStackTraceFactory(SentryOptions options) {
if (options == null) {
throw ArgumentError('SentryOptions is required.');
}

_inAppExcludes = options.inAppExcludes;
_inAppIncludes = options.inAppIncludes;
_options = options;
}

/// returns the [SentryStackFrame] list from a stackTrace ([StackTrace] or [String])
Expand All @@ -34,6 +25,20 @@ class SentryStackTraceFactory {
? Chain.forTrace(stackTrace)
: Chain.parse(stackTrace as String);

// if strip symbols are enabled, thats what we see:
// warning: This VM has been configured to produce stack traces that violate the Dart standard.
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// unparsed pid: 30930, tid: 30990, name 1.ui
// unparsed build_id: '5346e01103ffeed44e97094ff7bfcc19'
// unparsed isolate_dso_base: 723d447000, vm_dso_base: 723d447000
// unparsed isolate_instructions: 723d452000, vm_instructions: 723d449000
// unparsed #00 abs 000000723d6346d7 virt 00000000001ed6d7 _kDartIsolateSnapshotInstructions+0x1e26d7
// unparsed #01 abs 000000723d637527 virt 00000000001f0527 _kDartIsolateSnapshotInstructions+0x1e5527
// unparsed #02 abs 000000723d4a41a7 virt 000000000005d1a7 _kDartIsolateSnapshotInstructions+0x521a7
// unparsed #03 abs 000000723d624663 virt 00000000001dd663 _kDartIsolateSnapshotInstructions+0x1d2663
// unparsed #04 abs 000000723d4b8c3b virt 0000000000071c3b _kDartIsolateSnapshotInstructions+0x66c3b
// unparsed #05 abs 000000723d5ffe27 virt 00000000001b8e27 _kDartIsolateSna

final frames = <SentryStackFrame>[];
for (var t = 0; t < chain.traces.length; t += 1) {
final encodedFrames =
Expand All @@ -52,16 +57,29 @@ class SentryStackTraceFactory {
/// converts [Frame] to [SentryStackFrame]
@visibleForTesting
SentryStackFrame encodeStackTraceFrame(Frame frame) {
_options.logger(SentryLevel.debug,
'frame uri: ${frame.uri}'); // warning if split symbols
_options.logger(SentryLevel.debug,
'frame uri segs: ${frame.uri.pathSegments}'); // segs []
final fileName =
frame.uri.pathSegments.isNotEmpty ? frame.uri.pathSegments.last : null;

_options.logger(SentryLevel.debug, 'file name: ${fileName}');

final abs = '$eventOrigin${_absolutePathForCrashReport(frame)}';
_options.logger(SentryLevel.debug, 'abs: ${abs}');
_options.logger(SentryLevel.debug, 'member: ${frame.member}');
_options.logger(SentryLevel.debug, 'inapp: ${isInApp(frame)}');
_options.logger(SentryLevel.debug, 'package: ${frame.package}');

var sentryStackFrame = SentryStackFrame(
absPath: '$eventOrigin${_absolutePathForCrashReport(frame)}',
absPath: abs,
function: frame.member,
// https://docs.sentry.io/development/sdk-dev/features/#in-app-frames
inApp: isInApp(frame),
fileName: fileName,
package: frame.package,
platform: 'native', // TODO: only if necessary to symbolicate
);

if (frame.line != null && frame.line >= 0) {
Expand All @@ -84,7 +102,10 @@ class SentryStackTraceFactory {
/// "dart:" and "package:" imports are always relative and are OK to send in
/// full.
String _absolutePathForCrashReport(Frame frame) {
if (frame.uri.scheme != 'dart' && frame.uri.scheme != 'package') {
_options.logger(SentryLevel.debug, 'scheme ${frame.uri.scheme}');
if (frame.uri.scheme != 'dart' &&
frame.uri.scheme != 'package' &&
frame.uri.pathSegments.isNotEmpty) {
return frame.uri.pathSegments.last;
}

Expand All @@ -99,15 +120,15 @@ class SentryStackTraceFactory {
return true;
}

if (_inAppIncludes != null) {
for (final include in _inAppIncludes) {
if (_options.inAppIncludes != null) {
for (final include in _options.inAppIncludes) {
if (frame.package != null && frame.package.startsWith(include)) {
return true;
}
}
}
if (_inAppExcludes != null) {
for (final exclude in _inAppExcludes) {
if (_options.inAppExcludes != null) {
for (final exclude in _options.inAppExcludes) {
if (frame.package != null && frame.package.startsWith(exclude)) {
return false;
}
Expand Down
10 changes: 0 additions & 10 deletions dart/test/exception_factory_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ void main() {
try {
throw StateError('a state error');
} catch (err, stacktrace) {
final mechanism = Mechanism(
type: 'example',
description: 'a mechanism',
);
sentryException = exceptionFactory.getSentryException(
err,
mechanism: mechanism,
stackTrace: stacktrace,
);
}
Expand All @@ -31,13 +26,8 @@ void main() {
try {
throw StateError('a state error');
} catch (err) {
final mechanism = Mechanism(
type: 'example',
description: 'a mechanism',
);
sentryException = exceptionFactory.getSentryException(
err,
mechanism: mechanism,
stackTrace: '''
#0 baz (file:///pathto/test.dart:50:3)
<asynchronous suspension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import android.content.Context
import io.sentry.SentryEvent
import io.sentry.SentryLevel
import io.sentry.SentryOptions
//import io.sentry.protocol.DebugImage
//import io.sentry.protocol.DebugMeta
import io.sentry.protocol.SdkVersion
import java.io.File
import java.util.UUID
Expand Down Expand Up @@ -115,11 +117,21 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler {
options.isEnableNdk = false
}

// var debugImage: DebugMeta? = null

options.setBeforeSend { event, _ ->
setEventOriginTag(event)
addPackages(event, options.sdkVersion)
removeThreadsIfNotAndroid(event)

// if (event.debugMeta != null &&
// debugImage == null &&
// event.debugMeta.images != null &&
// event.debugMeta.images.isNotEmpty()) {
// debugImage = event.debugMeta
// }
// addDebugImagesIfFlutterEvent(event, debugImage)

event
}

Expand Down Expand Up @@ -192,4 +204,13 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler {
}
}
}

// private fun addDebugImagesIfFlutterEvent(event: SentryEvent, meta: DebugMeta?) {
// if (isValidSdk(event.sdk)) {
// // cal sentry-native to load debug meta
// if (event.sdk.name == "sentry.dart.flutter" && meta != null && event.debugMeta == null) {
// event.debugMeta = meta
// }
// }
// }
}
14 changes: 7 additions & 7 deletions flutter/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ apply plugin: 'com.ydq.android.gradle.native-aar.import'

// uncomment this to upload proguard mapping file and debug symbols to Sentry
// and also set the token (sentry.properties) file
apply plugin: 'io.sentry.android.gradle'
//apply plugin: 'io.sentry.android.gradle'

android {
compileOptions {
Expand Down Expand Up @@ -73,8 +73,8 @@ android {

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// minifyEnabled true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
}
Expand All @@ -92,7 +92,7 @@ dependencies {
}

// uncomment this to upload debug symbols to Sentry
sentry {
uploadNativeSymbols true
includeNativeSources true
}
// sentry {
// uploadNativeSymbols true
// includeNativeSources true
// }
13 changes: 13 additions & 0 deletions flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry/sentry.dart';
import 'package:universal_platform/universal_platform.dart';

const String _release =
Expand Down Expand Up @@ -72,6 +73,10 @@ class _MyAppState extends State<MyApp> {
children: [
Center(child: Text('Running on: $_platformVersion\n')),
const Center(child: Text('Release: $_release\n')),
RaisedButton(
child: const Text('Dart: try catch'),
onPressed: () => tryCatch(),
),
RaisedButton(
child: const Text('Dart: throw null'),
// Warning : not captured if a debugger is attached
Expand Down Expand Up @@ -166,6 +171,14 @@ class AndroidExample extends StatelessWidget {
}
}

Future<void> tryCatch() async {
try {
throw StateError('whats happening here');
} catch (error, stackTrace) {
await Sentry.captureException(error, stackTrace: stackTrace);
}
}

class CocoaExample extends StatelessWidget {
const CocoaExample({Key key}) : super(key: key);

Expand Down
8 changes: 8 additions & 0 deletions flutter/lib/FileSystemTransport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ class FileSystemTransport implements Transport {
'event_id': event.eventId.toString(),
'sdk': _options.sdk.toJson()
};

final eventMap = event.toJson();

final eventString = _jsonEncoder.convert(eventMap);
_options.logger(SentryLevel.debug, 'event string: $eventString');

final itemHeaderMap = {
'content_type': 'application/json',
Expand All @@ -28,9 +30,15 @@ class FileSystemTransport implements Transport {
};

final headerString = _jsonEncoder.convert(headerMap);
_options.logger(SentryLevel.debug, 'header string: $headerString');

final itemHeaderString = _jsonEncoder.convert(itemHeaderMap);
_options.logger(SentryLevel.debug, 'item header string: $itemHeaderString');

final envelopeString = '$headerString\n$itemHeaderString\n$eventString';

_options.logger(SentryLevel.debug, 'envelope string: $envelopeString');

final args = [envelopeString];
try {
await _channel.invokeMethod('captureEnvelope', args);
Expand Down
3 changes: 2 additions & 1 deletion flutter/lib/sentry_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ mixin SentryFlutter {
// our plugin can call into the native code.
WidgetsFlutterBinding.ensureInitialized();

options.debug = kDebugMode;
// options.debug = kDebugMode;
options.debug = true;

// web still uses a http transport
if (!kIsWeb) {
Expand Down