Skip to content

Commit aa8bcc6

Browse files
committed
Merge branch 'feat/feature-flags-integration' into fear/firebase-feature-flags
2 parents 42eea2e + 4f247a5 commit aa8bcc6

File tree

123 files changed

+1165
-1169
lines changed

Some content is hidden

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

123 files changed

+1165
-1169
lines changed

CHANGELOG.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
Sentry.addFeatureFlag('my-feature', true);
1111
```
1212

13+
### Behavioral changes
14+
15+
- Set log level to `warning` by default when `debug = true` ([#2836](https://github.com/getsentry/sentry-dart/pull/2836))
16+
17+
### API Changes
18+
19+
- Update naming of `LoadImagesListIntegration` to `LoadNativeDebugImagesIntegration` ([#2833](https://github.com/getsentry/sentry-dart/pull/2833))
20+
1321
### Dependencies
1422

1523
- Bump Android SDK from v8.2.0 to v8.6.0 ([#2819](https://github.com/getsentry/sentry-dart/pull/2819), [#2831](https://github.com/getsentry/sentry-dart/pull/2831))
@@ -21,6 +29,15 @@ Sentry.addFeatureFlag('my-feature', true);
2129
- Bump Native SDK from v0.8.2 to v0.8.3 ([#2823](https://github.com/getsentry/sentry-dart/pull/2823))
2230
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#083)
2331
- [diff](https://github.com/getsentry/sentry-native/compare/0.8.2...0.8.3)
32+
- Bump jni from v0.14.0 to v0.14.1 ([#2800])(https://github.com/getsentry/sentry-dart/pull/2800)
33+
- [changelog](https://github.com/dart-lang/native/blob/main/pkgs/jni/CHANGELOG.md#0141)
34+
- [diff](https://github.com/dart-lang/native/compare/jnigen-v0.14.0..jnigen-v0.14.1)
35+
36+
### Behavioral changes
37+
38+
- Mutable Data Classes ([#2818](https://github.com/getsentry/sentry-dart/pull/2818))
39+
- Some SDK classes do not have `const` constructors anymore.
40+
- The `copyWith` and `clone` methods of SDK classes were deprecated.
2441

2542
## 9.0.0-alpha.2
2643

@@ -37,13 +54,13 @@ Sentry.addFeatureFlag('my-feature', true);
3754
- Bump Javascript SDK from v8.42.0 to v9.5.0 ([#2784](https://github.com/getsentry/sentry-dart/pull/2784))
3855
- [changelog](https://github.com/getsentry/sentry-javascript/blob/main/CHANGELOG.md#950)
3956
- [diff](https://github.com/getsentry/sentry-javascript/compare/8.42.0...9.5.0)
40-
57+
4158
### Behavioral changes
4259

4360
- Set sentry-native backend to `crashpad` by default and `breakpad` for Windows ARM64 ([#2791](https://github.com/getsentry/sentry-dart/pull/2791))
4461
- Setting the `SENTRY_NATIVE_BACKEND` environment variable will override the defaults.
4562
- Remove renderer from `flutter_context` ([#2751](https://github.com/getsentry/sentry-dart/pull/2751))
46-
63+
4764
### API changes
4865

4966
- Move replay and privacy from experimental to options ([#2755](https://github.com/getsentry/sentry-dart/pull/2755))

dart/example/bin/event_example.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ final event = SentryEvent(
2929
)
3030
],
3131
contexts: Contexts(
32-
operatingSystem: const SentryOperatingSystem(
32+
operatingSystem: SentryOperatingSystem(
3333
name: 'Android',
3434
version: '5.0.2',
3535
build: 'LRX22G.P900XXS0BPL2',
3636
kernelVersion:
3737
'Linux version 3.4.39-5726670 (dpi@SWHC3807) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Thu Dec 1 19:42:39 KST 2016',
3838
rooted: false,
3939
),
40-
runtimes: [const SentryRuntime(name: 'ART', version: '5')],
40+
runtimes: [SentryRuntime(name: 'ART', version: '5')],
4141
app: SentryApp(
4242
name: 'Example Dart App',
4343
version: '1.42.0',
@@ -47,7 +47,7 @@ final event = SentryEvent(
4747
deviceAppHash: '5afd3a6',
4848
startTime: DateTime.now().toUtc(),
4949
),
50-
browser: const SentryBrowser(name: 'Firefox', version: '42.0.1'),
50+
browser: SentryBrowser(name: 'Firefox', version: '42.0.1'),
5151
device: SentryDevice(
5252
name: 'SM-P900',
5353
family: 'SM-P900',

dart/example_web/web/event.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ final event = SentryEvent(
2828
)
2929
],
3030
contexts: Contexts(
31-
operatingSystem: const SentryOperatingSystem(
31+
operatingSystem: SentryOperatingSystem(
3232
name: 'Android',
3333
version: '5.0.2',
3434
build: 'LRX22G.P900XXS0BPL2',
3535
kernelVersion:
3636
'Linux version 3.4.39-5726670 (dpi@SWHC3807) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Thu Dec 1 19:42:39 KST 2016',
3737
rooted: false,
3838
),
39-
runtimes: [const SentryRuntime(name: 'ART', version: '5')],
39+
runtimes: [SentryRuntime(name: 'ART', version: '5')],
4040
app: SentryApp(
4141
name: 'Example Dart App',
4242
version: '1.42.0',
@@ -46,7 +46,7 @@ final event = SentryEvent(
4646
deviceAppHash: '5afd3a6',
4747
startTime: DateTime.now().toUtc(),
4848
),
49-
browser: const SentryBrowser(name: 'Firefox', version: '42.0.1'),
49+
browser: SentryBrowser(name: 'Firefox', version: '42.0.1'),
5050
device: SentryDevice(
5151
name: 'SM-P900',
5252
family: 'SM-P900',

dart/lib/src/diagnostic_logger.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import 'protocol.dart';
22
import 'sentry_options.dart';
33

44
class DiagnosticLogger {
5-
final SentryLogger _logger;
65
final SentryOptions _options;
6+
final SentryLogger _logger;
7+
SentryLogger get logger => _logger;
78

89
DiagnosticLogger(this._logger, this._options);
910

dart/lib/src/event_processor/enricher/flutter_runtime.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const _isFlutterRuntimeInformationAbsent = FlutterVersion.version == null ||
1717
FlutterVersion.channel == null ||
1818
FlutterVersion.frameworkRevision == null;
1919

20-
const SentryRuntime? flutterRuntime = _isFlutterRuntimeInformationAbsent
20+
final SentryRuntime? flutterRuntime = _isFlutterRuntimeInformationAbsent
2121
? null
2222
: SentryRuntime(
2323
name: 'Flutter',
@@ -28,7 +28,7 @@ const SentryRuntime? flutterRuntime = _isFlutterRuntimeInformationAbsent
2828
'- Git URL ${FlutterVersion.gitUrl}',
2929
);
3030

31-
const SentryRuntime? dartFlutterRuntime = FlutterVersion.dartVersion == null
31+
final SentryRuntime? dartFlutterRuntime = FlutterVersion.dartVersion == null
3232
? null
3333
: SentryRuntime(name: 'Dart', version: FlutterVersion.dartVersion);
3434

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

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ class IoEnricherEventProcessor implements EnricherEventProcessor {
4444
Future<SentryEvent?> apply(SentryEvent event, Hint hint) async {
4545
final contexts = event.contexts;
4646

47-
contexts.device = await _getDevice(event.contexts.device);
48-
contexts.operatingSystem =
49-
_getOperatingSystem(event.contexts.operatingSystem);
50-
contexts.runtimes = _getRuntimes(event.contexts.runtimes);
51-
contexts.app = _getApp(event.contexts.app);
52-
contexts.culture = _getSentryCulture(event.contexts.culture);
47+
contexts
48+
..device = await _getDevice(event.contexts.device)
49+
..operatingSystem = _getOperatingSystem(event.contexts.operatingSystem)
50+
..runtimes = _getRuntimes(event.contexts.runtimes)
51+
..app = _getApp(event.contexts.app)
52+
..culture = _getSentryCulture(event.contexts.culture);
5353

5454
contexts['dart_context'] = _getDartContext();
5555

56-
return event.copyWith(
57-
contexts: contexts,
58-
);
56+
event.contexts = contexts;
57+
58+
return event;
5959
}
6060

6161
List<SentryRuntime> _getRuntimes(List<SentryRuntime>? runtimes) {
@@ -102,13 +102,13 @@ class IoEnricherEventProcessor implements EnricherEventProcessor {
102102
}
103103

104104
Future<SentryDevice> _getDevice(SentryDevice? device) async {
105-
return (device ?? SentryDevice()).copyWith(
106-
name: device?.name ??
107-
(_options.sendDefaultPii ? Platform.localHostname : null),
108-
processorCount: device?.processorCount ?? Platform.numberOfProcessors,
109-
memorySize: device?.memorySize ?? await _getTotalPhysicalMemory(),
110-
freeMemory: device?.freeMemory,
111-
);
105+
device ??= SentryDevice();
106+
return device
107+
..name = device.name ??
108+
(_options.sendDefaultPii ? Platform.localHostname : null)
109+
..processorCount = device.processorCount ?? Platform.numberOfProcessors
110+
..memorySize = device.memorySize ?? await _getTotalPhysicalMemory()
111+
..freeMemory = device.freeMemory;
112112
}
113113

114114
Future<int?> _getTotalPhysicalMemory() async {
@@ -121,14 +121,22 @@ class IoEnricherEventProcessor implements EnricherEventProcessor {
121121
}
122122

123123
SentryApp _getApp(SentryApp? app) {
124-
return (app ?? SentryApp()).copyWith(
125-
appMemory: app?.appMemory ?? ProcessInfo.currentRss,
126-
);
124+
app ??= SentryApp();
125+
return app..appMemory = app.appMemory ?? ProcessInfo.currentRss;
127126
}
128127

129128
SentryOperatingSystem _getOperatingSystem(SentryOperatingSystem? os) {
130129
if (os == null) {
131-
return _os.clone();
130+
return SentryOperatingSystem(
131+
name: _os.name,
132+
version: _os.version,
133+
build: _os.build,
134+
kernelVersion: _os.kernelVersion,
135+
rooted: _os.rooted,
136+
rawDescription: _os.rawDescription,
137+
theme: _os.theme,
138+
unknown: _os.unknown,
139+
);
132140
} else {
133141
return _os.mergeWith(os);
134142
}
@@ -171,10 +179,10 @@ class IoEnricherEventProcessor implements EnricherEventProcessor {
171179
}
172180

173181
SentryCulture _getSentryCulture(SentryCulture? culture) {
174-
return (culture ?? SentryCulture()).copyWith(
175-
locale: culture?.locale ?? Platform.localeName,
176-
timezone: culture?.timezone ?? DateTime.now().timeZoneName,
177-
);
182+
culture ??= SentryCulture();
183+
return culture
184+
..locale = culture.locale ?? Platform.localeName
185+
..timezone = culture.timezone ?? DateTime.now().timeZoneName;
178186
}
179187
}
180188

dart/lib/src/event_processor/enricher/web_enricher_event_processor.dart

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,16 @@ class WebEnricherEventProcessor implements EnricherEventProcessor {
2424
@override
2525
SentryEvent? apply(SentryEvent event, Hint hint) {
2626
// Web has no native integration, so no need to check for it
27+
event.contexts
28+
..device = _getDevice(event.contexts.device)
29+
..culture = _getSentryCulture(event.contexts.culture)
30+
..runtimes = _getRuntimes(event.contexts.runtimes);
2731

28-
final contexts = event.contexts.copyWith(
29-
device: _getDevice(event.contexts.device),
30-
culture: _getSentryCulture(event.contexts.culture),
31-
runtimes: _getRuntimes(event.contexts.runtimes),
32-
);
32+
event.contexts['dart_context'] = _getDartContext();
3333

34-
contexts['dart_context'] = _getDartContext();
35-
36-
return event.copyWith(
37-
contexts: contexts,
38-
request: _getRequest(event.request),
39-
transaction: event.transaction ?? _window.location.pathname,
40-
);
34+
return event
35+
..request = _getRequest(event.request)
36+
..transaction = event.transaction ?? _window.location.pathname;
4137
}
4238

4339
// As seen in
@@ -51,22 +47,24 @@ class WebEnricherEventProcessor implements EnricherEventProcessor {
5147
header.putIfAbsent('User-Agent', () => _window.navigator.userAgent);
5248

5349
final url = request?.url ?? _window.location.toString();
54-
return (request ?? SentryRequest(url: url))
55-
.copyWith(headers: header)
56-
.sanitized();
50+
request ??= SentryRequest(url: url);
51+
return request
52+
..headers = header
53+
..sanitize();
5754
}
5855

5956
SentryDevice _getDevice(SentryDevice? device) {
60-
return (device ?? SentryDevice()).copyWith(
61-
online: device?.online ?? _window.navigator.onLine,
62-
memorySize: device?.memorySize ?? _getMemorySize(),
63-
orientation: device?.orientation ?? _getScreenOrientation(),
64-
screenHeightPixels:
65-
device?.screenHeightPixels ?? _window.screen.availHeight,
66-
screenWidthPixels: device?.screenWidthPixels ?? _window.screen.availWidth,
67-
screenDensity:
68-
device?.screenDensity ?? _window.devicePixelRatio.toDouble(),
69-
);
57+
device ??= SentryDevice();
58+
return device
59+
..online = device.online ?? _window.navigator.onLine
60+
..memorySize = device.memorySize ?? _getMemorySize()
61+
..orientation = device.orientation ?? _getScreenOrientation()
62+
..screenHeightPixels =
63+
device.screenHeightPixels ?? _window.screen.availHeight
64+
..screenWidthPixels =
65+
device.screenWidthPixels ?? _window.screen.availWidth
66+
..screenDensity =
67+
device.screenDensity ?? _window.devicePixelRatio.toDouble();
7068
}
7169

7270
int? _getMemorySize() {
@@ -96,9 +94,8 @@ class WebEnricherEventProcessor implements EnricherEventProcessor {
9694
}
9795

9896
SentryCulture _getSentryCulture(SentryCulture? culture) {
99-
return (culture ?? SentryCulture()).copyWith(
100-
timezone: culture?.timezone ?? DateTime.now().timeZoneName,
101-
);
97+
culture ??= SentryCulture();
98+
return culture..timezone = culture.timezone ?? DateTime.now().timeZoneName;
10299
}
103100

104101
List<SentryRuntime> _getRuntimes(List<SentryRuntime>? runtimes) {

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

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ class IoExceptionEventProcessor implements ExceptionEventProcessor {
3535
if (uri == null) {
3636
return event;
3737
}
38-
return event.copyWith(
39-
request: event.request ?? SentryRequest.fromUri(uri: uri),
40-
);
38+
return event..request = event.request ?? SentryRequest.fromUri(uri: uri);
4139
}
4240

4341
// https://api.dart.dev/stable/dart-io/SocketException-class.html
@@ -48,15 +46,14 @@ class IoExceptionEventProcessor implements ExceptionEventProcessor {
4846
final address = exception.address;
4947
final osError = exception.osError;
5048
if (address == null) {
51-
return event.copyWith(
52-
exceptions: [
53-
// OSError is the underlying error
54-
// https://api.dart.dev/stable/dart-io/SocketException/osError.html
55-
// https://api.dart.dev/stable/dart-io/OSError-class.html
56-
if (osError != null) _sentryExceptionfromOsError(osError),
57-
...?event.exceptions,
58-
],
59-
);
49+
event.exceptions = [
50+
// OSError is the underlying error
51+
// https://api.dart.dev/stable/dart-io/SocketException/osError.html
52+
// https://api.dart.dev/stable/dart-io/OSError-class.html
53+
if (osError != null) _sentryExceptionfromOsError(osError),
54+
...?event.exceptions,
55+
];
56+
return event;
6057
}
6158
SentryRequest? request;
6259
try {
@@ -74,16 +71,15 @@ class IoExceptionEventProcessor implements ExceptionEventProcessor {
7471
}
7572
}
7673

77-
return event.copyWith(
78-
request: event.request ?? request,
79-
exceptions: [
80-
// OSError is the underlying error
81-
// https://api.dart.dev/stable/dart-io/SocketException/osError.html
82-
// https://api.dart.dev/stable/dart-io/OSError-class.html
83-
if (osError != null) _sentryExceptionfromOsError(osError),
84-
...?event.exceptions,
85-
],
86-
);
74+
event.request = event.request ?? request;
75+
event.exceptions = [
76+
// OSError is the underlying error
77+
// https://api.dart.dev/stable/dart-io/SocketException/osError.html
78+
// https://api.dart.dev/stable/dart-io/OSError-class.html
79+
if (osError != null) _sentryExceptionfromOsError(osError),
80+
...?event.exceptions,
81+
];
82+
return event;
8783
}
8884

8985
// https://api.dart.dev/stable/dart-io/FileSystemException-class.html
@@ -92,15 +88,14 @@ class IoExceptionEventProcessor implements ExceptionEventProcessor {
9288
SentryEvent event,
9389
) {
9490
final osError = exception.osError;
95-
return event.copyWith(
96-
exceptions: [
97-
// OSError is the underlying error
98-
// https://api.dart.dev/stable/dart-io/FileSystemException/osError.html
99-
// https://api.dart.dev/stable/dart-io/OSError-class.html
100-
if (osError != null) _sentryExceptionfromOsError(osError),
101-
...?event.exceptions,
102-
],
103-
);
91+
event.exceptions = [
92+
// OSError is the underlying error
93+
// https://api.dart.dev/stable/dart-io/FileSystemException/osError.html
94+
// https://api.dart.dev/stable/dart-io/OSError-class.html
95+
if (osError != null) _sentryExceptionfromOsError(osError),
96+
...?event.exceptions,
97+
];
98+
return event;
10499
}
105100
}
106101

dart/lib/src/feature_flags_integration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class FeatureFlagsIntegration extends Integration<SentryOptions> {
3333
values.add(SentryFeatureFlag(name: name, value: value));
3434
}
3535

36-
final newFlags = flags.copyWith(values: values);
36+
flags.values = values;
3737

38-
await _hub?.scope.setContexts(SentryFeatureFlags.type, newFlags);
38+
await _hub?.scope.setContexts(SentryFeatureFlags.type, flags);
3939
}
4040

4141
@override

0 commit comments

Comments
 (0)