Skip to content

Commit cf64268

Browse files
authored
Merge branch 'main' into feat/use-app-launched-in-foreground-to-determinate-invalid-app-start-data-on-android
2 parents b2dc712 + fe6dcac commit cf64268

File tree

140 files changed

+846
-514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+846
-514
lines changed

dart/lib/src/event_processor/enricher/io_enricher_event_processor.dart

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class IoEnricherEventProcessor implements EnricherEventProcessor {
100100
exception: exception,
101101
stackTrace: stackTrace,
102102
);
103+
if (_options.automatedTestMode) {
104+
rethrow;
105+
}
103106
}
104107
}
105108

dart/lib/src/event_processor/enricher/io_platform_memory.dart

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class PlatformMemory {
7575
}
7676
} catch (e) {
7777
options.logger(SentryLevel.warning, "Failed to run process: $e");
78+
if (options.automatedTestMode) {
79+
rethrow;
80+
}
7881
}
7982
return null;
8083
}

dart/lib/src/event_processor/exception/io_exception_event_processor.dart

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class IoExceptionEventProcessor implements ExceptionEventProcessor {
6969
exception: exception,
7070
stackTrace: stackTrace,
7171
);
72+
if (_options.automatedTestMode) {
73+
rethrow;
74+
}
7275
}
7376

7477
return event.copyWith(

dart/lib/src/hub.dart

+27
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ class Hub {
124124
exception: exception,
125125
stackTrace: stackTrace,
126126
);
127+
if (_options.automatedTestMode) {
128+
rethrow;
129+
}
127130
} finally {
128131
_lastEventId = sentryId;
129132
}
@@ -183,6 +186,9 @@ class Hub {
183186
exception: exception,
184187
stackTrace: stackTrace,
185188
);
189+
if (_options.automatedTestMode) {
190+
rethrow;
191+
}
186192
} finally {
187193
_lastEventId = sentryId;
188194
}
@@ -238,6 +244,9 @@ class Hub {
238244
exception: exception,
239245
stackTrace: stackTrace,
240246
);
247+
if (_options.automatedTestMode) {
248+
rethrow;
249+
}
241250
} finally {
242251
_lastEventId = sentryId;
243252
}
@@ -271,6 +280,9 @@ class Hub {
271280
exception: exception,
272281
stackTrace: stacktrace,
273282
);
283+
if (_options.automatedTestMode) {
284+
rethrow;
285+
}
274286
}
275287
}
276288

@@ -364,6 +376,9 @@ class Hub {
364376
exception: exception,
365377
stackTrace: stackTrace,
366378
);
379+
if (_options.automatedTestMode) {
380+
rethrow;
381+
}
367382
}
368383

369384
_isEnabled = false;
@@ -565,6 +580,9 @@ class Hub {
565580
exception: exception,
566581
stackTrace: stackTrace,
567582
);
583+
if (_options.automatedTestMode) {
584+
rethrow;
585+
}
568586
}
569587
}
570588
}
@@ -602,6 +620,9 @@ class Hub {
602620
exception: exception,
603621
stackTrace: stackTrace,
604622
);
623+
if (_options.automatedTestMode) {
624+
rethrow;
625+
}
605626
}
606627
}
607628
return sentryId;
@@ -682,6 +703,9 @@ class _WeakMap {
682703
exception: exception,
683704
stackTrace: stackTrace,
684705
);
706+
if (_options.automatedTestMode) {
707+
rethrow;
708+
}
685709
}
686710
}
687711

@@ -699,6 +723,9 @@ class _WeakMap {
699723
exception: exception,
700724
stackTrace: stackTrace,
701725
);
726+
if (_options.automatedTestMode) {
727+
rethrow;
728+
}
702729
}
703730
return null;
704731
}

dart/lib/src/load_dart_debug_images_integration.dart

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class _LoadImageIntegrationEventProcessor implements EventProcessor {
4242
exception: e,
4343
stackTrace: stackTrace,
4444
);
45+
if (_options.automatedTestMode) {
46+
rethrow;
47+
}
4548
return event;
4649
}
4750
}

dart/lib/src/recursive_exception_cause_extractor.dart

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class RecursiveExceptionCauseExtractor {
4141
exception: exception,
4242
stackTrace: stackTrace,
4343
);
44+
if (_options.automatedTestMode) {
45+
rethrow;
46+
}
4447
break;
4548
}
4649
}

