Monitoring Android Apps with Firebase Crashlytics and Performance

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
some Michael France welcome back to the channel in this video we are going to see how you can monitor the crashes and the performance of your Android application using Firebase monitoring system for crash settings and performance monitoring let's get started so here I'm having just a separate project I won't be showing how you can integrate your app with Firebase because we already did that in a previous video I think it was about Firebase Anonymous login and the setup is always the same okay and let's start with digging to the documentation in order to add the setup for crashlytics and performance ones now both Firebase crashlytics and performance monitoring are Services provided by Firefly based by Google so crash sticks will catch any issues crashed into your application and provide cash reporting same thing for performance monitoring it's a service and it will provide some performance issues like HTTP Network time for example startup times some graphic issues and also you can use custom traces in order to measure specific block that will depend on your application and Trust the time there and it will give you these insights both for performance and crochetics for both the Android device the Android version and different metadata in order to start using those we'll have to go to Android here there is this set of dependencies you have to add all right I already add some of that if you go to the project here first of all you'll have to add this type of thing well because you need five rings you have to add Google Play services here you need to add plugin for performance and plugin for crash Matrix you have to do the same here you have to add this plugins here also and now you have to add some differences first of all I added only the Firebase for performance I would have to add the crash latex Also let's go to get started and here check Android and give me that okay that's all sync it and you can start using those well first of all once you do that the application and the service will automatically send reports to the Firebase packet you don't have to add anything else if you go to your activity and for example try to throw an exception by hand illegal exception right once you start it throw it and check your dashboard for Firebase you will see that this one will get raised with which device and so on so this kind of trigger test what our video of course doesn't end here we'll try to see some things you can do first of all any crash that will stop the application will be reported automatically now the way you get access to the service into your code is like following there is this type Fire based crashlytics this object you have to get an instance for that and with that it says you can do many things you can log custom messages you can for example delete and set report because if you don't have the internet connection what this service we do we'll store the reports internally until you have an internet connection to set it there is check for this like this custom logic if you want to send everything and this this record exception usually we do this record exception we did the try catch block sometimes you will catch the bug before crashing or stopping the application but you need to report that to your dashboard so you know this bug happens a lot and you need to fix this exception there is this user ID so basically sometimes you will group The Box based on the user well you can do it based on the device model based on the Android version that's automatically set by Firebase crashletic service but if you want to track the box that depended on the user you can set user ID when you initialize this thing and then when you send your box it will go with this user ID so you know this kind of work happened for that user exactly so you are able to fix that well the way you use this kind of statements inside your application let's say I want to log something usually I saw two main mems first of all a lot of people create like an accession function they will do that following let's name it log and they will do like log like that and you can log and hear any message it can do something like following and you can do basically Firebase cluster text get an instance for that and just lock that message and whenever you are in your application just type here log and you could go maybe this one we'll use this function you can just rename it properly you can have also another one called log exception and just name the exception and you have to record exception let's say you have tried catch here but this track catch doesn't have to be here in the main activity it can be on the repository and the view model on your data sources and everything you can't catch using this log exception and you pass this Exception by default now the the first thing this one for setting the user ID you have to do it only one time let's say when the application first time blocking the user the first time login you'll have to set this kind of keys you can use it and then you shouldn't worry about like this service will save this kind of information or this you have to repeat it every time now this kind of implementation I don't know it's a little bit good when you have to produce a lot of your code with this login exception but the main thing is that if you want to change this kind of logger like log with what with crashlytics to something else like there is multiple services that provide this kind of service you can switch easily here you can delete this and everything will go fine for your next release some other people use another implementation like following you create like an interface called blogger and this logo will have two main methods or for example just one method like World accepts it will take an exception now you have to implement this interface using Firebase crash latex block and that way you can use this Firebase crashlytics like the following and you can log your exception or let me just put here recording session okay and now you can pass this object in your places when you want to do the logger you can basically use dependency injection to inject this kind of object and this kind of provides the same thing but this is more cleaner but the main important thing about this kind of implementation is to enable testing now this is a bit controversial about like should we test login exceptions and logging for example features and something else now that would depend on the business not the the program because the programmer also wants to know what is happening and login exception now there is two type usually two type of logs the one we need by programmers and the other one for the business like the business wants to know that there is crashes at the app so they can fix like this is a business required if it is a business requirement well then you have to test it because it is a business required the book is called growing object oriented pro software by test this is by the London style of test driven development okay it's worth reading now in this book they are telling that there is diagnostic logs which are needed by the programmer you don't have to test them because you will put them and then you will delete them but there is some logs that will remain into the application so this type of log need to be tested the way to test slack is a little bit difficult like how you would do that with Firebase crashlytics the main idea is that you use mocs because this function and this class is pretty simple it's just forwarded you have to mock the logger using some fake logger into the place where you for example the activity you will inject a fake logger and see if the RTV is logging this kind of thing now with this there is also another type of logger you can use like sometimes you want to use logger when doing the development but basically here you can do also log dot for example e or using Timber you don't know if I'm using timber here and that way you can lock the exception for both like normal debugging modes and also for production thing and when you reducing production you have to delete all of this or you can replace that with something specifically development and change it into the production that's the controversial part about whether you should test this kind of logging reporting and so on so that was for the crusher tick spot for the performance monitoring Parts it's just the same you'll have to of course do this kind of Firebase performance there it is you should get against this for that it's always the same and using that you can access many things the main important thing is this new Trace you can trace custom things for example you can like for example in here I will do all create time for example I will create trace for that and I will wait until this completely let's say I will put it here and once completed we only have to start it and stop it you have to stop it here and start it here sorry that way you will have this on create of the main activity there sometimes there is business requirements also for that so you have to test that if the application is measuring exactly this kind of measures so you have to put that in mind but the main idea is that and any other metric the app will collect it by default now keep in mind that this one you can disable and enable this kind of tracing so I think it is here yeah exactly set performance collection enabled let's say in the beginning you will say user you want to collect performance stick you allow that or not so basically you can enable it on that that's the idea for performance monitoring and always try to abstract things a little bit because you don't know whether you'll be using a lot of this Firebase thing or whether you'll be replacing it in the future with another implementation or another service other than Firebase performance monitoring because this kind of statement this one and also the crashlytics report will be a lot in your code like let's say if you have big the code base and let's say this statement is repeated like multiple times to be tedious when we want to change that so always abstract that and provide single Source like that like following and then when you want to replace it when you want to test it you have just substitute this logo with another type of locker now here I mean this project this is a demo project provided by Firebase in order to see the crash settings and everything so they have this application called flooded so here is the report part now you can see the report based on several things like the lights last 90 days for example and you see this crashes there is this automatic tag if you go here to this one you will see on which devices this crash happened for Samsung Huawei and everything you will see also a detailed thing like on fully screen activities you see also the time on which this error happened you see many things all right you see some logs here level start this kind of locks are based from this analytics part it's not from the crashlytics part you can do that also from analytics and there is this kind of keys I don't know some data yeah exactly data about the device and everything they are not using the user ID I think here and basically here you can check the exception on which line everything as I said this is the crash to take dashboard there is another dashboard here which is the performance that first of all you can create metric as we said with custom tracing and you can see here like for example this app start time the app start time is a little bit faster it is good okay so you can come back so you can also select the version of your application here and you can compare the different measures here in the performance you can see some Network requests there is Network request a little bit for this crash.tc for Google API if it's taking two time it is this custom tracking key application background foreground as you can see duration this is the custom trusting and finally there's the screen rendering okay this is also important you will see how your application is the Frozen frames and everything you can go here I think and you can see exactly some detailed dashboard detail things so this is a great way to monitor the performance in our application in order to make it good by the time so that's it so that's it exactly performance and also crashlytics so the main takeaway from this video not only how to use it like this one this is simple thing anyone can do that but how you would abstract it and make it clean in a way that you can use it you can test it and you can replace it in the future if you want that's the main takeaway from that video thanks a lot for watching this video to the end don't forget to subscribe to the channel and see in the next videos
Info
Channel: Charfaoui Younes
Views: 5,738
Rating: undefined out of 5
Keywords: firebase, firebase monitoring, firebase performance monitoring, firebase crashlytics, android, android app development, kotlin, java, google io, performance monitoring, app development
Id: infKu-sxCFQ
Channel Id: undefined
Length: 11min 51sec (711 seconds)
Published: Wed Nov 09 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.