diff --git a/lib/aptabase_flutter.dart b/lib/aptabase_flutter.dart index 795ae36..380007d 100644 --- a/lib/aptabase_flutter.dart +++ b/lib/aptabase_flutter.dart @@ -27,7 +27,7 @@ enum _SendResult { disabled, success, discard, tryAgain } class Aptabase { Aptabase._(); - static const _sdkVersion = "aptabase_flutter@0.4.1"; + static const _sdkVersion = "aptabase_flutter@0.4.2"; static const _sessionTimeout = Duration(hours: 1); static const Map _hosts = { @@ -39,9 +39,9 @@ class Aptabase { static final _http = newUniversalHttpClient(); - static late final String _appKey; + static String? _appKey; + static Uri? _apiUrl; static late final InitOptions _initOptions; - static late final Uri? _apiUrl; static var _sessionId = _newSessionId(); static var _lastTouchTs = DateTime.now().toUtc(); static Timer? _timer; @@ -187,7 +187,8 @@ class Aptabase { String eventName, [ Map? props, ]) async { - if (_appKey.isEmpty || _apiUrl == null) { + final appKey = _appKey; + if (_apiUrl == null || appKey == null || appKey.isEmpty) { _logInfo("Tracking is disabled!"); return; @@ -211,7 +212,8 @@ class Aptabase { static Future<_SendResult> _send(List events) async { try { final apiUrl = _apiUrl; - if (apiUrl == null) { + final appKey = _appKey; + if (apiUrl == null || appKey == null) { _logInfo("Tracking is disabled!"); return _SendResult.disabled; @@ -221,7 +223,7 @@ class Aptabase { request.followRedirects = true; request.headers - ..set("App-Key", _appKey) + ..set("App-Key", appKey) ..set( HttpHeaders.contentTypeHeader, "application/json; charset=UTF-8", diff --git a/pubspec.yaml b/pubspec.yaml index 895ee98..8d15b44 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: aptabase_flutter description: "Flutter SDK for Aptabase: Open Source Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps" -version: 0.4.1 +version: 0.4.2 homepage: https://aptabase.com repository: https://github.com/aptabase/aptabase_flutter issue_tracker: https://github.com/aptabase/aptabase_flutter/issues @@ -12,12 +12,12 @@ environment: dependencies: flutter: sdk: flutter - package_info_plus: ^8.0.0 - device_info_plus: ^10.1.0 - universal_io: ^2.2.2 - shared_preferences: ^2.3.3 + package_info_plus: any + device_info_plus: any + universal_io: any + shared_preferences: any dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^4.0.0 + flutter_lints: ^6.0.0