From Clever Tap

Using multiple app analytics tools in an iOS app — Ghost Crashes 👻💥

Salmaan Ahmed
Swift2Go
Published in
4 min readSep 30, 2020

--

We are Hypercare! ❤️

At Hypercare we built an amazing product, but that wasn’t all. Because now is the time for optimizing your app and monitoring the behavior of your app users.

With over 2.7 billion smartphone users and over 4 million apps worldwide, competition is getting fierce. In order to be successful, we have to stay sharp and offer a good mobile app experience to our customers. But how can they know if they’re on the right track? More specifically, Enter mobile app analytics tools…

What analytics do we use? 📈

Mixpanel

We were more interested in user engagement than the analytics and Mixpanel is the only data analytics product that lets you track data and take action from your metrics — all in one place.

As a startup we wanted to know our users more and how they use our app to be more specific, with mixpanel we track most sophisticated metrics, see the complete customer journey and what not.

Later we realized that mixpanel is working great for product team but for developers we need a better crash reporting tool, one which gives us more clear logs and a way to manage those crashes.

Firebase Crashlytics by Google

We decided to integrate Firebase Crashlytics as it is lightweight, realtime crash reporter that helps us track, prioritize, and fix stability issues that erode Hypercare app quality.

Crashlytics saves us a lot of troubleshooting time by intelligently grouping crashes and highlighting the circumstances that lead up to them.

Also it brings up if a particular crash is impacting a lot of users so we can decide the priority of a crash. We also can get alerts when an issue suddenly increases in severity (thank God, haven’t got this kind of email yet 😅).

It was a disaster 🤯

After we added firebase crashlytics, it started showing up a lot of crashes. We thought them as existing crashes which we were never aware of. But some time later we realized, it was result of adding in the firebase 🤦‍♂️

We removed firebase to go back to a stable version and it worked like a charm, but it was very sad knowing that we might not be able to use multiple analytics tools together and get best of both the worlds.

After investigating, we found a solution to the problem 😎

Problem 🤬

The culprit is what we all are always warned about Method Swizzling.

Method swizzling means that you change the implementation of a given function at runtime.

It is often used when you don’t have access to the code of the function or if you don’t want to modify the code of a library and when inheritance doesn’t apply.

Mixpanel using Method Swizzling ☝️
And this is what firebase does, swizzling ☝️

Another interesting thing to look at is the issues which are highlighted when we search swizzle. Btw searching swizzling, swizzler can give us even more results 😅

So what actually happens is that firebase cloud messaging swizzle the same delegate to capture analytics data as Mixpanel does. Most analytics libraries use swizzling so be careful with that.

Solution 🥳

So there are two solutions for us.

  • Firebase comes with switch to enable or disable swizzling
  • Alternate initializer to disable automaticPushTracking so it do not conflicts with firebase swizzle

To know more about swizzling for firebase you can read their complete guide here 👇

And you can disable it as per their instructions here 👇

Disabling swizzling in Firebase Crashlytics ☝️

And for mixpanel you can use the alternate constructor as per their documentation here 👇.

Disabling automaticPushTracking in Mixpanel ☝️

Conclusion 😌

After getting rid of these ghost crashes our iOS Engineers lived happily every after (just kidding 😅)

Hypercare continues to grow and flourish as we are now working with multiple analytics tools, one perfect for product team and other for the developers.

Hypercare has helped transform 60+ organizations clinical workflow for better patient-centered care with our modern and secured collaboration tool.

You can see our wall of love by clicking the link below 👇

--

--

Salmaan Ahmed
Swift2Go

An open source contributor passionate about tech specifically mobile app development, both native and cross platform. Android | iOS | Flutter | Xamarin