dd-sdk-ios icon indicating copy to clipboard operation
dd-sdk-ios copied to clipboard

Missing crashes when tracking consent is pending

Open kublaios opened this issue 11 months ago • 6 comments

Question

The Datadog SDK is initialized during the app launch with trackingConsent set to pending and we update it during the user sign-in. The problem is that if the user experiences a crash before signing in, the emergency log/other logs are not uploaded to Datadog, even after the user signs in.

I expected that the logs would persist from the previous session until the tracking consent is granted and they are uploaded together with the logs in the current session. Is the current behavior the expected behavior and, if yes, is there a way of retrieving the crashes for sessions where tracking consent is pending/granted later?

kublaios avatar Feb 27 '24 19:02 kublaios

Hey @kublaios 👋

I expected that the logs would persist from the previous session until the tracking consent is granted and they are uploaded together with the logs in the current session.

That is how the SDK behaves: when the tracking consent is pending, data is collected and stored on disk (included crashes) but not upload. When consent is granted, the data previously collected is uploaded. If the user does not consent, then the data is erased from disk and no further data is collected.

~~In your case, if the user experience a crash before login then the crash will be stored on disk. When the user re-open the application and grant consent after login, then the previous crash will be uploaded.~~

Does it answer your question?

maxep avatar Feb 28 '24 09:02 maxep

Thanks for the swift response, @maxep.

Unfortunately, both on the live app as well as in our testing, we are losing crashes that occur before sign-in. Any log, for that matter. We noticed this when we discovered that some crashes are reported to Firebase Crashlytics but not Datadog. The same crash is reported to Datadog if it happens when the user is signed in.

I had also tried the following:

  • From a cold start, navigated through the app before signing in (consent: pending), then signed in. I was able to see logs pre-sign-in. I logged out and killed the app.
  • From the next cold start, navigated through the app unauthenticated, but killed the app before signing in this time. Then I reopened the app and signed in. I lost the logs from the session that I killed the app without signing in.

Could it be that only the logs from the same session are reported after consent is granted and the session identifier is reset upon the app is terminated/crashed?

kublaios avatar Feb 28 '24 10:02 kublaios

Hey @kublaios,

Sorry, I was wrong on my previous comment: We only keep pending data for the current session, not from the previous one. We are actually clearing pending data when the app starts, and we only report crashes when the consent is granted. Which mean that crashes happening before the login won't be reported..

You are getting crashes from Firebase Crashlytics before the consent is actually granted?

I will bring this topic to the team! thank you for the report 🙏

maxep avatar Feb 28 '24 11:02 maxep

Sounds good, thanks @maxep.

You are getting crashes from Firebase Crashlytics before the consent is actually granted?

Yes, but since the Firebase analytics is disabled in our case, there is no additional consent we need to configure later on. As Datadog provides more context, we are evaluating whether to use it instead of Firebase Crashlytics and this capability would be a big plus.

kublaios avatar Feb 28 '24 12:02 kublaios

@maxep

We have encountered a similar issue in our scenario where crashes are not being reported to Datadog when the consent is in a pending state during initialization.

We would greatly appreciate it if crashes could be reported once the consent status changes to Granted instead dropped completely.

Thank you.

sathriyanIDPal avatar Mar 07 '24 05:03 sathriyanIDPal

Thanks for the additional details. It's a totally valid use case, it has been added to our backlog 👍 I keep this ticket open for tracking and visibility, stay tuned!

maxep avatar Mar 12 '24 11:03 maxep