# Testing debug analytics - Tues 6th Oct, 2020 Continued to add analytics and crashylitics fuctionality to C+. The syntax is easy from [React Native Firebase](https://rnfirebase.io/) - a logging call might look like this: ```typescript= analytics().logEvent('comment_sent') ``` Screen tracking was also easy. I primarily used [React Navigation's guide](https://reactnavigation.org/docs/screen-tracking/), and typed the refs thusly: ```typescript= const routeNameRef = useRef<string | undefined>(undefined) const navigationRef = useRef<NavigationContainerRef>(null) // `NavigationContainerRef` is provided by React Navigation ``` Crashlytics is also straightforward. You can log a string as I'm doing in my Apollo Client `errorLink`: ```typescript= export const errorLink = onError(({ graphQLErrors, networkError }) => { if (graphQLErrors) { graphQLErrors.map(({ message, locations, path }) => { const graphQLError = `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}` crashlytics().log(graphQLError) console.log(graphQLError) }) } if (networkError) { const netError = `[Network error]: ${networkError}` crashlytics().log(netError) console.log(netError) } }) ``` Or you can [send entire stack traces](https://rnfirebase.io/crashlytics/usage#error-reports) (useful for try/catch blocks.) ### Debugging (analytics) events I had an issue viewing debug analytic events in the Firebase console. Google [has a guide](https://firebase.google.com/docs/analytics/debugview) to enable them. It worked straightaway on Android, but on iOS I found adding the `-FIRDebugEnabled` in Xcode to be an IDE only setting. This meant I saw the logs when I built from Xcode itself, but this flag was not passed when running the `react-native run ___` Node script. Short of hacking the Node script to be able to pass this flag, or doing a change in the Swift code to switch Firebase based on debug or release build, ie: ```csharp= func sourceURL(for bridge: RCTBridge!) -> URL! { #if DEBUG return RCTBundleURLProvider.sharedSettings()?.jsBundleURL(forBundleRoot: "index", fallbackResource: nil) #else return Bundle.main.url(forResource: "main", withExtension: "jsbundle") #endif } ``` I found no way to see debug events without building through Xcode directly. It's not a big deal, but just watch out for it. ###### tags: `programmingjournal` `2020` `C+` `crashylitics` `analytics` `firebase` `firdebugenabled` `xcode` `iOS`