Firebase Crashlytics

Integration

Smartlook can be easily integrated into Crashlytics:

// User URL integration
Smartlook.instance.user.listeners += object : User.Listener {
  override fun onUrlChanged(url: URL) {
		FirebaseCrashlytics.getInstance().setCustomKey("Smartlook user URL", url)
  }
}

// Session URL integration
Smartlook.instance.user.session.listeners += object : Session.Listener {
  override fun onUrlChanged(url: URL) {
		FirebaseCrashlytics.getInstance().setCustomKey("Smartlook session URL", url)
  }
}
// User URL integration
Smartlook.getInstance().getUser().getListeners().add(url -> {
	FirebaseCrashlytics.getInstance().setCustomKey("Smartlook user URL", url);
});

// Session URL integration
Smartlook.getInstance().getUser().getSession().getListeners().add(url -> {
	FirebaseCrashlytics.getInstance().setCustomKey("Smartlook session URL", dashboardSessionUrl);
});
NotificationCenter.default.addObserver(forName: Session.urlDidChangeNotification, object: nil, queue: nil) 
{ notification in
	if let smartlook = notification.object as? Smartlook,
 		 let sessionUrl = smartlook.user.session.url {
       
			Crashlytics.crashlytics().setCustomValue(sessionUrl, forKey: "Smartlook session URL") 	}
 	}
}

NotificationCenter.default.addObserver(forName: User.urlDidChangeNotification, object: nil, queue: nil) 
{ notification in
	if let smartlook = notification.object as? Smartlook {
    let visitorUrl = smartlook.user.url

     Crashlytics.crashlytics().setCustomValue(visitorUrl, forKey: "Smartlook visitor URL")
  }
}
async function sessionUrlChangedCallback(sessionUrl: string) {
    await Promise.all([
      crashlytics().setAttribute('sessionUrl', sessionUrl)
    ]);
}

async function userUrlChangedCallback(userUrl: string) {
    await Promise.all([
      crashlytics().setAttribute('userUrl', userUrl)
    ]);
}

Smartlook.instance.eventListeners.registerUserChangedListener(userUrlChangedCallback);
Smartlook.instance.eventListeners.registerSessionChangedListener(sessionUrlChangedCallback);
class CustomIntegrationListener implements IntegrationListener {
	@override
  void onSessionReady(String? dashboardSessionUrl) {
      FirebaseCrashlytics.instance.setCustomKey("sessionUrl", dashboardSessionUrl);
  }

  @override
  void onVisitorReady(String? dashboardVisitorUrl) {
   FirebaseCrashlytics.instance.setCustomKey("userUrl", dashboardVisitorUrl);
  }
}

//Put to your init state or some place you want to register this
Smartlook.registerIntegrationListener(CustomIntegrationListener());

πŸ“˜

Official documentation

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