Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bc65a42
Update dependencies + fix tests
ueman Feb 10, 2021
c6b35e0
Remove unused code
ueman Feb 10, 2021
4dc480b
Migration Hints
ueman Feb 10, 2021
88eb3c6
add more type annotations + make api more nullsafety friendly
ueman Feb 10, 2021
ff296d0
null safety migration
ueman Feb 10, 2021
35b663d
Rewritten test + fixed linter warnings
ueman Feb 13, 2021
713b05b
Fixed more test which were broken
ueman Feb 13, 2021
c24a96d
Fix tests
ueman Feb 14, 2021
d722a8c
Don't build CI on Dart stable
ueman Feb 14, 2021
437fc1c
Fixed test + some more null safety refactorings
ueman Feb 14, 2021
9133b3b
build flutter only on beta
ueman Feb 15, 2021
b15c136
fix example
ueman Feb 15, 2021
3d4a513
make sure the Flutter Sentry SDK compiles
ueman Feb 15, 2021
d594922
DebugImage.type is required -> non-nullable
ueman Feb 15, 2021
42a619c
add changelog
ueman Feb 15, 2021
5201270
Update dart/lib/src/sentry_options.dart
ueman Feb 17, 2021
a41c4a7
Merge remote-tracking branch 'upstream/main' into feature/nullsafety
ueman Feb 20, 2021
5276086
Apply improvements and suggestions from PR review
ueman Feb 20, 2021
39c6a2a
Use stable null safe release in Flutter
ueman Feb 20, 2021
9a7328b
Some smaller fixes
ueman Feb 20, 2021
5c0ddbf
use correct dart sdk
ueman Feb 20, 2021
95508d6
Use nullable lists/maps :(
ueman Feb 20, 2021
3638f43
fix
ueman Feb 20, 2021
44a8206
Update dart/lib/src/scope.dart
ueman Feb 22, 2021
3b2b6dd
Add PR feedback
ueman Feb 22, 2021
699b31a
Merge remote-tracking branch 'origin/feature/nullsafety' into feature…
ueman Feb 22, 2021
7635d4e
fix typo
ueman Feb 22, 2021
006fb0c
Merge remote-tracking branch 'upstream/feat/null-safety' into feature…
ueman Feb 22, 2021
1703333
fix problems caused by merge
ueman Feb 22, 2021
7ea8a89
PR Feedback
ueman Feb 23, 2021
1aacadb
Make SentryLevel nullable again
ueman Feb 23, 2021
7308de7
Remove default values
ueman Feb 23, 2021
83bc406
PR Feedback
ueman Feb 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
null safety migration
  • Loading branch information
ueman committed Feb 10, 2021
commit ff296d080ab4f775d6c368db3e8b1419ce5166e0
2 changes: 1 addition & 1 deletion dart/lib/src/http_client/sentry_http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import '../../sentry.dart';
// For example with Darts Stopwatch:
// https://api.dart.dev/stable/2.10.4/dart-core/Stopwatch-class.html
class SentryHttpClient extends BaseClient {
SentryHttpClient({Client/*?*/ client, Hub/*?*/ hub})
SentryHttpClient({Client? client, Hub? hub})
: _hub = hub ?? HubAdapter(),
_client = client ?? Client();

Expand Down
17 changes: 8 additions & 9 deletions dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ class Hub {
final ListQueue<_StackItem> _stack = ListQueue();

/// if stack is empty, it throws IterableElementError.noElement()
_StackItem _peek() => _stack.isNotEmpty ? _stack.first : null;
_StackItem? _peek() => _stack.isNotEmpty ? _stack.first : null;

final SentryOptions _options;

factory Hub(SentryOptions options) {
assert(options != null, 'SentryOptions is required.');
_validateOptions(options);

return Hub._(options);
Expand All @@ -36,7 +35,7 @@ class Hub {
}

static void _validateOptions(SentryOptions options) {
if (options.dsn?.isNotEmpty != true) {
if (options.dsn.isEmpty) {
throw ArgumentError('DSN is required.');
}
}
Expand All @@ -53,7 +52,7 @@ class Hub {

/// Captures the event.
Future<SentryId> captureEvent(
SentryEvent /*?*/ event, {
SentryEvent? event, {
dynamic stackTrace,
dynamic hint,
}) async {
Expand Down Expand Up @@ -146,10 +145,10 @@ class Hub {

/// Captures the message.
Future<SentryId> captureMessage(
String /*?*/ message, {
SentryLevel level = SentryLevel.info,
String template,
List<dynamic> params,
String? message, {
SentryLevel? level = SentryLevel.info,
String? template,
List<dynamic>? params,
dynamic hint,
}) async {
var sentryId = SentryId.empty();
Expand Down Expand Up @@ -195,7 +194,7 @@ class Hub {
}

/// Adds a breacrumb to the current Scope
void addBreadcrumb(Breadcrumb /*?*/ crumb, {dynamic hint}) {
void addBreadcrumb(Breadcrumb? crumb, {dynamic hint}) {
if (!_isEnabled) {
_options.logger(
SentryLevel.warning,
Expand Down
12 changes: 6 additions & 6 deletions dart/lib/src/hub_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class HubAdapter implements Hub {
}

@override
void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) =>
void addBreadcrumb(Breadcrumb? crumb, {dynamic hint}) =>
Sentry.addBreadcrumb(crumb, hint: hint);

@override
void bindClient(SentryClient client) => Sentry.bindClient(client);

@override
Future<SentryId> captureEvent(
SentryEvent event, {
SentryEvent? event, {
dynamic stackTrace,
dynamic hint,
}) =>
Expand All @@ -48,10 +48,10 @@ class HubAdapter implements Hub {

@override
Future<SentryId> captureMessage(
String message, {
SentryLevel level = SentryLevel.info,
String template,
List params,
String? message, {
SentryLevel? level = SentryLevel.info,
String? template,
List? params,
dynamic hint,
}) =>
Sentry.captureMessage(
Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/isolate_error_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'sentry_options.dart';
import 'throwable_mechanism.dart';

class IsolateErrorIntegration extends Integration {
RawReceivePort _receivePort;
late RawReceivePort _receivePort;

@override
FutureOr<void> call(Hub hub, SentryOptions options) async {
Expand Down
20 changes: 10 additions & 10 deletions dart/lib/src/noop_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,38 @@ class NoOpClient implements Client {
@override
Future<Response> delete(
Uri url, {
Map<String, String> headers,
Object body,
Encoding encoding,
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_response;

@override
Future<Response> get(url, {Map<String, String> headers}) => _response;
Future<Response> get(url, {Map<String, String>? headers}) => _response;

@override
Future<Response> head(url, {Map<String, String> headers}) => _response;
Future<Response> head(url, {Map<String, String>? headers}) => _response;

@override
Future<Response> patch(url,
{Map<String, String> headers, body, Encoding encoding}) =>
{Map<String, String>? headers, body, Encoding? encoding}) =>
_response;

@override
Future<Response> post(url,
{Map<String, String> headers, body, Encoding encoding}) =>
{Map<String, String>? headers, body, Encoding? encoding}) =>
_response;

@override
Future<Response> put(url,
{Map<String, String> headers, body, Encoding encoding}) =>
{Map<String, String>? headers, body, Encoding? encoding}) =>
_response;

@override
Future<String> read(url, {Map<String, String> headers}) => _string;
Future<String> read(url, {Map<String, String>? headers}) => _string;

@override
Future<Uint8List> readBytes(url, {Map<String, String> headers}) => _intList;
Future<Uint8List> readBytes(url, {Map<String, String>? headers}) => _intList;

@override
Future<StreamedResponse> send(BaseRequest request) => _streamedResponse;
Expand Down
12 changes: 6 additions & 6 deletions dart/lib/src/noop_hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NoOpHub implements Hub {

@override
Future<SentryId> captureEvent(
SentryEvent event, {
SentryEvent? event, {
dynamic stackTrace,
dynamic hint,
}) =>
Expand All @@ -34,10 +34,10 @@ class NoOpHub implements Hub {

@override
Future<SentryId> captureMessage(
String message, {
SentryLevel level = SentryLevel.info,
String template,
List params,
String? message, {
SentryLevel? level = SentryLevel.info,
String? template,
List? params,
dynamic hint,
}) =>
Future.value(SentryId.empty());
Expand All @@ -58,5 +58,5 @@ class NoOpHub implements Hub {
SentryId get lastEventId => SentryId.empty();

@override
void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) {}
void addBreadcrumb(Breadcrumb? crumb, {dynamic hint}) {}
}
14 changes: 7 additions & 7 deletions dart/lib/src/noop_sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class NoOpSentryClient implements SentryClient {
Future<SentryId> captureEvent(
SentryEvent event, {
dynamic stackTrace,
Scope scope,
Scope? scope,
dynamic hint,
}) =>
Future.value(SentryId.empty());
Expand All @@ -26,18 +26,18 @@ class NoOpSentryClient implements SentryClient {
Future<SentryId> captureException(
dynamic exception, {
dynamic stackTrace,
Scope scope,
Scope? scope,
dynamic hint,
}) =>
Future.value(SentryId.empty());

@override
Future<SentryId> captureMessage(
String message, {
SentryLevel level = SentryLevel.info,
String template,
List<dynamic> params,
Scope scope,
String? message, {
SentryLevel? level = SentryLevel.info,
String? template,
List<dynamic>? params,
Scope? scope,
dynamic hint,
}) =>
Future.value(SentryId.empty());
Expand Down
6 changes: 3 additions & 3 deletions dart/lib/src/platform_checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ class PlatformChecker {
const PlatformChecker();

/// Check if running in release/production environment
bool/*!*/ isReleaseMode() {
bool isReleaseMode() {
return const bool.fromEnvironment('dart.vm.product', defaultValue: false);
}

/// Check if running in debug environment
bool/*!*/ isDebugMode() {
bool isDebugMode() {
return !isReleaseMode() && !isProfileMode();
}

/// Check if running in profile environment
bool/*!*/ isProfileMode() {
bool isProfileMode() {
return const bool.fromEnvironment('dart.vm.profile', defaultValue: false);
}
}
32 changes: 16 additions & 16 deletions dart/lib/src/protocol/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@ class App {
);

/// Human readable application name, as it appears on the platform.
final String name;
final String? name;

/// Human readable application version, as it appears on the platform.
final String version;
final String? version;

/// Version-independent application identifier, often a dotted bundle ID.
final String identifier;
final String? identifier;

/// Internal build identifier, as it appears on the platform.
final String build;
final String? build;

/// String identifying the kind of build, e.g. `testflight`.
final String buildType;
final String? buildType;

/// When the application was started by the user.
final DateTime startTime;
final DateTime? startTime;

/// Application specific device identifier.
final String deviceAppHash;
final String? deviceAppHash;

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
final json = <String, String>{};
final json = <String, String?>{};

if (name != null) {
json['app_name'] = name;
Expand All @@ -76,7 +76,7 @@ class App {
}

if (startTime != null) {
json['app_start_time'] = startTime.toIso8601String();
json['app_start_time'] = startTime!.toIso8601String();
}

if (deviceAppHash != null) {
Expand All @@ -97,13 +97,13 @@ class App {
);

App copyWith({
String name,
String version,
String identifier,
String build,
String buildType,
DateTime startTime,
String deviceAppHash,
String? name,
String? version,
String? identifier,
String? build,
String? buildType,
DateTime? startTime,
String? deviceAppHash,
}) =>
App(
name: name ?? this.name,
Expand Down
24 changes: 12 additions & 12 deletions dart/lib/src/protocol/breadcrumb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Breadcrumb {
/// Creates a breadcrumb that can be attached to an [Event].
Breadcrumb({
this.message,
DateTime timestamp,
DateTime? timestamp,
this.category,
this.data,
this.level = SentryLevel.info,
Expand All @@ -34,12 +34,12 @@ class Breadcrumb {
/// Describes the breadcrumb.
///
/// This field is optional and may be set to null.
final String message;
final String? message;

/// A dot-separated string describing the source of the breadcrumb, e.g. "ui.click".
///
/// This field is optional and may be set to null.
final String category;
final String? category;

/// Data associated with the breadcrumb.
///
Expand All @@ -50,7 +50,7 @@ class Breadcrumb {
/// See also:
///
/// * https://docs.sentry.io/development/sdk-dev/event-payloads/breadcrumbs/#breadcrumb-types
final Map<String, dynamic> data;
final Map<String, dynamic>? data;

/// Severity of the breadcrumb.
///
Expand All @@ -66,7 +66,7 @@ class Breadcrumb {
/// See also:
///
/// * https://docs.sentry.io/development/sdk-dev/event-payloads/breadcrumbs/#breadcrumb-types
final String type;
final String? type;

/// The time the breadcrumb was recorded.
///
Expand All @@ -87,7 +87,7 @@ class Breadcrumb {
if (category != null) {
json['category'] = category;
}
if (data != null && data.isNotEmpty) {
if (data != null && data!.isNotEmpty) {
json['data'] = data;
}
if (level != null) {
Expand All @@ -100,12 +100,12 @@ class Breadcrumb {
}

Breadcrumb copyWith({
String message,
String category,
Map<String, dynamic> data,
SentryLevel level,
String type,
DateTime timestamp,
String? message,
String? category,
Map<String, dynamic>? data,
SentryLevel? level,
String? type,
DateTime? timestamp,
}) =>
Breadcrumb(
message: message ?? this.message,
Expand Down
Loading