From 6a35dad6221c9d28ccf78e7816587066c4aec038 Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Sun, 29 May 2022 04:28:01 +0530 Subject: [PATCH 01/17] Move to local dependency --- flutter/pubspec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 959b7f8bcf..3689920d12 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -14,7 +14,8 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - sentry: ^6.5.1 + sentry: + path: ../dart package_info_plus: ^1.0.0 meta: ^1.3.0 From 1ba4085ad44496f37392ae9172393d741fe65b75 Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Sun, 29 May 2022 04:42:20 +0530 Subject: [PATCH 02/17] Pass DSN within the SentryEnvelopeHeader --- dart/lib/src/sentry_client.dart | 1 + dart/lib/src/sentry_envelope.dart | 9 +++++---- dart/lib/src/sentry_envelope_header.dart | 11 +++++++++-- dart/test/mocks.dart | 5 ++++- dart/test/sentry_envelope_header_test.dart | 4 ++-- dart/test/sentry_envelope_test.dart | 11 +++++++++-- dart/test/sentry_envelope_vm_test.dart | 4 +++- dart/test/transport/http_transport_test.dart | 14 +++++++++----- dio/test/mocks.dart | 3 +++ flutter/test/file_system_transport_test.dart | 9 ++++++--- 10 files changed, 51 insertions(+), 20 deletions(-) diff --git a/dart/lib/src/sentry_client.dart b/dart/lib/src/sentry_client.dart index 020be3046e..8990bde736 100644 --- a/dart/lib/src/sentry_client.dart +++ b/dart/lib/src/sentry_client.dart @@ -108,6 +108,7 @@ class SentryClient { final envelope = SentryEnvelope.fromEvent( preparedEvent, _options.sdk, + _options.dsn, attachments: scope?.attachements, ); diff --git a/dart/lib/src/sentry_envelope.dart b/dart/lib/src/sentry_envelope.dart index 25bd031974..492bce048f 100644 --- a/dart/lib/src/sentry_envelope.dart +++ b/dart/lib/src/sentry_envelope.dart @@ -21,11 +21,12 @@ class SentryEnvelope { /// Create an [SentryEnvelope] with containing one [SentryEnvelopeItem] which holds the [SentryEvent] data. factory SentryEnvelope.fromEvent( SentryEvent event, - SdkVersion sdkVersion, { + SdkVersion sdkVersion, + String? dsn, { List? attachments, }) { return SentryEnvelope( - SentryEnvelopeHeader(event.eventId, sdkVersion), + SentryEnvelopeHeader(event.eventId, sdkVersion, dsn), [ SentryEnvelopeItem.fromEvent(event), if (attachments != null) @@ -39,7 +40,7 @@ class SentryEnvelope { SdkVersion sdkVersion, ) { return SentryEnvelope( - SentryEnvelopeHeader(feedback.eventId, sdkVersion), + SentryEnvelopeHeader(feedback.eventId, sdkVersion, null), [SentryEnvelopeItem.fromUserFeedback(feedback)], ); } @@ -51,7 +52,7 @@ class SentryEnvelope { List? attachments, }) { return SentryEnvelope( - SentryEnvelopeHeader(transaction.eventId, sdkVersion), + SentryEnvelopeHeader(transaction.eventId, sdkVersion, null), [ SentryEnvelopeItem.fromTransaction(transaction), if (attachments != null) diff --git a/dart/lib/src/sentry_envelope_header.dart b/dart/lib/src/sentry_envelope_header.dart index 426bccc910..49d87ce35f 100644 --- a/dart/lib/src/sentry_envelope_header.dart +++ b/dart/lib/src/sentry_envelope_header.dart @@ -3,10 +3,11 @@ import 'protocol/sdk_version.dart'; /// Header containing `SentryId` and `SdkVersion`. class SentryEnvelopeHeader { - SentryEnvelopeHeader(this.eventId, this.sdkVersion); + SentryEnvelopeHeader(this.eventId, this.sdkVersion, this.dsn); SentryEnvelopeHeader.newEventId() : eventId = SentryId.newId(), - sdkVersion = null; + sdkVersion = null, + dsn = null; /// The identifier of encoded `SentryEvent`. final SentryId? eventId; @@ -14,6 +15,9 @@ class SentryEnvelopeHeader { /// The `SdkVersion` with which the envelope was send. final SdkVersion? sdkVersion; + /// The `DSN` of the Sentry project. + final String? dsn; + /// Header encoded as JSON Map toJson() { final json = {}; @@ -25,6 +29,9 @@ class SentryEnvelopeHeader { if (tempSdkVersion != null) { json['sdk'] = tempSdkVersion.toJson(); } + if (dsn != null) { + json['dsn'] = dsn; + } return json; } } diff --git a/dart/test/mocks.dart b/dart/test/mocks.dart index cb36172d06..4c0aa47307 100644 --- a/dart/test/mocks.dart +++ b/dart/test/mocks.dart @@ -129,7 +129,10 @@ typedef EventProcessorFunction = FutureOr Function(SentryEvent event, {dynamic hint}); var fakeEnvelope = SentryEnvelope.fromEvent( - fakeEvent, SdkVersion(name: 'sdk1', version: '1.0.0')); + fakeEvent, + SdkVersion(name: 'sdk1', version: '1.0.0'), + fakeDsn, +); class MockRateLimiter implements RateLimiter { bool filterReturnsNull = false; diff --git a/dart/test/sentry_envelope_header_test.dart b/dart/test/sentry_envelope_header_test.dart index 28f894e766..cedc01ebd9 100644 --- a/dart/test/sentry_envelope_header_test.dart +++ b/dart/test/sentry_envelope_header_test.dart @@ -5,7 +5,7 @@ import 'package:test/test.dart'; void main() { group('SentryEnvelopeHeader', () { test('toJson empty', () { - final sut = SentryEnvelopeHeader(null, null); + final sut = SentryEnvelopeHeader(null, null, null); final expected = {}; expect(sut.toJson(), expected); }); @@ -16,7 +16,7 @@ void main() { name: 'fixture-sdkName', version: 'fixture-version', ); - final sut = SentryEnvelopeHeader(eventId, sdkVersion); + final sut = SentryEnvelopeHeader(eventId, sdkVersion, null); final expextedSkd = sdkVersion.toJson(); final expected = { 'event_id': eventId.toString(), diff --git a/dart/test/sentry_envelope_test.dart b/dart/test/sentry_envelope_test.dart index bc28c508de..21141951c5 100644 --- a/dart/test/sentry_envelope_test.dart +++ b/dart/test/sentry_envelope_test.dart @@ -28,7 +28,7 @@ void main() { final item = SentryEnvelopeItem(itemHeader, dataFactory); - final header = SentryEnvelopeHeader(eventId, null); + final header = SentryEnvelopeHeader(eventId, null, null); final sut = SentryEnvelope(header, [item, item]); final expectedHeaderJson = header.toJson(); @@ -53,7 +53,9 @@ void main() { final sentryEvent = SentryEvent(eventId: eventId); final sdkVersion = SdkVersion(name: 'fixture-name', version: 'fixture-version'); - final sut = SentryEnvelope.fromEvent(sentryEvent, sdkVersion); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; + final sut = + SentryEnvelope.fromEvent(sentryEvent, sdkVersion, fakeDsn); final expectedEnvelopeItem = SentryEnvelopeItem.fromEvent(sentryEvent); @@ -111,16 +113,19 @@ void main() { final sentryEvent = SentryEvent(eventId: eventId); final sdkVersion = SdkVersion(name: 'fixture-name', version: 'fixture-version'); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final sut = SentryEnvelope.fromEvent( sentryEvent, sdkVersion, + fakeDsn, attachments: [attachment], ); final expectedEnvelopeItem = SentryEnvelope.fromEvent( sentryEvent, sdkVersion, + fakeDsn, ); final sutEnvelopeData = []; @@ -140,12 +145,14 @@ void main() { // This is a test for https://github.com/getsentry/sentry-dart/issues/523 test('serialize with non-serializable class', () async { final event = SentryEvent(extra: {'non-ecodable': NonEncodable()}); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final sut = SentryEnvelope.fromEvent( event, SdkVersion( name: 'test', version: '1', ), + fakeDsn, ); final _ = sut.envelopeStream(SentryOptions()).map((e) => e); diff --git a/dart/test/sentry_envelope_vm_test.dart b/dart/test/sentry_envelope_vm_test.dart index b1bd880f91..e345d68fae 100644 --- a/dart/test/sentry_envelope_vm_test.dart +++ b/dart/test/sentry_envelope_vm_test.dart @@ -28,7 +28,7 @@ void main() { final eventId = SentryId.fromId('3b382f22ee67491f80f7dee18016a7b1'); final sdkVersion = SdkVersion(name: 'test', version: 'version'); - final header = SentryEnvelopeHeader(eventId, sdkVersion); + final header = SentryEnvelopeHeader(eventId, sdkVersion, null); final envelope = SentryEnvelope(header, [attachmentItem]); final envelopeData = []; @@ -51,10 +51,12 @@ void main() { final sdkVersion = SdkVersion(name: '', version: ''); final attachment = IoSentryAttachment.fromPath('this_path_does_not_exist.txt'); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = SentryEnvelope.fromEvent( event, sdkVersion, + fakeDsn, attachments: [attachment], ); diff --git a/dart/test/transport/http_transport_test.dart b/dart/test/transport/http_transport_test.dart index 6b7319b5ee..a2e66bd550 100644 --- a/dart/test/transport/http_transport_test.dart +++ b/dart/test/transport/http_transport_test.dart @@ -16,7 +16,7 @@ import '../mocks.dart'; void main() { SentryEnvelope givenEnvelope() { - final filteredEnvelopeHeader = SentryEnvelopeHeader(SentryId.empty(), null); + final filteredEnvelopeHeader = SentryEnvelopeHeader(SentryId.empty(), null, null); final filteredItemHeader = SentryEnvelopeItemHeader(SentryItemType.event, () async { return 2; @@ -66,8 +66,9 @@ void main() { final sut = fixture.getSut(httpMock, mockRateLimiter); final sentryEvent = SentryEvent(); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk); + SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk, fakeDsn); await sut.send(envelope); final envelopeData = []; @@ -90,8 +91,9 @@ void main() { final sut = fixture.getSut(httpMock, mockRateLimiter); final sentryEvent = SentryEvent(); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk); + SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk, fakeDsn); final eventId = await sut.send(envelope); expect(eventId, SentryId.empty()); @@ -114,8 +116,9 @@ void main() { final sut = fixture.getSut(httpMock, mockRateLimiter); final sentryEvent = SentryEvent(); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk); + SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk, fakeDsn); await sut.send(envelope); expect(mockRateLimiter.envelopeToFilter?.header.eventId, @@ -135,8 +138,9 @@ void main() { final sut = fixture.getSut(httpMock, mockRateLimiter); final sentryEvent = SentryEvent(); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk); + SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk, fakeDsn); await sut.send(envelope); expect(mockRateLimiter.errorCode, 200); diff --git a/dio/test/mocks.dart b/dio/test/mocks.dart index b17a27e8b6..9bfdec85c5 100644 --- a/dio/test/mocks.dart +++ b/dio/test/mocks.dart @@ -128,9 +128,12 @@ class FunctionEventProcessor extends EventProcessor { typedef EventProcessorFunction = FutureOr Function(SentryEvent event, {dynamic hint}); +final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; + var fakeEnvelope = SentryEnvelope.fromEvent( fakeEvent, SdkVersion(name: 'sdk1', version: '1.0.0'), + fakeDsn, ); class MockRateLimiter implements RateLimiter { diff --git a/flutter/test/file_system_transport_test.dart b/flutter/test/file_system_transport_test.dart index 680deb073d..f8420d19e7 100644 --- a/flutter/test/file_system_transport_test.dart +++ b/flutter/test/file_system_transport_test.dart @@ -28,8 +28,9 @@ void main() { final event = SentryEvent(); final sdkVersion = SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = SentryEnvelope.fromEvent(event, sdkVersion); + final envelope = SentryEnvelope.fromEvent(event, sdkVersion, fakeDsn); final sentryId = await transport.send(envelope); expect(sentryId, sentryId); @@ -44,8 +45,9 @@ void main() { final event = SentryEvent(); final sdkVersion = SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = SentryEnvelope.fromEvent(event, sdkVersion); + final envelope = SentryEnvelope.fromEvent(event, sdkVersion, fakeDsn); final sentryId = await transport.send(envelope); expect(SentryId.empty(), sentryId); @@ -63,7 +65,8 @@ void main() { SentryEvent(message: SentryMessage('hi I am a special char ◤')); final sdkVersion = SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); - final envelope = SentryEnvelope.fromEvent(event, sdkVersion); + final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; + final envelope = SentryEnvelope.fromEvent(event, sdkVersion, fakeDsn); await transport.send(envelope); final envelopeList = arguments as List; From a6fb6c0cae4db9abfcba5496c242017390244d18 Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Tue, 14 Jun 2022 21:12:30 +0530 Subject: [PATCH 03/17] Switch to remote dependency as an override is already declared --- flutter/pubspec.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 3689920d12..959b7f8bcf 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -14,8 +14,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - sentry: - path: ../dart + sentry: ^6.5.1 package_info_plus: ^1.0.0 meta: ^1.3.0 From 3502ee4d534b9fcf47be2d89c0ae45a28044ef5e Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:45:05 +0530 Subject: [PATCH 04/17] Fix broken tests --- dart/test/mocks.dart | 2 +- dart/test/sentry_envelope_header_test.dart | 2 +- dart/test/sentry_envelope_test.dart | 6 ++-- dart/test/sentry_envelope_vm_test.dart | 5 +--- dart/test/transport/http_transport_test.dart | 29 +++++++++++--------- flutter/test/file_system_transport_test.dart | 6 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/dart/test/mocks.dart b/dart/test/mocks.dart index 4c0aa47307..836dccc762 100644 --- a/dart/test/mocks.dart +++ b/dart/test/mocks.dart @@ -131,7 +131,7 @@ typedef EventProcessorFunction = FutureOr var fakeEnvelope = SentryEnvelope.fromEvent( fakeEvent, SdkVersion(name: 'sdk1', version: '1.0.0'), - fakeDsn, + dsn: fakeDsn, ); class MockRateLimiter implements RateLimiter { diff --git a/dart/test/sentry_envelope_header_test.dart b/dart/test/sentry_envelope_header_test.dart index 92fbe9db5f..912a7ef9e3 100644 --- a/dart/test/sentry_envelope_header_test.dart +++ b/dart/test/sentry_envelope_header_test.dart @@ -5,7 +5,7 @@ import 'package:test/test.dart'; void main() { group('SentryEnvelopeHeader', () { test('toJson empty', () { - final sut = SentryEnvelopeHeader(null, null, null); + final sut = SentryEnvelopeHeader(null, null); final expected = {}; expect(sut.toJson(), expected); }); diff --git a/dart/test/sentry_envelope_test.dart b/dart/test/sentry_envelope_test.dart index 4878a788c9..d5b24a9d92 100644 --- a/dart/test/sentry_envelope_test.dart +++ b/dart/test/sentry_envelope_test.dart @@ -143,14 +143,14 @@ void main() { final sut = SentryEnvelope.fromEvent( sentryEvent, sdkVersion, - fakeDsn, + dsn: fakeDsn, attachments: [attachment], ); final expectedEnvelopeItem = SentryEnvelope.fromEvent( sentryEvent, sdkVersion, - fakeDsn, + dsn: fakeDsn, ); final sutEnvelopeData = []; @@ -177,7 +177,7 @@ void main() { name: 'test', version: '1', ), - fakeDsn, + dsn: fakeDsn, ); final _ = sut.envelopeStream(SentryOptions()).map((e) => e); diff --git a/dart/test/sentry_envelope_vm_test.dart b/dart/test/sentry_envelope_vm_test.dart index 569f6176ba..fdb136d9d6 100644 --- a/dart/test/sentry_envelope_vm_test.dart +++ b/dart/test/sentry_envelope_vm_test.dart @@ -27,7 +27,7 @@ void main() { final eventId = SentryId.fromId('3b382f22ee67491f80f7dee18016a7b1'); final sdkVersion = SdkVersion(name: 'test', version: 'version'); - final header = SentryEnvelopeHeader(eventId, sdkVersion, null); + final header = SentryEnvelopeHeader(eventId, sdkVersion); final envelope = SentryEnvelope(header, [attachmentItem]); final envelopeData = []; @@ -50,12 +50,9 @@ void main() { final sdkVersion = SdkVersion(name: '', version: ''); final attachment = IoSentryAttachment.fromPath('this_path_does_not_exist.txt'); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = SentryEnvelope.fromEvent( event, sdkVersion, - fakeDsn, attachments: [attachment], ); diff --git a/dart/test/transport/http_transport_test.dart b/dart/test/transport/http_transport_test.dart index 3f2b53770f..e8df1cf372 100644 --- a/dart/test/transport/http_transport_test.dart +++ b/dart/test/transport/http_transport_test.dart @@ -2,17 +2,16 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:http/testing.dart'; +import 'package:sentry/sentry.dart'; import 'package:sentry/src/client_reports/discard_reason.dart'; import 'package:sentry/src/sentry_envelope_header.dart'; import 'package:sentry/src/sentry_envelope_item_header.dart'; import 'package:sentry/src/sentry_item_type.dart'; +import 'package:sentry/src/sentry_tracer.dart'; import 'package:sentry/src/transport/data_category.dart'; +import 'package:sentry/src/transport/http_transport.dart'; import 'package:sentry/src/transport/rate_limiter.dart'; import 'package:test/test.dart'; -import 'package:sentry/src/sentry_tracer.dart'; - -import 'package:sentry/sentry.dart'; -import 'package:sentry/src/transport/http_transport.dart'; import '../mocks.dart'; import '../mocks/mock_client_report_recorder.dart'; @@ -20,7 +19,7 @@ import '../mocks/mock_hub.dart'; void main() { SentryEnvelope givenEnvelope() { - final filteredEnvelopeHeader = SentryEnvelopeHeader(SentryId.empty(), null, null); + final filteredEnvelopeHeader = SentryEnvelopeHeader(SentryId.empty(), null); final filteredItemHeader = SentryEnvelopeItemHeader(SentryItemType.event, () async { return 2; @@ -71,8 +70,9 @@ void main() { final sentryEvent = SentryEvent(); final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk, fakeDsn); + final envelope = SentryEnvelope.fromEvent( + sentryEvent, fixture.options.sdk, + dsn: fakeDsn); await sut.send(envelope); final envelopeData = []; @@ -96,8 +96,9 @@ void main() { final sentryEvent = SentryEvent(); final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk, fakeDsn); + final envelope = SentryEnvelope.fromEvent( + sentryEvent, fixture.options.sdk, + dsn: fakeDsn); final eventId = await sut.send(envelope); expect(eventId, SentryId.empty()); @@ -121,8 +122,9 @@ void main() { final sentryEvent = SentryEvent(); final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk, fakeDsn); + final envelope = SentryEnvelope.fromEvent( + sentryEvent, fixture.options.sdk, + dsn: fakeDsn); await sut.send(envelope); expect(mockRateLimiter.envelopeToFilter?.header.eventId, @@ -143,8 +145,9 @@ void main() { final sentryEvent = SentryEvent(); final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk, fakeDsn); + final envelope = SentryEnvelope.fromEvent( + sentryEvent, fixture.options.sdk, + dsn: fakeDsn); await sut.send(envelope); expect(mockRateLimiter.errorCode, 200); diff --git a/flutter/test/file_system_transport_test.dart b/flutter/test/file_system_transport_test.dart index 57feea568c..fccb953ac8 100644 --- a/flutter/test/file_system_transport_test.dart +++ b/flutter/test/file_system_transport_test.dart @@ -34,7 +34,7 @@ void main() { SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = SentryEnvelope.fromEvent(event, sdkVersion, fakeDsn); + final envelope = SentryEnvelope.fromEvent(event, sdkVersion, dsn: fakeDsn); final sentryId = await transport.send(envelope); expect(sentryId, sentryId); @@ -51,7 +51,7 @@ void main() { SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = SentryEnvelope.fromEvent(event, sdkVersion, fakeDsn); + final envelope = SentryEnvelope.fromEvent(event, sdkVersion, dsn: fakeDsn); final sentryId = await transport.send(envelope); expect(SentryId.empty(), sentryId); @@ -70,7 +70,7 @@ void main() { final sdkVersion = SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = SentryEnvelope.fromEvent(event, sdkVersion, fakeDsn); + final envelope = SentryEnvelope.fromEvent(event, sdkVersion, dsn: fakeDsn); await transport.send(envelope); final envelopeList = arguments as List; From bd6984854bf42ce69d4cfa4095d4f77bf30acb8b Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 28 Sep 2022 16:07:07 +0530 Subject: [PATCH 05/17] Fix test --- dio/test/mocks.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dio/test/mocks.dart b/dio/test/mocks.dart index 9bfdec85c5..f12bc2c4aa 100644 --- a/dio/test/mocks.dart +++ b/dio/test/mocks.dart @@ -128,12 +128,10 @@ class FunctionEventProcessor extends EventProcessor { typedef EventProcessorFunction = FutureOr Function(SentryEvent event, {dynamic hint}); -final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - var fakeEnvelope = SentryEnvelope.fromEvent( fakeEvent, SdkVersion(name: 'sdk1', version: '1.0.0'), - fakeDsn, + dsn: fakeDsn, ); class MockRateLimiter implements RateLimiter { From 93b03daa22be05800be656ed87ae3a0743c681b9 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 10:09:12 +0200 Subject: [PATCH 06/17] fix lint --- flutter/test/file_system_transport_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter/test/file_system_transport_test.dart b/flutter/test/file_system_transport_test.dart index fccb953ac8..ebae943251 100644 --- a/flutter/test/file_system_transport_test.dart +++ b/flutter/test/file_system_transport_test.dart @@ -32,7 +32,7 @@ void main() { final event = SentryEvent(); final sdkVersion = SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; + const fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = SentryEnvelope.fromEvent(event, sdkVersion, dsn: fakeDsn); final sentryId = await transport.send(envelope); From 7534e8240cbdaa6c829de8e8f7fc860aed90acd5 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 10:11:26 +0200 Subject: [PATCH 07/17] fix --- CHANGELOG.md | 1 + dart/test/test.dart | 16 ++++++++++++++++ flutter/test/file_system_transport_test.dart | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 dart/test/test.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f82ab263a..46630af9a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Features - Added [Flutter renderer](https://docs.flutter.dev/development/platform-integration/web/renderers) information to events ([#1035](https://github.com/getsentry/sentry-dart/pull/1035)) +- Added missing DSN field into the SentryEnvelopeHeader ([#873](https://github.com/getsentry/sentry-dart/pull/873)) ## 6.11.2 diff --git a/dart/test/test.dart b/dart/test/test.dart new file mode 100644 index 0000000000..8ce2a15a6f --- /dev/null +++ b/dart/test/test.dart @@ -0,0 +1,16 @@ +import 'package:sentry/sentry.dart'; + +void test() { + final transaction = Sentry.getSpan(); + + // Record amount of memory used + transaction?.setMeasurement('memoryUsed', 123, + unit: SentryMeasurementUnit.byte); + + // Record time when Footer component renders on page + transaction?.setMeasurement('ui.footerComponent.render', 1.3, + unit: SentryMeasurementUnit.second); + + // Record amount of times localStorage was read + transaction?.setMeasurement('localStorageRead', 4); +} diff --git a/flutter/test/file_system_transport_test.dart b/flutter/test/file_system_transport_test.dart index ebae943251..734b200b93 100644 --- a/flutter/test/file_system_transport_test.dart +++ b/flutter/test/file_system_transport_test.dart @@ -49,7 +49,7 @@ void main() { final event = SentryEvent(); final sdkVersion = SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; + const fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = SentryEnvelope.fromEvent(event, sdkVersion, dsn: fakeDsn); final sentryId = await transport.send(envelope); @@ -69,7 +69,7 @@ void main() { SentryEvent(message: SentryMessage('hi I am a special char ◤')); final sdkVersion = SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; + const fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = SentryEnvelope.fromEvent(event, sdkVersion, dsn: fakeDsn); await transport.send(envelope); From 647697cab8575776e80f1993e0f86041adf1ca82 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 10:46:45 +0200 Subject: [PATCH 08/17] fix tests --- dart/lib/src/sentry_client.dart | 2 + dart/lib/src/sentry_envelope.dart | 11 +++-- dart/test/sentry_envelope_test.dart | 2 + dart/test/sentry_envelope_vm_test.dart | 52 ++++++++++++++++++++ dart/test/sentry_user_feedback_test.dart | 1 + dart/test/transport/http_transport_test.dart | 49 +++++++++++------- flutter/test/file_system_transport_test.dart | 25 +++++++--- 7 files changed, 114 insertions(+), 28 deletions(-) diff --git a/dart/lib/src/sentry_client.dart b/dart/lib/src/sentry_client.dart index a10c52079e..ec63372f7a 100644 --- a/dart/lib/src/sentry_client.dart +++ b/dart/lib/src/sentry_client.dart @@ -319,6 +319,7 @@ class SentryClient { final envelope = SentryEnvelope.fromTransaction( preparedTransaction, _options.sdk, + dsn: _options.dsn, traceContext: traceContext, attachments: attachments, ); @@ -337,6 +338,7 @@ class SentryClient { final envelope = SentryEnvelope.fromUserFeedback( userFeedback, _options.sdk, + dsn: _options.dsn, ); return _attachClientReportsAndSend(envelope); } diff --git a/dart/lib/src/sentry_envelope.dart b/dart/lib/src/sentry_envelope.dart index 450a3bb8d3..eb62aeec47 100644 --- a/dart/lib/src/sentry_envelope.dart +++ b/dart/lib/src/sentry_envelope.dart @@ -45,11 +45,16 @@ class SentryEnvelope { factory SentryEnvelope.fromUserFeedback( SentryUserFeedback feedback, - SdkVersion sdkVersion, - ) { + SdkVersion sdkVersion, { + String? dsn, + }) { return SentryEnvelope( // no need for [traceContext] - SentryEnvelopeHeader(feedback.eventId, sdkVersion), + SentryEnvelopeHeader( + feedback.eventId, + sdkVersion, + dsn: dsn, + ), [SentryEnvelopeItem.fromUserFeedback(feedback)], ); } diff --git a/dart/test/sentry_envelope_test.dart b/dart/test/sentry_envelope_test.dart index d5b24a9d92..ed37001002 100644 --- a/dart/test/sentry_envelope_test.dart +++ b/dart/test/sentry_envelope_test.dart @@ -9,6 +9,7 @@ import 'package:sentry/src/sentry_tracer.dart'; import 'package:sentry/src/utils.dart'; import 'package:test/test.dart'; +import 'mocks.dart'; import 'mocks/mock_hub.dart'; void main() { @@ -107,6 +108,7 @@ void main() { final sut = SentryEnvelope.fromTransaction( tr, sdkVersion, + dsn: fakeDsn, traceContext: traceContext, ); diff --git a/dart/test/sentry_envelope_vm_test.dart b/dart/test/sentry_envelope_vm_test.dart index fdb136d9d6..ceeecd4e9a 100644 --- a/dart/test/sentry_envelope_vm_test.dart +++ b/dart/test/sentry_envelope_vm_test.dart @@ -6,6 +6,8 @@ import 'package:sentry/src/sentry_envelope_header.dart'; import 'package:sentry/src/sentry_envelope_item_header.dart'; import 'package:test/test.dart'; +import 'mocks.dart'; + void main() { group('SentryEnvelopeItem', () { test('item with binary payload', () async { @@ -53,6 +55,7 @@ void main() { final envelope = SentryEnvelope.fromEvent( event, sdkVersion, + dsn: fakeDsn, attachments: [attachment], ); @@ -142,6 +145,55 @@ final envelopeBinaryData = [ 34, 34, 125, + 44, + 34, + 100, + 115, + 110, + 34, + 58, + 34, + 104, + 116, + 116, + 112, + 115, + 58, + 47, + 47, + 97, + 98, + 99, + 64, + 100, + 101, + 102, + 46, + 105, + 110, + 103, + 101, + 115, + 116, + 46, + 115, + 101, + 110, + 116, + 114, + 121, + 46, + 105, + 111, + 47, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 34, 125, 10, 123, diff --git a/dart/test/sentry_user_feedback_test.dart b/dart/test/sentry_user_feedback_test.dart index 700e94e35d..93e5764b6a 100644 --- a/dart/test/sentry_user_feedback_test.dart +++ b/dart/test/sentry_user_feedback_test.dart @@ -74,6 +74,7 @@ void main() { final envelope = SentryEnvelope.fromUserFeedback( feedback, SdkVersion(name: 'a', version: 'b'), + dsn: fakeDsn, ); expect(envelope.items.length, 1); diff --git a/dart/test/transport/http_transport_test.dart b/dart/test/transport/http_transport_test.dart index e8df1cf372..876feb6f15 100644 --- a/dart/test/transport/http_transport_test.dart +++ b/dart/test/transport/http_transport_test.dart @@ -69,10 +69,11 @@ void main() { final sut = fixture.getSut(httpMock, mockRateLimiter); final sentryEvent = SentryEvent(); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = SentryEnvelope.fromEvent( - sentryEvent, fixture.options.sdk, - dsn: fakeDsn); + sentryEvent, + fixture.options.sdk, + dsn: fixture.options.dsn, + ); await sut.send(envelope); final envelopeData = []; @@ -95,10 +96,11 @@ void main() { final sut = fixture.getSut(httpMock, mockRateLimiter); final sentryEvent = SentryEvent(); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = SentryEnvelope.fromEvent( - sentryEvent, fixture.options.sdk, - dsn: fakeDsn); + sentryEvent, + fixture.options.sdk, + dsn: fixture.options.dsn, + ); final eventId = await sut.send(envelope); expect(eventId, SentryId.empty()); @@ -121,10 +123,11 @@ void main() { final sut = fixture.getSut(httpMock, mockRateLimiter); final sentryEvent = SentryEvent(); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = SentryEnvelope.fromEvent( - sentryEvent, fixture.options.sdk, - dsn: fakeDsn); + sentryEvent, + fixture.options.sdk, + dsn: fixture.options.dsn, + ); await sut.send(envelope); expect(mockRateLimiter.envelopeToFilter?.header.eventId, @@ -144,10 +147,11 @@ void main() { final sut = fixture.getSut(httpMock, mockRateLimiter); final sentryEvent = SentryEvent(); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final envelope = SentryEnvelope.fromEvent( - sentryEvent, fixture.options.sdk, - dsn: fakeDsn); + sentryEvent, + fixture.options.sdk, + dsn: fixture.options.dsn, + ); await sut.send(envelope); expect(mockRateLimiter.errorCode, 200); @@ -171,8 +175,11 @@ void main() { final sut = fixture.getSut(httpMock, MockRateLimiter()); final sentryEvent = SentryEvent(); - final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk); + final envelope = SentryEnvelope.fromEvent( + sentryEvent, + fixture.options.sdk, + dsn: fixture.options.dsn, + ); await sut.send(envelope); expect(fixture.clientReportRecorder.reason, DiscardReason.networkError); @@ -186,8 +193,11 @@ void main() { final sut = fixture.getSut(httpMock, MockRateLimiter()); final sentryEvent = SentryEvent(); - final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk); + final envelope = SentryEnvelope.fromEvent( + sentryEvent, + fixture.options.sdk, + dsn: fixture.options.dsn, + ); await sut.send(envelope); expect(fixture.clientReportRecorder.reason, null); @@ -201,8 +211,11 @@ void main() { final sut = fixture.getSut(httpMock, MockRateLimiter()); final sentryEvent = SentryEvent(); - final envelope = - SentryEnvelope.fromEvent(sentryEvent, fixture.options.sdk); + final envelope = SentryEnvelope.fromEvent( + sentryEvent, + fixture.options.sdk, + dsn: fixture.options.dsn, + ); await sut.send(envelope); expect(fixture.clientReportRecorder.reason, DiscardReason.networkError); diff --git a/flutter/test/file_system_transport_test.dart b/flutter/test/file_system_transport_test.dart index 734b200b93..5bad534153 100644 --- a/flutter/test/file_system_transport_test.dart +++ b/flutter/test/file_system_transport_test.dart @@ -10,6 +10,8 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:sentry/sentry.dart'; import 'package:sentry_flutter/src/file_system_transport.dart'; +import 'integrations/native_app_start_integration_test.dart'; + void main() { const _channel = MethodChannel('sentry_flutter'); @@ -32,9 +34,12 @@ void main() { final event = SentryEvent(); final sdkVersion = SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); - const fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = SentryEnvelope.fromEvent(event, sdkVersion, dsn: fakeDsn); + final envelope = SentryEnvelope.fromEvent( + event, + sdkVersion, + dsn: fixture.options.dsn, + ); final sentryId = await transport.send(envelope); expect(sentryId, sentryId); @@ -49,9 +54,12 @@ void main() { final event = SentryEvent(); final sdkVersion = SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); - const fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = SentryEnvelope.fromEvent(event, sdkVersion, dsn: fakeDsn); + final envelope = SentryEnvelope.fromEvent( + event, + sdkVersion, + dsn: fixture.options.dsn, + ); final sentryId = await transport.send(envelope); expect(SentryId.empty(), sentryId); @@ -69,8 +77,11 @@ void main() { SentryEvent(message: SentryMessage('hi I am a special char ◤')); final sdkVersion = SdkVersion(name: 'fixture-sdkName', version: 'fixture-sdkVersion'); - const fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - final envelope = SentryEnvelope.fromEvent(event, sdkVersion, dsn: fakeDsn); + final envelope = SentryEnvelope.fromEvent( + event, + sdkVersion, + dsn: fixture.options.dsn, + ); await transport.send(envelope); final envelopeList = arguments as List; @@ -103,7 +114,7 @@ void main() { } class Fixture { - final options = SentryOptions(dsn: ''); + final options = SentryOptions(dsn: fakeDsn); FileSystemTransport getSut(MethodChannel channel) { return FileSystemTransport(channel, options); From 0cb505d770ea29873fd38e6eabcc44412901e4ae Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 10:50:12 +0200 Subject: [PATCH 09/17] pr id --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46630af9a8..bff38cc72d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Fixes - Handle traces sampler exception ([#1040](https://github.com/getsentry/sentry-dart/pull/1040)) -- tracePropagationTargets ignores invalid Regex ([#1043](https://github.com/getsentry/sentry-dart/pull/1043)) +- tracePropagationTargets ignores invalid Regex ([#1050](https://github.com/getsentry/sentry-dart/pull/1050)) ### Features From 4f8a29cd8c3b3eff4240aef6acef7a5158d67f84 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 10:51:51 +0200 Subject: [PATCH 10/17] pr id --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bff38cc72d..644242f8a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ### Features - Added [Flutter renderer](https://docs.flutter.dev/development/platform-integration/web/renderers) information to events ([#1035](https://github.com/getsentry/sentry-dart/pull/1035)) -- Added missing DSN field into the SentryEnvelopeHeader ([#873](https://github.com/getsentry/sentry-dart/pull/873)) +- Added missing DSN field into the SentryEnvelopeHeader ([#1050](https://github.com/getsentry/sentry-dart/pull/1050)) ## 6.11.2 From 441d14fee1953e6e6ae8b02269dcad37abf940db Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 11:06:13 +0200 Subject: [PATCH 11/17] add tests --- dart/test/sentry_client_test.dart | 34 +++++++++++++++++++ dart/test/sentry_envelope_header_test.dart | 4 +++ dart/test/sentry_envelope_test.dart | 5 ++- dart/test/sentry_user_feedback_test.dart | 1 + .../native_app_start_integration_test.dart | 2 -- 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index 5161fcb53b..2cc2d15e62 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -195,6 +195,16 @@ void main() { expect(capturedEvent.threads?.first.stacktrace, isNull); }); + + test('event envelope contains dsn', () async { + final client = fixture.getSut(); + final event = SentryEvent(); + await client.captureEvent(event); + + final capturedEnvelope = (fixture.transport).envelopes.first; + + expect(capturedEnvelope.header.dsn, fixture.options.dsn); + }); }); group('SentryClient captures exception', () { @@ -468,6 +478,16 @@ void main() { expect(id, SentryId.empty()); }); + + test('transaction envelope contains dsn', () async { + final client = fixture.getSut(); + final tr = SentryTransaction(fixture.tracer); + await client.captureTransaction(tr); + + final capturedEnvelope = (fixture.transport).envelopes.first; + + expect(capturedEnvelope.header.dsn, fixture.options.dsn); + }); }); group('SentryClient : apply scope to the captured event', () { @@ -1193,6 +1213,20 @@ void main() { expect(fixture.recorder.reason, DiscardReason.sampleRate); expect(fixture.recorder.category, DataCategory.error); }); + + test('user feedback envelope contains dsn', () async { + final client = fixture.getSut(); + final event = SentryEvent(); + final feedback = SentryUserFeedback( + eventId: event.eventId, + name: 'test', + ); + await client.captureUserFeedback(feedback); + + final capturedEnvelope = (fixture.transport).envelopes.first; + + expect(capturedEnvelope.header.dsn, fixture.options.dsn); + }); }); } diff --git a/dart/test/sentry_envelope_header_test.dart b/dart/test/sentry_envelope_header_test.dart index 912a7ef9e3..23b06a1c5c 100644 --- a/dart/test/sentry_envelope_header_test.dart +++ b/dart/test/sentry_envelope_header_test.dart @@ -2,6 +2,8 @@ import 'package:sentry/sentry.dart'; import 'package:sentry/src/sentry_envelope_header.dart'; import 'package:test/test.dart'; +import 'mocks.dart'; + void main() { group('SentryEnvelopeHeader', () { test('toJson empty', () { @@ -23,6 +25,7 @@ void main() { final sut = SentryEnvelopeHeader( eventId, sdkVersion, + dsn: fakeDsn, traceContext: context, ); final expextedSkd = sdkVersion.toJson(); @@ -30,6 +33,7 @@ void main() { 'event_id': eventId.toString(), 'sdk': expextedSkd, 'trace': context.toJson(), + 'dsn': fakeDsn, }; expect(sut.toJson(), expected); }); diff --git a/dart/test/sentry_envelope_test.dart b/dart/test/sentry_envelope_test.dart index ed37001002..0b4aa4348f 100644 --- a/dart/test/sentry_envelope_test.dart +++ b/dart/test/sentry_envelope_test.dart @@ -65,7 +65,6 @@ void main() { 'trace_id': '${SentryId.newId()}', 'public_key': '123', }); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final sut = SentryEnvelope.fromEvent( sentryEvent, sdkVersion, @@ -78,6 +77,7 @@ void main() { expect(sut.header.eventId, eventId); expect(sut.header.sdkVersion, sdkVersion); expect(sut.header.traceContext, context); + expect(sut.header.dsn, fakeDsn); expect(sut.items[0].header.contentType, expectedEnvelopeItem.header.contentType); expect(sut.items[0].header.type, expectedEnvelopeItem.header.type); @@ -117,6 +117,7 @@ void main() { expect(sut.header.eventId, tr.eventId); expect(sut.header.sdkVersion, sdkVersion); expect(sut.header.traceContext, traceContext); + expect(sut.header.dsn, fakeDsn); expect(sut.items[0].header.contentType, expectedEnvelopeItem.header.contentType); expect(sut.items[0].header.type, expectedEnvelopeItem.header.type); @@ -140,7 +141,6 @@ void main() { final sentryEvent = SentryEvent(eventId: eventId); final sdkVersion = SdkVersion(name: 'fixture-name', version: 'fixture-version'); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final sut = SentryEnvelope.fromEvent( sentryEvent, @@ -172,7 +172,6 @@ void main() { // This is a test for https://github.com/getsentry/sentry-dart/issues/523 test('serialize with non-serializable class', () async { final event = SentryEvent(extra: {'non-ecodable': NonEncodable()}); - final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final sut = SentryEnvelope.fromEvent( event, SdkVersion( diff --git a/dart/test/sentry_user_feedback_test.dart b/dart/test/sentry_user_feedback_test.dart index 93e5764b6a..a9af1a81b5 100644 --- a/dart/test/sentry_user_feedback_test.dart +++ b/dart/test/sentry_user_feedback_test.dart @@ -83,6 +83,7 @@ void main() { SentryItemType.userFeedback, ); expect(envelope.header.eventId.toString(), feedback.eventId.toString()); + expect(envelope.header.dsn, fakeDsn); }); }); diff --git a/flutter/test/integrations/native_app_start_integration_test.dart b/flutter/test/integrations/native_app_start_integration_test.dart index ef851af6ac..5bc5dbc4a7 100644 --- a/flutter/test/integrations/native_app_start_integration_test.dart +++ b/flutter/test/integrations/native_app_start_integration_test.dart @@ -10,8 +10,6 @@ import 'package:sentry/src/sentry_tracer.dart'; import '../mocks.dart'; import '../mocks.mocks.dart'; -const fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; - void main() { group('$NativeAppStartIntegration', () { late Fixture fixture; From 52265fe124f8fe3b38c9bd412b5702bcfcf9def8 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 11:07:59 +0200 Subject: [PATCH 12/17] fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 644242f8a7..55ec1ff7c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Fixes - Handle traces sampler exception ([#1040](https://github.com/getsentry/sentry-dart/pull/1040)) -- tracePropagationTargets ignores invalid Regex ([#1050](https://github.com/getsentry/sentry-dart/pull/1050)) +- tracePropagationTargets ignores invalid Regex ([#1043](https://github.com/getsentry/sentry-dart/pull/1043)) ### Features From 06fc8cfb0434dc61485202e85849898a5873db37 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 11:09:27 +0200 Subject: [PATCH 13/17] remove --- dart/test/test.dart | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 dart/test/test.dart diff --git a/dart/test/test.dart b/dart/test/test.dart deleted file mode 100644 index 8ce2a15a6f..0000000000 --- a/dart/test/test.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:sentry/sentry.dart'; - -void test() { - final transaction = Sentry.getSpan(); - - // Record amount of memory used - transaction?.setMeasurement('memoryUsed', 123, - unit: SentryMeasurementUnit.byte); - - // Record time when Footer component renders on page - transaction?.setMeasurement('ui.footerComponent.render', 1.3, - unit: SentryMeasurementUnit.second); - - // Record amount of times localStorage was read - transaction?.setMeasurement('localStorageRead', 4); -} From 64c803ff0ca3f9f70a36802669cfb68b94b00b0d Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 11:30:33 +0200 Subject: [PATCH 14/17] fix --- .../test/android_platform_exception_event_processor_test.dart | 2 +- flutter/test/file_system_transport_test.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flutter/test/android_platform_exception_event_processor_test.dart b/flutter/test/android_platform_exception_event_processor_test.dart index 77a85724da..cbc375b837 100644 --- a/flutter/test/android_platform_exception_event_processor_test.dart +++ b/flutter/test/android_platform_exception_event_processor_test.dart @@ -7,7 +7,7 @@ import 'package:package_info_plus/package_info_plus.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/event_processor/android_platform_exception_event_processor.dart'; -import 'integrations/native_app_start_integration_test.dart'; +import 'mocks.dart'; void main() { late Fixture fixture; diff --git a/flutter/test/file_system_transport_test.dart b/flutter/test/file_system_transport_test.dart index 5bad534153..a8c185fae3 100644 --- a/flutter/test/file_system_transport_test.dart +++ b/flutter/test/file_system_transport_test.dart @@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:sentry/sentry.dart'; import 'package:sentry_flutter/src/file_system_transport.dart'; -import 'integrations/native_app_start_integration_test.dart'; +import 'mocks.dart'; void main() { const _channel = MethodChannel('sentry_flutter'); From 614334e97c58b69347f69ae0f95f9a4ca8eb6c99 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 12:06:36 +0200 Subject: [PATCH 15/17] move bytes to file --- dart/test/sentry_envelope_vm_test.dart | 285 +----------------- .../envelope-no-attachment.envelope | 3 + 2 files changed, 7 insertions(+), 281 deletions(-) create mode 100644 dart/test_resources/envelope-no-attachment.envelope diff --git a/dart/test/sentry_envelope_vm_test.dart b/dart/test/sentry_envelope_vm_test.dart index ceeecd4e9a..5c3340761b 100644 --- a/dart/test/sentry_envelope_vm_test.dart +++ b/dart/test/sentry_envelope_vm_test.dart @@ -62,287 +62,10 @@ void main() { final data = (await envelope.envelopeStream(SentryOptions()).toList()) .reduce((a, b) => a + b); - expect(data, envelopeBinaryData); + final file = File('test_resources/envelope-no-attachment.envelope'); + final bytes = await file.readAsBytes(); + + expect(data, bytes); }); }); } - -final envelopeBinaryData = [ - 123, - 34, - 101, - 118, - 101, - 110, - 116, - 95, - 105, - 100, - 34, - 58, - 34, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 34, - 44, - 34, - 115, - 100, - 107, - 34, - 58, - 123, - 34, - 110, - 97, - 109, - 101, - 34, - 58, - 34, - 34, - 44, - 34, - 118, - 101, - 114, - 115, - 105, - 111, - 110, - 34, - 58, - 34, - 34, - 125, - 44, - 34, - 100, - 115, - 110, - 34, - 58, - 34, - 104, - 116, - 116, - 112, - 115, - 58, - 47, - 47, - 97, - 98, - 99, - 64, - 100, - 101, - 102, - 46, - 105, - 110, - 103, - 101, - 115, - 116, - 46, - 115, - 101, - 110, - 116, - 114, - 121, - 46, - 105, - 111, - 47, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 34, - 125, - 10, - 123, - 34, - 99, - 111, - 110, - 116, - 101, - 110, - 116, - 95, - 116, - 121, - 112, - 101, - 34, - 58, - 34, - 97, - 112, - 112, - 108, - 105, - 99, - 97, - 116, - 105, - 111, - 110, - 47, - 106, - 115, - 111, - 110, - 34, - 44, - 34, - 116, - 121, - 112, - 101, - 34, - 58, - 34, - 101, - 118, - 101, - 110, - 116, - 34, - 44, - 34, - 108, - 101, - 110, - 103, - 116, - 104, - 34, - 58, - 56, - 54, - 125, - 10, - 123, - 34, - 101, - 118, - 101, - 110, - 116, - 95, - 105, - 100, - 34, - 58, - 34, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 48, - 34, - 44, - 34, - 116, - 105, - 109, - 101, - 115, - 116, - 97, - 109, - 112, - 34, - 58, - 34, - 49, - 57, - 55, - 48, - 45, - 48, - 49, - 45, - 48, - 49, - 84, - 48, - 48, - 58, - 48, - 48, - 58, - 48, - 48, - 46, - 48, - 48, - 48, - 90, - 34, - 125 -]; diff --git a/dart/test_resources/envelope-no-attachment.envelope b/dart/test_resources/envelope-no-attachment.envelope new file mode 100644 index 0000000000..0faac03efa --- /dev/null +++ b/dart/test_resources/envelope-no-attachment.envelope @@ -0,0 +1,3 @@ +{"event_id":"00000000000000000000000000000000","sdk":{"name":"","version":""},"dsn":"https://abc@def.ingest.sentry.io/1234567"} +{"content_type":"application/json","type":"event","length":86} +{"event_id":"00000000000000000000000000000000","timestamp":"1970-01-01T00:00:00.000Z"} \ No newline at end of file From 9cd0ac9726d88f5a05c0bb2fcf6f687aa80d942c Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 13:45:29 +0200 Subject: [PATCH 16/17] test --- dart/test/sentry_envelope_vm_test.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dart/test/sentry_envelope_vm_test.dart b/dart/test/sentry_envelope_vm_test.dart index 5c3340761b..8e216bf226 100644 --- a/dart/test/sentry_envelope_vm_test.dart +++ b/dart/test/sentry_envelope_vm_test.dart @@ -1,4 +1,5 @@ @TestOn('vm') +import 'dart:convert'; import 'dart:io'; import 'package:sentry/sentry_io.dart'; @@ -63,9 +64,10 @@ void main() { .reduce((a, b) => a + b); final file = File('test_resources/envelope-no-attachment.envelope'); - final bytes = await file.readAsBytes(); + final jsonStr = await file.readAsString(); + final dataStr = utf8.decode(data); - expect(data, bytes); + expect(dataStr, jsonStr); }); }); } From a0ef68c6f473c45a4bb7947b04e48374353c8bd3 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 7 Oct 2022 15:19:58 +0200 Subject: [PATCH 17/17] lf fix --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index a19ade077d..82afe757ba 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ CHANGELOG.md merge=union +* text=auto eol=lf