Firebase Crashlytics

Automatic integration

Smartlook can be auto-integrated into you project’s Crashlytics simply by calling:

var integrations = Array<Smartlook.Integration>()
integrations.append(Smartlook.FirebaseAnalyticsIntegration(integrationWith: Firebase.Analytics.self))
integrations.append(Smartlook.FirebaseCrashlyticsIntegration(integrationWith: Firebase.Crashlytics.crashlytics()))

let smartlookConfiguration = Smartlook.Configuration.configuration(key: "YOUR_SMARTLOOK_API_KEY")
smartlookConfiguration.enableIntegrations = integrations
    
Smartlook.setupAndStartRecording(configuration: smartlookConfiguration)
[FIRApp configure];

NSMutableArray<SLIntegration *> *smartlookIntegrations = [NSMutableArray new];
[smartlookIntegrations addObject:[[SLFirebaseAnalyticsIntegration alloc] initIntegrationWith:[FIRAnalytics class]]];
[smartlookIntegrations addObject:[[SLFirebaseCrashlyticsIntegration alloc] initIntegrationWith:[FIRCrashlytics crashlytics]]];

[Smartlook setupAndStartRecordingWithConfiguration:configuration];

Then in the Crashlytics dashboard, there should be a new Smartlook session URL key-value pair with a link to your Smartlook dashboard. Once opened, you can directly play the recording just before the crash occurred.

1244

Manual integration

Smartlook can be easily integrated into Crashlytics using Notifications:

NotificationCenter.default.addObserver(forName: Smartlook.dashboardSessionURLChanged, object: nil, queue: nil) { (note) in
  if let currentSessionUrl = Smartlook.getDashboardSessionURL(withCurrentTimestamp: false) {
        Crashlytics.crashlytics().setCustomValue(currentSessionUrl, forKey: "Smartlook session URL")
  }
}

NotificationCenter.default.addObserver(forName: Smartlook.dashboardVisitorURLChanged, object: nil, queue: nil) { (note) in
  if let currentVisitorUrl = Smartlook.getDashboardVisitorURL() {
    Crashlytics.crashlytics().setCustomValue(currentVisitorUrl, forKey: "Smartlook visitor URL")
  }
}
[[NSNotificationCenter defaultCenter] addObserverForName:SLDashboardSessionURLChangedNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
    NSURL *currentSessionURL = [Smartlook getDashboardSessionURLWithCurrentTimestamp:NO];
    if (currentSessionURL != nil) {
        [[FIRCrashlytics crashlytics] setCustomValue:currentSessionURL forKey:@"session_url"];
    }
}];

[[NSNotificationCenter defaultCenter] addObserverForName:SLDashboardVisitorURLChangedNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
    NSURL *currentVisitorURL = [Smartlook getDashboardVisitorURL];
    if (currentVisitorURL != nil) {
        [[FIRCrashlytics crashlytics] setCustomValue:currentVisitorURL forKey:@"smartlook_visitor_url"];
    }
}];

Full Firebase Crashlytics documentation can be found on the official website.