Skip to content

Commit

Permalink
Merge branch 'main' into ref/remove-dio-failed-request-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
ueman committed Feb 10, 2022
2 parents 422a5e8 + c2893b8 commit deca26b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
12 changes: 3 additions & 9 deletions dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class SentryClient {

static final _sentryId = Future.value(SentryId.empty());

late SentryExceptionFactory _exceptionFactory;
SentryExceptionFactory get _exceptionFactory => _options.exceptionFactory;

late SentryStackTraceFactory _stackTraceFactory;
SentryStackTraceFactory get _stackTraceFactory => _options.stackTraceFactory;

/// Instantiates a client using [SentryOptions]
factory SentryClient(SentryOptions options) {
Expand All @@ -43,13 +43,7 @@ class SentryClient {

/// Instantiates a client using [SentryOptions]
SentryClient._(this._options)
: _random = _options.sampleRate == null ? null : Random() {
_stackTraceFactory = SentryStackTraceFactory(_options);
_exceptionFactory = SentryExceptionFactory(
_options,
_stackTraceFactory,
);
}
: _random = _options.sampleRate == null ? null : Random();

/// Reports an [event] to Sentry.io.
Future<SentryId> captureEvent(
Expand Down
4 changes: 2 additions & 2 deletions dart/lib/src/sentry_exception_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import 'throwable_mechanism.dart';
class SentryExceptionFactory {
final SentryOptions _options;

final SentryStackTraceFactory _stacktraceFactory;
SentryStackTraceFactory get _stacktraceFactory => _options.stackTraceFactory;

SentryExceptionFactory(this._options, this._stacktraceFactory);
SentryExceptionFactory(this._options);

SentryException getSentryException(
dynamic exception, {
Expand Down
9 changes: 9 additions & 0 deletions dart/lib/src/sentry_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'dart:developer';
import 'package:meta/meta.dart';
import 'package:http/http.dart';

import 'sentry_exception_factory.dart';
import 'sentry_stack_trace_factory.dart';
import 'diagnostic_logger.dart';
import 'environment/environment_variables.dart';
import 'event_processor.dart';
Expand Down Expand Up @@ -319,6 +321,13 @@ class SentryOptions {
bool isTracingEnabled() {
return tracesSampleRate != null || tracesSampler != null;
}

@internal
late SentryExceptionFactory exceptionFactory = SentryExceptionFactory(this);

@internal
late SentryStackTraceFactory stackTraceFactory =
SentryStackTraceFactory(this);
}

/// This function is called with an SDK specific event object and can return a modified event
Expand Down
9 changes: 8 additions & 1 deletion dart/lib/src/sentry_stack_trace_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class SentryStackTraceFactory {
static const _stackTraceViolateDartStandard =
'This VM has been configured to produce stack traces that violate the Dart standard.';

static const _sentryPackagesIdentifier = <String>[
'sentry',
'sentry_flutter',
'sentry_logging',
'sentry_dio',
];

SentryStackTraceFactory(this._options);

/// returns the [SentryStackFrame] list from a stackTrace ([StackTrace] or [String])
Expand All @@ -31,7 +38,7 @@ class SentryStackTraceFactory {

for (final frame in trace.frames) {
// we don't want to add our own frames
if (frame.package == 'sentry') {
if (_sentryPackagesIdentifier.contains(frame.package)) {
continue;
}

Expand Down
6 changes: 1 addition & 5 deletions dart/test/sentry_exception_factory_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:sentry/sentry.dart';
import 'package:sentry/src/sentry_exception_factory.dart';
import 'package:sentry/src/sentry_stack_trace_factory.dart';
import 'package:test/test.dart';

import 'mocks.dart';
Expand Down Expand Up @@ -92,9 +91,6 @@ class Fixture {
final options = SentryOptions(dsn: fakeDsn);

SentryExceptionFactory getSut() {
return SentryExceptionFactory(
options,
SentryStackTraceFactory(options),
);
return SentryExceptionFactory(options);
}
}

0 comments on commit deca26b

Please sign in to comment.