@@ -326,12 +326,6 @@ - (FBLPromise *)deleteUnsentReports {
326
326
return [FBLPromise resolvedWith: @NO ];
327
327
}
328
328
329
- if (![self .settings crashReportingEnabled ]) {
330
- FIRCLSInfoLog (@" Reporting is disabled" );
331
- [_fileManager removeContentsOfAllPaths ];
332
- return [FBLPromise resolvedWith: @NO ];
333
- }
334
-
335
329
if (![_fileManager createReportDirectories ]) {
336
330
return [FBLPromise resolvedWith: @NO ];
337
331
}
@@ -364,11 +358,13 @@ - (FBLPromise *)deleteUnsentReports {
364
358
FIRCLSDebugLog (@" Automatic data collection is enabled." );
365
359
FIRCLSDebugLog (@" Unsent reports will be uploaded at startup" );
366
360
FIRCLSDataCollectionToken *dataCollectionToken = [FIRCLSDataCollectionToken validToken ];
367
- [self startNetworkRequestsWithToken: dataCollectionToken
368
- preexistingReportPaths: preexistingReportPaths
369
- waitForSettingsRequest: NO
370
- blockingSend: launchFailure
371
- report: report];
361
+
362
+ [self beginSettingsAndOnboardingWithToken: dataCollectionToken waitForSettingsRequest: NO ];
363
+
364
+ [self beginReportUploadsWithToken: dataCollectionToken
365
+ preexistingReportPaths: preexistingReportPaths
366
+ blockingSend: launchFailure
367
+ report: report];
372
368
373
369
// If data collection is enabled, the SDK will not notify the user
374
370
// when unsent reports are available, or respect Send / DeleteUnsentReports
@@ -401,16 +397,17 @@ - (FBLPromise *)deleteUnsentReports {
401
397
BOOL waitForSetting =
402
398
!self.settings .shouldUseNewReportEndpoint && !self.settings .orgID ;
403
399
404
- [self startNetworkRequestsWithToken: dataCollectionToken
405
- preexistingReportPaths: preexistingReportPaths
406
- waitForSettingsRequest: waitForSetting
407
- blockingSend: NO
408
- report: report];
400
+ [self beginSettingsAndOnboardingWithToken: dataCollectionToken
401
+ waitForSettingsRequest: waitForSetting];
402
+
403
+ [self beginReportUploadsWithToken: dataCollectionToken
404
+ preexistingReportPaths: preexistingReportPaths
405
+ blockingSend: NO
406
+ report: report];
409
407
410
408
} else if (action == FIRCLSReportActionDelete) {
411
409
FIRCLSDebugLog (@" Deleting unsent reports." );
412
- [self removeExistingReportPaths: preexistingReportPaths];
413
- [self removeContentsInOtherReportingDirectories ];
410
+ [self deleteUnsentReportsWithPreexisting: preexistingReportPaths];
414
411
} else {
415
412
FIRCLSErrorLog (@" Unknown report action: %d " , action);
416
413
}
@@ -456,11 +453,8 @@ - (void)checkAndRotateInstallUUIDIfNeededWithReport:(FIRCLSInternalReport *)repo
456
453
}];
457
454
}
458
455
459
- - (void )startNetworkRequestsWithToken : (FIRCLSDataCollectionToken *)token
460
- preexistingReportPaths : (NSArray *)preexistingReportPaths
461
- waitForSettingsRequest : (BOOL )waitForSettings
462
- blockingSend : (BOOL )blockingSend
463
- report : (FIRCLSInternalReport *)report {
456
+ - (void )beginSettingsAndOnboardingWithToken : (FIRCLSDataCollectionToken *)token
457
+ waitForSettingsRequest : (BOOL )waitForSettings {
464
458
if (self.settings .isCacheExpired ) {
465
459
// This method can be called more than once if the user calls
466
460
// SendUnsentReports again, so don't repeat the settings fetch
@@ -471,11 +465,22 @@ - (void)startNetworkRequestsWithToken:(FIRCLSDataCollectionToken *)token
471
465
waitForCompletion: waitForSettings];
472
466
});
473
467
}
468
+ }
474
469
475
- [self processExistingReportPaths: preexistingReportPaths
476
- dataCollectionToken: token
477
- asUrgent: blockingSend];
478
- [self handleContentsInOtherReportingDirectoriesWithToken: token];
470
+ - (void )beginReportUploadsWithToken : (FIRCLSDataCollectionToken *)token
471
+ preexistingReportPaths : (NSArray *)preexistingReportPaths
472
+ blockingSend : (BOOL )blockingSend
473
+ report : (FIRCLSInternalReport *)report {
474
+ if (self.settings .collectReportsEnabled ) {
475
+ [self processExistingReportPaths: preexistingReportPaths
476
+ dataCollectionToken: token
477
+ asUrgent: blockingSend];
478
+ [self handleContentsInOtherReportingDirectoriesWithToken: token];
479
+
480
+ } else {
481
+ FIRCLSInfoLog (@" Collect crash reports is disabled" );
482
+ [self deleteUnsentReportsWithPreexisting: preexistingReportPaths];
483
+ }
479
484
}
480
485
481
486
- (BOOL )startCrashReporterWithProfilingMark : (FIRCLSProfileMark)mark
@@ -550,14 +555,6 @@ - (FIRCLSInternalReport *)setupCurrentReport:(NSString *)executionIdentifier {
550
555
executionIdentifier: executionIdentifier];
551
556
}
552
557
553
- - (void )removeExistingReportPaths : (NSArray *)reportPaths {
554
- [self .operationQueue addOperationWithBlock: ^{
555
- for (NSString *path in reportPaths) {
556
- [self .fileManager removeItemAtPath: path];
557
- }
558
- }];
559
- }
560
-
561
558
- (int )countSubmittableAndDeleteUnsubmittableReportPaths : (NSArray *)reportPaths {
562
559
int count = 0 ;
563
560
for (NSString *path in reportPaths) {
@@ -621,11 +618,11 @@ - (void)submitReport:(FIRCLSInternalReport *)report
621
618
[self didSubmitReport ];
622
619
}
623
620
624
- - (void )removeReport : (FIRCLSInternalReport *)report {
625
- [_fileManager removeItemAtPath: report.path];
626
- }
621
+ // This is the side-effect of calling deleteUnsentReports, or collect_reports setting
622
+ // being false
623
+ - (void )deleteUnsentReportsWithPreexisting : (NSArray *)preexistingReportPaths {
624
+ [self removeExistingReportPaths: preexistingReportPaths];
627
625
628
- - (void )removeContentsInOtherReportingDirectories {
629
626
[self removeExistingReportPaths: self .fileManager.processingPathContents];
630
627
if (self.settings .shouldUseNewReportEndpoint ) {
631
628
[self removeExistingReportPaths: self .fileManager.preparedPathContents];
@@ -634,6 +631,14 @@ - (void)removeContentsInOtherReportingDirectories {
634
631
}
635
632
}
636
633
634
+ - (void )removeExistingReportPaths : (NSArray *)reportPaths {
635
+ [self .operationQueue addOperationWithBlock: ^{
636
+ for (NSString *path in reportPaths) {
637
+ [self .fileManager removeItemAtPath: path];
638
+ }
639
+ }];
640
+ }
641
+
637
642
- (void )handleContentsInOtherReportingDirectoriesWithToken : (FIRCLSDataCollectionToken *)token {
638
643
[self handleExistingFilesInProcessingWithToken: token];
639
644
[self handleExistingFilesInPreparedWithToken: token];
0 commit comments