dart/lib/src/sentry_baggage.dart

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class SentryBaggage {
5555
exception: exception,
5656
stackTrace: stackTrace,
5757
);
58+
// TODO rethrow in options.automatedTestMode (currently not available here to check)
5859
}
5960
}
6061

dart/lib/src/sentry_envelope_item.dart

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class SentryEnvelopeItem {
132132
// TODO the data copy could be avoided - this would be most significant with attachments.
133133
return [...itemHeader, ...newLine, ...data];
134134
} catch (e) {
135+
// TODO rethrow in options.automatedTestMode (currently not available here to check)
135136
return [];
136137
}
137138
}

dart/lib/src/transport/http_transport.dart

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class HttpTransport implements Transport {
6464
return eventId != null ? SentryId.fromId(eventId) : null;
6565
} catch (e) {
6666
_options.logger(SentryLevel.error, 'Error parsing response: $e');
67+
if (_options.automatedTestMode) {
68+
rethrow;
69+
}
6770
return null;
6871
}
6972
}

dart/lib/src/transport/spotlight_http_transport.dart

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class SpotlightHttpTransport extends Transport {
3131
} catch (e) {
3232
_options.logger(
3333
SentryLevel.warning, 'Failed to send envelope to Spotlight: $e');
34+
if (_options.automatedTestMode) {
35+
rethrow;
36+
}
3437
}
3538
return _transport.send(envelope);
3639
}

dart/test/debug_image_extractor_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import 'package:test/test.dart';
2-
import 'package:sentry/sentry.dart';
32
import 'package:sentry/src/debug_image_extractor.dart';
43

54
import 'mocks/mock_platform.dart';
65
import 'mocks/mock_platform_checker.dart';
6+
import 'test_utils.dart';
77

