@@ -27,7 +27,7 @@ enum _SendResult { disabled, success, discard, tryAgain }
2727class Aptabase {
2828 Aptabase ._();
2929
30- static const _sdkVersion = "aptabase_flutter@0.4.1 " ;
30+ static const _sdkVersion = "aptabase_flutter@0.4.2 " ;
3131 static const _sessionTimeout = Duration (hours: 1 );
3232
3333 static const Map <String , String > _hosts = {
@@ -39,9 +39,9 @@ class Aptabase {
3939
4040 static final _http = newUniversalHttpClient ();
4141
42- static late final String _appKey;
42+ static String ? _appKey;
43+ static Uri ? _apiUrl;
4344 static late final InitOptions _initOptions;
44- static late final Uri ? _apiUrl;
4545 static var _sessionId = _newSessionId ();
4646 static var _lastTouchTs = DateTime .now ().toUtc ();
4747 static Timer ? _timer;
@@ -187,7 +187,8 @@ class Aptabase {
187187 String eventName, [
188188 Map <String , dynamic >? props,
189189 ]) async {
190- if (_appKey.isEmpty || _apiUrl == null ) {
190+ final appKey = _appKey;
191+ if (_apiUrl == null || appKey == null || appKey.isEmpty) {
191192 _logInfo ("Tracking is disabled!" );
192193
193194 return ;
@@ -211,7 +212,8 @@ class Aptabase {
211212 static Future <_SendResult > _send (List <String > events) async {
212213 try {
213214 final apiUrl = _apiUrl;
214- if (apiUrl == null ) {
215+ final appKey = _appKey;
216+ if (apiUrl == null || appKey == null ) {
215217 _logInfo ("Tracking is disabled!" );
216218
217219 return _SendResult .disabled;
@@ -221,7 +223,7 @@ class Aptabase {
221223
222224 request.followRedirects = true ;
223225 request.headers
224- ..set ("App-Key" , _appKey )
226+ ..set ("App-Key" , appKey )
225227 ..set (
226228 HttpHeaders .contentTypeHeader,
227229 "application/json; charset=UTF-8" ,
0 commit comments