Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ref
  • Loading branch information
marandaneto committed Oct 20, 2020
commit 627f7748d88e81d61ecfa7b3aefe1641bee2a381
4 changes: 2 additions & 2 deletions dart/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ abstract class SentryClient {
if (response.headers['x-sentry-error'] != null) {
errorMessage += ': ${response.headers['x-sentry-error']}';
}*/
return SentryId.emptyId;
return SentryId.empty();
}

final eventId = json.decode(response.body)['id'];
return eventId != null ? SentryId.fromId(eventId) : SentryId.emptyId;
return eventId != null ? SentryId.fromId(eventId) : SentryId.empty();
}

/// Reports the [throwable] and optionally its [stackTrace] to Sentry.io.
Expand Down
11 changes: 5 additions & 6 deletions dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class Hub {
/// Check if the Hub is enabled/active.
bool get isEnabled => _isEnabled;

SentryId _lastEventId = SentryId.emptyId;
SentryId _lastEventId = SentryId.empty();

/// Last event id recorded in the current scope
SentryId get lastEventId => _lastEventId;

/// Captures the event.
Future<SentryId> captureEvent(Event event) async {
var sentryId = SentryId.emptyId;
var sentryId = SentryId.empty();

if (!_isEnabled) {
_options.logger(
Expand All @@ -79,10 +79,9 @@ class Hub {
try {
sentryId = await item.client.captureEvent(event, scope: item.scope);
} catch (err) {
/* TODO add Event.id */
_options.logger(
SentryLevel.error,
'Error while capturing event with id: ${event}',
'Error while capturing event with id: ${event.eventId}',
);
} finally {
_lastEventId = sentryId;
Expand All @@ -102,7 +101,7 @@ class Hub {
dynamic throwable, {
dynamic stackTrace,
}) async {
var sentryId = SentryId.emptyId;
var sentryId = SentryId.empty();

if (!_isEnabled) {
_options.logger(
Expand Down Expand Up @@ -146,7 +145,7 @@ class Hub {
String template,
List<dynamic> params,
}) async {
var sentryId = SentryId.emptyId;
var sentryId = SentryId.empty();

if (!_isEnabled) {
_options.logger(
Expand Down
6 changes: 3 additions & 3 deletions dart/lib/src/noop_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class NoOpSentryClient implements SentryClient {

@override
Future<SentryId> captureEvent(Event event, {stackFrameFilter, scope}) =>
Future.value(SentryId.emptyId);
Future.value(SentryId.empty());

@override
Future<SentryId> captureException(throwable, {stackTrace, scope}) =>
Future.value(SentryId.emptyId);
Future.value(SentryId.empty());

@override
Future<SentryId> captureMessage(
Expand All @@ -44,7 +44,7 @@ class NoOpSentryClient implements SentryClient {
List<dynamic> params,
Scope scope,
}) =>
Future.value(SentryId.emptyId);
Future.value(SentryId.empty());

@override
String get clientId => 'No-op';
Expand Down
8 changes: 4 additions & 4 deletions dart/lib/src/noop_hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class NoOpHub implements Hub {
void bindClient(SentryClient client) {}

@override
Future<SentryId> captureEvent(Event event) => Future.value(SentryId.emptyId);
Future<SentryId> captureEvent(Event event) => Future.value(SentryId.empty());

@override
Future<SentryId> captureException(throwable, {stackTrace}) =>
Future.value(SentryId.emptyId);
Future.value(SentryId.empty());

@override
Future<SentryId> captureMessage(
Expand All @@ -32,7 +32,7 @@ class NoOpHub implements Hub {
String template,
List params,
}) =>
Future.value(SentryId.emptyId);
Future.value(SentryId.empty());

@override
Hub clone() => this;
Expand All @@ -47,5 +47,5 @@ class NoOpHub implements Hub {
bool get isEnabled => false;

@override
SentryId get lastEventId => SentryId.emptyId;
SentryId get lastEventId => SentryId.empty();
}
9 changes: 5 additions & 4 deletions dart/lib/src/protocol/sentry_id.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'package:uuid/uuid.dart';

class SentryId {
static const String _emptyId = '00000000-0000-0000-0000-000000000000';

/// SentryId with an empty UUID
static final SentryId emptyId = SentryId.fromId(_emptyId);
static final SentryId _emptyId =
SentryId.fromId('00000000-0000-0000-0000-000000000000');

/// The ID Sentry.io assigned to the submitted event for future reference.
String _id;
Expand All @@ -21,6 +19,9 @@ class SentryId {
/// Generates a SentryId with the given UUID
factory SentryId.fromId(String id) => SentryId._internal(id: id);

/// SentryId with an empty UUID
factory SentryId.empty() => _emptyId;

@override
String toString() => _id.replaceAll('-', '');
}