Skip to main content

Lifecycle & status

Bugsee works in the background of your app. When you need to know what it is doing — whether it is recording yet, or when a report is shown or uploaded — use the SDK status and the lifecycle events described here. Stopping and relaunching are covered in Configuration.

Setting the delegate​

Status changes and lifecycle events are delivered to your BugseeDelegate. Every delegate method is optional: implement the ones you need, and set your object as the delegate. Bugsee holds the delegate weakly, so keep a strong reference to it yourself.

In Swift, derive the delegate from NSObject, so you do not have to implement the NSObjectProtocol requirements yourself.

@interface MyBugseeDelegate : NSObject <BugseeDelegate>
@end

// ...

[Bugsee sharedInstance].delegate = self.bugseeDelegate;

You can set the delegate before launchWithToken:.

SDK status​

launchWithToken: returns before Bugsee is recording. status tells you where the SDK is:

ValueMeaning
BugseeStatusStoppedNot launched, a launch that waits for the app to become active, or fully stopped. Calls that submit data are ignored.
BugseeStatusLaunchingThe SDK is starting capture. Reports can be filed, but logs, events, traces, breadcrumbs and network events may not be recorded yet.
BugseeStatusLaunchedFully running: capture is recording.
BugseeStatusStoppingstop: is in progress.

The launched property is YES only while the status is Launched. Prefer status, or the status callback below, for launch sequencing.

When the launch waits for the app to become active​

When launchWithToken: is called while the app is in the background state, or before UIApplication exists, Bugsee installs its crash handler right away and starts everything else when the app becomes active. That is the case for a launch from application:didFinishLaunchingWithOptions: in a scene-based app, and for a launch from a SwiftUI App initializer. Until the app becomes active:

  • the status stays Stopped, and the first transition is to Launching at that moment;
  • calls that submit data (log, event, trace, logError:, logException, upload…, notify) are ignored;
  • startTransaction and startSpan return objects that record nothing;
  • BugseeOptionCaptureNetworkOnLaunch has no effect, so requests started in that window are not captured.

Once the status is Launched, all of these work as usual.

if ([Bugsee sharedInstance].status == BugseeStatusLaunched) {
// Bugsee is recording
}

Observing status changes​

bugseeDidChangeStatus: (Swift bugsee(didChangeStatus:)) is called on the main thread on every status transition, including the Launching and Stopping steps that no lifecycle event covers.

- (void)bugseeDidChangeStatus:(BugseeStatus)status {
if (status == BugseeStatusLaunched) {
// Bugsee is recording
}
}

The launch completion​

launchWithToken:options:started: (Swift launch(token:options:started:)) calls its block once:

  • For a launch that starts right away, it is called once capture is up, with YES, or with NO if the launch failed or a stop: cancelled it.
  • For a launch that waits for the app to become active, it is called at once with YES: the launch was accepted, but recording has not begun.
  • NO also means the launch was refused, for example because the app token is empty or the SDK is stopping.
  • A launch called while Bugsee is already running reports YES, and its options are ignored.

To know when recording has begun, observe the status.

[Bugsee launchWithToken:@"<your_app_token>"
options:nil
started:^(BOOL success) {
NSLog(@"Bugsee launch accepted: %d", success);
}];

Lifecycle events​

Lifecycle events report discrete moments: a launch, a report shown or uploaded, a blackout started. Implement bugseeLifecycleEvent: (Swift bugsee(lifecycleEvent:)) to receive them. They are delivered on the main queue.

- (void)bugseeLifecycleEvent:(BugseeLifecycleEventType)eventType {
if (eventType == BugseeLifecycleEventRelaunchedAfterCrash) {
// The previous run crashed
}
}

Lifecycle events and status changes are delivered separately and are not ordered against each other: with a cross-platform SDK in the app, a lifecycle event can arrive after a later status change.

Available lifecycle events​

EventDispatched when
BugseeLifecycleEventLaunchedBugsee was launched.
BugseeLifecycleEventStoppedBugsee was stopped.
BugseeLifecycleEventRelaunchedAfterCrashBugsee was launched and found a crash left by its crash handler in an earlier run. Dispatched at most once per process. Exit reports, including the watchdog and memory-limit reports of the Crash Report Extension, do not dispatch it.
BugseeLifecycleEventBeforeReportShownBefore the report dialog is shown.
BugseeLifecycleEventAfterReportShownAfter the report dialog is shown.
BugseeLifecycleEventBeforeReportAssembledBefore a bug, crash or error report starts being assembled.
BugseeLifecycleEventAfterReportAssembledAfter a report has been assembled.
BugseeLifecycleEventReportAssemblyFailedAssembling a report ran out of attempts in this process. Assembly that is interrupted instead, because the process ends or Bugsee is stopped, resumes on a later launch and does not dispatch this event.
BugseeLifecycleEventBeforeReportUploadedA report is about to be uploaded.
BugseeLifecycleEventAfterReportUploadedA report was uploaded.
BugseeLifecycleEventReportUploadFailedWithFutureRetryA report upload failed and will be retried later.
BugseeLifecycleEventReportUploadFailedRepeated upload attempts failed. No more attempts are made, and the report is not uploaded.
BugseeLifecycleEventBlackoutStartedA blackout began (startBlackout). A relaunch that keeps a blackout dispatches BlackoutEnded and then BlackoutStarted.
BugseeLifecycleEventBlackoutEndedA blackout ended (endBlackout, or stop:).
BugseeLifecycleEventBeforeFeedbackShownReserved for the feedback screen; not dispatched yet.
BugseeLifecycleEventAfterFeedbackShownReserved for the feedback screen; not dispatched yet.
note

7.x has no pause and resume, so the 6.x BugseeLifecycleEventStarted, BugseeLifecycleEventPaused and BugseeLifecycleEventResumed events are gone, and the raw values of the remaining events changed. Compare against the constants, never against numbers. See Migrating from 6.x to 7.x.

Found an issue, typo, or wrong statement on this page? Report it now →