@@ -95,16 +95,16 @@ class Codelessly {
95
95
/// when they are triggered.
96
96
final Map <String , CodelesslyFunction > functions = {};
97
97
98
- CodelesslyStatus _status = CodelesslyStatus .empty;
98
+ CStatus _status = CStatus .empty () ;
99
99
100
100
/// Returns the current status of this SDK instance.
101
- CodelesslyStatus get status => _status;
101
+ CStatus get status => _status;
102
102
103
- final StreamController <CodelesslyStatus > _statusStreamController =
104
- StreamController .broadcast ()..add (CodelesslyStatus .empty);
103
+ final StreamController <CStatus > _statusStreamController =
104
+ StreamController .broadcast ()..add (CStatus .empty () );
105
105
106
106
/// Returns a stream of status updates for this SDK instance.
107
- Stream <CodelesslyStatus > get statusStream => _statusStreamController.stream;
107
+ Stream <CStatus > get statusStream => _statusStreamController.stream;
108
108
109
109
LocalStorage get localStorage => dataManager.localStorage;
110
110
@@ -139,7 +139,7 @@ class Codelessly {
139
139
140
140
// If the config is not null, update the status to configured.
141
141
if (_config != null ) {
142
- _updateStatus (CodelesslyStatus .configured);
142
+ _updateStatus (CStatus .configured () );
143
143
}
144
144
}
145
145
@@ -150,7 +150,7 @@ class Codelessly {
150
150
if (completeDispose) {
151
151
_statusStreamController.close ();
152
152
} else {
153
- _status = CodelesslyStatus .empty;
153
+ _status = CStatus .empty () ;
154
154
_statusStreamController.add (_status);
155
155
}
156
156
@@ -178,8 +178,8 @@ class Codelessly {
178
178
_templateDataManager? .invalidate ('Template' );
179
179
_authManager? .invalidate ();
180
180
181
- _config = null ;
182
- _status = CodelesslyStatus .empty;
181
+ _status =
182
+ config == null ? CStatus .empty () : CStatus . configured () ;
183
183
_statusStreamController.add (_status);
184
184
185
185
if (clearCache) {
@@ -207,7 +207,7 @@ class Codelessly {
207
207
208
208
/// Internally updates the status of this instance of the SDK and emits a
209
209
/// status update event to the [statusStream] .
210
- void _updateStatus (CodelesslyStatus status) {
210
+ void _updateStatus (CStatus status) {
211
211
if (_status == status) {
212
212
return ;
213
213
}
@@ -228,7 +228,7 @@ class Codelessly {
228
228
/// [Codelessly] SDK is the global instance rather than a local one, it will
229
229
/// configure and initialize the SDK automatically via its widget's
230
230
/// constructor parameters.
231
- CodelesslyStatus configure ({
231
+ CStatus configure ({
232
232
CodelesslyConfig ? config,
233
233
234
234
// Optional data and functions.
@@ -249,7 +249,7 @@ class Codelessly {
249
249
);
250
250
251
251
assert (
252
- status == CodelesslyStatus .empty,
252
+ status == CStatus .empty () ,
253
253
'The SDK cannot be configured if it is not idle. '
254
254
'Consider calling [Codelessly.dispose] before reconfiguring.' ,
255
255
);
@@ -277,7 +277,7 @@ class Codelessly {
277
277
if (functions != null ) {
278
278
this .functions.addAll (functions);
279
279
}
280
- _updateStatus (CodelesslyStatus .configured);
280
+ _updateStatus (CStatus .configured () );
281
281
return status;
282
282
}
283
283
@@ -315,7 +315,7 @@ class Codelessly {
315
315
if (exception.layoutID != null ) {
316
316
return ;
317
317
}
318
- _updateStatus (CodelesslyStatus .error);
318
+ _updateStatus (CStatus .error () );
319
319
},
320
320
);
321
321
@@ -332,7 +332,7 @@ class Codelessly {
332
332
/// [Codelessly] SDK is the global instance rather than a local one, it will
333
333
/// configure and/or initialize the SDK automatically via its widget's
334
334
/// constructor parameters, if specified.
335
- Future <CodelesslyStatus > initialize ({
335
+ Future <CStatus > initialize ({
336
336
CodelesslyConfig ? config,
337
337
338
338
// Optional data and functions.
@@ -368,7 +368,7 @@ class Codelessly {
368
368
automaticallySendCrashReports: _config! .automaticallySendCrashReports,
369
369
);
370
370
try {
371
- _updateStatus (CodelesslyStatus .configured);
371
+ _updateStatus (CStatus .configured () );
372
372
373
373
// Clean up.
374
374
if (cacheManager != null ) _cacheManager? .dispose ();
@@ -441,12 +441,14 @@ class Codelessly {
441
441
LocalDataRepository (cacheManager: this .cacheManager),
442
442
);
443
443
444
- _updateStatus (CodelesslyStatus .loading);
444
+ _updateStatus (CStatus .loading ( 'initialized_managers' ) );
445
445
446
446
log ('[SDK] [INIT] Initializing cache manager' );
447
447
// The cache manager initializes first to load the local cache.
448
448
await this .cacheManager.init ();
449
449
450
+ _updateStatus (CStatus .loading ('initialized_cache' ));
451
+
450
452
// The auth manager initializes second to look up cached auth data
451
453
// from the cache manager. If no auth data is available, it halts the
452
454
// entire process and awaits to authenticate with the server.
@@ -461,6 +463,8 @@ class Codelessly {
461
463
await this .authManager.init ();
462
464
_config! .publishSource =
463
465
this .authManager.getBestPublishSource (_config! );
466
+
467
+ _updateStatus (CStatus .loading ('initialized_auth' ));
464
468
} else {
465
469
log ('[SDK] [INIT] A slug was provided. Acutely skipping authentication.' );
466
470
}
@@ -497,6 +501,8 @@ class Codelessly {
497
501
}
498
502
break ;
499
503
}
504
+
505
+ _updateStatus (CStatus .loading ('initialized_data_managers' ));
500
506
} else {
501
507
if (! initializeDataManagers) {
502
508
log (
@@ -523,13 +529,14 @@ class Codelessly {
523
529
this .authManager.authData! .projectId,
524
530
);
525
531
});
532
+ _updateStatus (CStatus .loading ('initialized_slug' ));
526
533
}
527
534
528
535
log ('[SDK] [INIT] Codelessly ${_instance == this ? 'global' : 'local' } instance initialization complete.' );
529
536
530
- _updateStatus (CodelesslyStatus .loaded);
537
+ _updateStatus (CStatus .loaded () );
531
538
} catch (error, stacktrace) {
532
- _updateStatus (CodelesslyStatus .error);
539
+ _updateStatus (CStatus .error () );
533
540
CodelesslyErrorHandler .instance.captureException (
534
541
error,
535
542
stacktrace: stacktrace,
0 commit comments