Skip to content

Commit

Permalink
Improve docs static methods (#1051)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Oct 7, 2022
1 parent bc9607c commit b8b9b7b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
6 changes: 5 additions & 1 deletion dart/lib/src/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class Sentry {
withScope: withScope,
);

/// Reports a [message] to Sentry.io.
static Future<SentryId> captureMessage(
String? message, {
SentryLevel? level = SentryLevel.info,
Expand All @@ -185,6 +186,9 @@ class Sentry {
withScope: withScope,
);

/// Reports a [userFeedback] to Sentry.io.
///
/// First capture an event and use the [SentryId] to create a [SentryUserFeedback]
static Future<void> captureUserFeedback(SentryUserFeedback userFeedback) =>
_hub.captureUserFeedback(userFeedback);

Expand Down Expand Up @@ -276,7 +280,7 @@ class Sentry {
onFinish: onFinish,
);

/// Gets the current active transaction or span.
/// Gets the current active transaction or span bound to the scope.
static ISentrySpan? getSpan() => _hub.getSpan();

@internal
Expand Down
5 changes: 4 additions & 1 deletion dart/lib/src/sentry_user_feedback.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class SentryUserFeedback {
this.name,
this.email,
this.comments,
}) : assert(eventId != SentryId.empty());
}) : assert(eventId != SentryId.empty() &&
(name?.isNotEmpty == true ||
email?.isNotEmpty == true ||
comments?.isNotEmpty == true));

factory SentryUserFeedback.fromJson(Map<String, dynamic> json) {
return SentryUserFeedback(
Expand Down
18 changes: 13 additions & 5 deletions dart/test/sentry_user_feedback_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ void main() {

group('$SentryUserFeedback to envelops', () {
test('to envelope', () {
final feedback = SentryUserFeedback(eventId: SentryId.newId());
final feedback = SentryUserFeedback(
eventId: SentryId.newId(),
name: 'test',
);
final envelope = SentryEnvelope.fromUserFeedback(
feedback,
SdkVersion(name: 'a', version: 'b'),
Expand All @@ -88,8 +91,10 @@ void main() {
test('sending $SentryUserFeedback', () async {
final fixture = Fixture();
final sut = fixture.getSut();
await sut
.captureUserFeedback(SentryUserFeedback(eventId: SentryId.newId()));
await sut.captureUserFeedback(SentryUserFeedback(
eventId: SentryId.newId(),
name: 'test',
));

expect(fixture.transport.envelopes.length, 1);
});
Expand All @@ -106,7 +111,10 @@ void main() {
final sut = fixture.getSut();
await sut.close();
await sut.captureUserFeedback(
SentryUserFeedback(eventId: SentryId.newId()),
SentryUserFeedback(
eventId: SentryId.newId(),
name: 'test',
),
);

expect(fixture.transport.envelopes.length, 0);
Expand All @@ -133,7 +141,7 @@ void main() {

await expectLater(() async {
await sut.captureUserFeedback(
SentryUserFeedback(eventId: SentryId.newId()),
SentryUserFeedback(eventId: SentryId.newId(), name: 'name'),
);
}, returnsNormally);
});
Expand Down

0 comments on commit b8b9b7b

Please sign in to comment.