88
void main() {
99
group(DebugImageExtractor, () {
@@ -112,8 +112,7 @@ isolate_dso_base: 10000000
112112

113113
class Fixture {
114114
DebugImageExtractor getSut({required MockPlatform platform}) {
115-
final options = SentryOptions(dsn: 'https://[email protected]/1')
116-
..platformChecker = MockPlatformChecker(platform: platform);
115+
final options = defaultTestOptions(MockPlatformChecker(platform: platform));
117116
return DebugImageExtractor(options);
118117
}
119118
}

dart/test/diagnostic_logger_test.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import 'package:sentry/sentry.dart';
22
import 'package:sentry/src/diagnostic_logger.dart';
33
import 'package:test/test.dart';
44

5+
import 'test_utils.dart';
6+
57
void main() {
68
late Fixture fixture;
79

@@ -44,7 +46,7 @@ void main() {
4446
}
4547

4648
class Fixture {
47-
var options = SentryOptions();
49+
var options = defaultTestOptions();
4850

4951
Object? loggedMessage;
5052

dart/test/environment_test.dart

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:test/test.dart';
33

44
import 'mocks.dart';
55
import 'mocks/mock_environment_variables.dart';
6+
import 'test_utils.dart';
67

78
void main() {
89
// See https://docs.sentry.io/platforms/dart/configuration/options/
@@ -13,7 +14,7 @@ void main() {
1314
});
1415

1516
test('SentryOptions are not overriden by environment', () async {
16-
final options = SentryOptions(dsn: fakeDsn);
17+
final options = defaultTestOptions();
1718
options.release = 'release-1.2.3';
1819
options.dist = 'foo';
1920
options.environment = 'prod';
@@ -23,28 +24,26 @@ void main() {
2324
release: 'release-9.8.7',
2425
dist: 'bar',
2526
);
26-
options.automatedTestMode = true;
2727

2828
await Sentry.init(
2929
(options) => options,
3030
options: options,
3131
);
3232

33-
expect(options.dsn, fakeDsn);
33+
expect(options.dsn, testDsn);
3434
expect(options.environment, 'prod');
3535
expect(options.release, 'release-1.2.3');
3636
expect(options.dist, 'foo');
3737
});
3838

3939
test('SentryOptions are overriden by environment', () async {
40-
final options = SentryOptions();
40+
final options = defaultTestOptions()..dsn = null;
4141
options.environmentVariables = MockEnvironmentVariables(
4242
dsn: fakeDsn,
4343
environment: 'staging',
4444
release: 'release-9.8.7',
4545
dist: 'bar',
4646
);
47-
options.automatedTestMode = true;
4847

4948
await Sentry.init(
5049
(options) => options,

dart/test/event_processor/deduplication_event_processor_test.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:test/test.dart';
66
import '../mocks.dart';
77
import '../mocks/mock_hub.dart';
88
import '../mocks/mock_transport.dart';
9+
import '../test_utils.dart';
910

1011
void main() {
1112
group('$DeduplicationEventProcessor', () {
@@ -77,14 +78,13 @@ void main() {
7778

7879
final transport = MockTransport();
7980

80-
final options = SentryOptions(dsn: fakeDsn)..automatedTestMode = true;
8181
await Sentry.init(
8282
(options) {
8383
options.dsn = fakeDsn;
8484
options.transport = transport;
8585
options.enableDeduplication = true;
8686
},
87-
options: options,
87+
options: defaultTestOptions(),
8888
);
8989

9090
// The test doesn't work if `outerTestMethod` is passed as
@@ -114,7 +114,7 @@ class Fixture {
114114

115115
DeduplicationEventProcessor getSut(bool enabled,
116116
[int? maxDeduplicationItems]) {
117-
final options = SentryOptions(dsn: fakeDsn)
117+
final options = defaultTestOptions()
118118
..enableDeduplication = enabled
119119
..maxDeduplicationItems = maxDeduplicationItems ?? 5;
120120

dart/test/event_processor/enricher/io_enricher_test.dart

+6-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:test/test.dart';
99

1010
import '../../mocks.dart';
1111
import '../../mocks/mock_platform_checker.dart';
12+
import '../../test_utils.dart';
1213

1314
void main() {
1415
group('io_enricher', () {
@@ -164,20 +165,17 @@ void main() {
164165
});
165166

166167
test('$IoEnricherEventProcessor gets added on init', () async {
167-
final options = SentryOptions(dsn: fakeDsn)..automatedTestMode = true;
168-
late SentryOptions configuredOptions;
168+
final options = defaultTestOptions();
169169
await Sentry.init(
170170
(options) {
171171
options.dsn = fakeDsn;
172-
configuredOptions = options;
173172
},
174173
options: options,
175174
);
176175
await Sentry.close();
177176

178-
final ioEnricherCount = configuredOptions.eventProcessors
179-
.whereType<IoEnricherEventProcessor>()
180-
.length;
177+
final ioEnricherCount =
178+
options.eventProcessors.whereType<IoEnricherEventProcessor>().length;
181179
expect(ioEnricherCount, 1);
182180
});
183181
});
@@ -188,10 +186,8 @@ class Fixture {
188186
bool hasNativeIntegration = false,
189187
bool includePii = false,
190188
}) {
191-
final options = SentryOptions(
192-
dsn: fakeDsn,
193-
checker:
194-
MockPlatformChecker(hasNativeIntegration: hasNativeIntegration))
189+
final options = defaultTestOptions(
190+
MockPlatformChecker(hasNativeIntegration: hasNativeIntegration))
195191
..sendDefaultPii = includePii;
196192

197193
return IoEnricherEventProcessor(options);

dart/test/event_processor/enricher/io_platform_memory_test.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ library dart_test;
33

44
import 'dart:io';
55

6-
import 'package:sentry/sentry.dart';
76
import 'package:sentry/src/event_processor/enricher/io_platform_memory.dart';
87
import 'package:test/test.dart';
98

9+
import '../../test_utils.dart';
10+
1011
void main() {
1112
late Fixture fixture;
1213

@@ -52,7 +53,7 @@ void main() {
5253
}
5354

5455
class Fixture {
55-
var options = SentryOptions();
56+
var options = defaultTestOptions();
5657

5758
PlatformMemory getSut() {
5859
return PlatformMemory(options);

dart/test/event_processor/enricher/web_enricher_test.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:test/test.dart';
99

1010
import '../../mocks.dart';
1111
import '../../mocks/mock_platform_checker.dart';
12+
import '../../test_utils.dart';
1213

1314
// can be tested on command line with
1415
// `dart test -p chrome --name web_enricher`
@@ -201,9 +202,8 @@ void main() {
201202

202203
class Fixture {
203204
WebEnricherEventProcessor getSut() {
204-
final options = SentryOptions(
205-
dsn: fakeDsn,
206-
checker: MockPlatformChecker(hasNativeIntegration: false));
205+
final options =
206+
defaultTestOptions(MockPlatformChecker(hasNativeIntegration: false));
207207
return enricherEventProcessor(options) as WebEnricherEventProcessor;
208208
}
209209
}

0 commit comments

Comments
 (0)