import firebase from 'react-native-firebase' ; class AnalyticsService { public setScreen ( screen ) { console . info ( `[Analytics] Set current screen: ${ screen }` ) ; firebase . analytics ( ) . setCurrentScreen ( screen , screen ) ; } public logEvent ( event , params ? ) { console . info ( `[Analytics] ${ event }${ params ? ` with params: ${ JSON . stringify ( params ) }` : '' }` ) ; firebase . analytics ( ) . logEvent ( event , params ) ; } public logError ( error ) { const { uid = '' } = firebase . auth ( ) . currentUser || { } ; firebase . crashlytics ( ) . setUserIdentifier ( uid ) ; firebase . crashlytics ( ) . setStringValue ( 'stack' , `${ error . stack }` ) ; firebase . crashlytics ( ) . log ( `JS Error: ${ error . message }` ) ; } } export default new AnalyticsService ( ) ;