Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -45,6 +45,7 @@
- Ref: rename the `throwable` argument name to `exception` in `captureEvents(...)`
- Ref : remove dsn from Transport public Api
- update the Dart sdk constraint
- fix : throws on invalid dsn

# `package:sentry` changelog

Expand Down
2 changes: 0 additions & 2 deletions dart/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ Future<void> main() async {
} finally {
await Sentry.close();
}

/* TODO(rxlabz) Sentry CaptureMessage(message, level) */
}

Future<void> loadConfig() async {
Expand Down
14 changes: 5 additions & 9 deletions dart/lib/src/protocol/dsn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,11 @@ class Dsn {
final uri = Uri.parse(dsn);
final userInfo = uri.userInfo.split(':');

assert(() {
if (uri.pathSegments.isEmpty) {
throw ArgumentError(
'Project ID not found in the URI path of the DSN URI: $dsn',
);
}

return true;
}());
if (uri.pathSegments.isEmpty) {
throw ArgumentError(
'Project ID not found in the URI path of the DSN URI: $dsn',
);
}

return Dsn(
publicKey: userInfo[0],
Expand Down
3 changes: 3 additions & 0 deletions dart/lib/src/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class Sentry {
return false;
}

// try parsing the dsn
Dsn.parse(options.dsn);

// if logger os NoOp, let's set a logger that prints on the console
if (options.debug && options.logger == noOpLogger) {
options.logger = dartLogger;
Expand Down
11 changes: 3 additions & 8 deletions dart/lib/src/sentry_browser_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
/// A pure Dart client for Sentry.io crash reporting.
import 'dart:html' show window;

import 'protocol.dart';
import 'sentry_client.dart';
import 'sentry_options.dart';
import 'version.dart';

SentryClient createSentryClient(SentryOptions options) =>
SentryBrowserClient(options);
Expand All @@ -25,13 +23,10 @@ class SentryBrowserClient extends SentryClient {
///
/// If [httpClient] is provided, it is used instead of the default client to
/// make HTTP calls to Sentry.io. This is useful in tests.
factory SentryBrowserClient(SentryOptions options) {
options.sdk ??= Sdk(name: sdkName, version: sdkVersion);

// origin is necessary for sentry to resolve stacktrace
return SentryBrowserClient._(options);
}
factory SentryBrowserClient(SentryOptions options) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make me wonder if now we need to have a SentryBrowserClient and IOClient only because of the origin field.

Copy link
Contributor Author

@rxlabz rxlabz Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, we could move the origin settings in transport, and use the same strategy as for gzip compression => it will remove the need for 2 clients

SentryBrowserClient._(options);

SentryBrowserClient._(SentryOptions options)
// origin is necessary for sentry to resolve stacktrace
: super.base(options, origin: '${window.location.origin}/');
}
8 changes: 1 addition & 7 deletions dart/lib/src/sentry_io_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'protocol.dart';

/// A pure Dart client for Sentry.io crash reporting.
import 'sentry_client.dart';
import 'sentry_options.dart';
import 'version.dart';

SentryClient createSentryClient(SentryOptions options) =>
SentryIOClient(options);

/// Logs crash reports and events to the Sentry.io service.
class SentryIOClient extends SentryClient {
/// Instantiates a client using [SentryOptions]
factory SentryIOClient(SentryOptions options) {
options.sdk ??= Sdk(name: sdkName, version: sdkVersion);
return SentryIOClient._(options);
}
factory SentryIOClient(SentryOptions options) => SentryIOClient._(options);

SentryIOClient._(SentryOptions options) : super.base(options);
}
24 changes: 12 additions & 12 deletions dart/lib/src/sentry_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,53 +37,53 @@ class SentryOptions {

set httpClient(Client httpClient) => _httpClient = httpClient ?? _httpClient;

/// If [clock] is provided, it is used to get time instead of the system
/// clock. This is useful in tests. Should be an implementation of [ClockProvider].
ClockProvider _clock = getUtcDateTime;

/// If [clock] is provided, it is used to get time instead of the system
/// clock. This is useful in tests. Should be an implementation of [ClockProvider].
ClockProvider get clock => _clock;

set clock(ClockProvider clock) => _clock = clock ?? _clock;

/// This variable controls the total amount of breadcrumbs that should be captured Default is 100
int maxBreadcrumbs = 100;

/// Logger interface to log useful debugging information if debug is enabled
Logger _logger = noOpLogger;

/// Logger interface to log useful debugging information if debug is enabled
Logger get logger => _logger;

set logger(Logger logger) {
_logger = logger != null ? DiagnosticLogger(logger, this) : noOpLogger;
}

/// Are callbacks that run for every event. They can either return a new event which in most cases
/// means just adding data OR return null in case the event will be dropped and not sent.
final List<EventProcessor> _eventProcessors = [];

/// Are callbacks that run for every event. They can either return a new event which in most cases
/// means just adding data OR return null in case the event will be dropped and not sent.
List<EventProcessor> get eventProcessors =>
List.unmodifiable(_eventProcessors);

/// Code that provides middlewares, bindings or hooks into certain frameworks or environments,
/// along with code that inserts those bindings and activates them.
final List<Integration> _integrations = [];

// TODO: shutdownTimeout, flushTimeoutMillis
// https://api.dart.dev/stable/2.10.2/dart-io/HttpClient/close.html doesn't have a timeout param, we'd need to implement manually

/// Code that provides middlewares, bindings or hooks into certain frameworks or environments,
/// along with code that inserts those bindings and activates them.
List<Integration> get integrations => List.unmodifiable(_integrations);

/// Turns debug mode on or off. If debug is enabled SDK will attempt to print out useful debugging
/// information if something goes wrong. Default is disabled.
bool debug = false;

/// minimum LogLevel to be used if debug is enabled
SentryLevel _diagnosticLevel = defaultDiagnosticLevel;

set diagnosticLevel(SentryLevel level) {
_diagnosticLevel = level ?? defaultDiagnosticLevel;
}

/// minimum LogLevel to be used if debug is enabled
SentryLevel get diagnosticLevel => _diagnosticLevel;

/// Sentry client name used for the HTTP authHeader and userAgent eg
Expand Down Expand Up @@ -111,17 +111,17 @@ class SentryOptions {
/// sent. Events are picked randomly. Default is null (disabled)
double sampleRate;

final List<String> _inAppExcludes = [];

/// 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.
final List<String> _inAppExcludes = [];

List<String> get inAppExcludes => List.unmodifiable(_inAppExcludes);

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

/// A list of string prefixes of module names that belong to the app. This option takes precedence
/// over inAppExcludes.
List<String> get inAppIncludes => List.unmodifiable(_inAppIncludes);

Transport _transport = NoOpTransport();
Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/transport/http_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HttpTransport implements Transport {
_dsn = Dsn.parse(options.dsn),
_headers = _buildHeaders(sdkIdentifier: options.sdk.identifier) {
_credentialBuilder = CredentialBuilder(
dsn: Dsn.parse(options.dsn),
dsn: _dsn,
clientId: options.sdk.identifier,
clock: options.clock,
);
Expand Down