Skip to content

Commit

Permalink
add attachmets from hint in client
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Apr 25, 2023
1 parent 3fa09f0 commit fb43a8f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class SentryClient {
preparedEvent = _eventWithoutBreadcrumbsIfNeeded(preparedEvent);

var attachments = List<SentryAttachment>.from(scope?.attachments ?? []);
attachments.addAll(hint.attachments);
var screenshot = hint.screenshot;
if (screenshot != null) {
attachments.add(screenshot);
Expand Down Expand Up @@ -323,6 +324,9 @@ class SentryClient {
final attachments = scope?.attachments
.where((element) => element.addToTransactions)
.toList();

// TODO Do we need to add attahcments?

final envelope = SentryEnvelope.fromTransaction(
preparedTransaction,
_options.sdk,
Expand Down
1 change: 0 additions & 1 deletion dart/test/hint_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:sentry/sentry.dart';
import 'package:test/test.dart';

void main() {

late Fixture fixture;

setUp(() {
Expand Down
14 changes: 14 additions & 0 deletions dart/test/sentry_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,20 @@ void main() {
expect(envelope.header.traceContext, isNotNull);
});

test('captureEvent adds attachments from hint', () async {
final attachment = SentryAttachment.fromIntList([], "fixture-fileName");
final hint = Hint.withAttachment(attachment);

final sut = fixture.getSut();
await sut.captureEvent(fakeEvent, hint: hint);

final capturedEnvelope = (fixture.transport).envelopes.first;
final attachmentItem = capturedEnvelope.items.firstWhereOrNull(
(element) => element.header.type == SentryItemType.attachment);
expect(attachmentItem?.header.attachmentType,
SentryAttachment.typeAttachmentDefault);
});

test('captureEvent adds screenshot from hint', () async {
final client = fixture.getSut();
final screenshot =
Expand Down

0 comments on commit fb43a8f

Please sign in to comment.