dd-sdk-android: View's duplicated when using version 2.x
Describe what happened Once we updated our app to use version 2.0 (and now 2.1.0), we noticed that the views inside the sessions were duplicated.
In the duplicated view, one is full of data, like tracers, and the other is empty.
Here’s our setup
fun startLibrary() {
if (Datadog.isInitialized()) return
val configuration = getConfiguration()
val trackingConsent = TrackingConsent.GRANTED
Datadog.initialize(context, configuration, trackingConsent)
// Enable RUM
setupRumConfiguration()
// Setup Tracers
setupTracesConfiguration()
if (showLogs) {
Datadog.setVerbosity(Log.VERBOSE)
}
}
fun setupUserInLibrary(user: User) {
Datadog.setUserInfo(id = user.id)
}
fun unsetUserInLibrary() {
// Setting nothing as user info will default to null attributes
Datadog.setUserInfo()
}
private fun setupRumConfiguration() {
val rumConfig = RumConfiguration
.Builder(applicationId = ...)
.setSessionSampleRate(SampleRateProvider.sampleRate())
.setSessionListener(object : RumSessionListener {
override fun onSessionStarted(sessionId: String, isDiscarded: Boolean) {
log("Datadog - sessionId = [$sessionId], isDiscarded = [$isDiscarded]")
}
})
.useViewTrackingStrategy(strategy = strategyProvider.get())
.trackUserInteractions()
.setErrorEventMapper(ErrorEventMapper())
.trackLongTasks()
.build()
Rum.enable(rumConfig)
}
private fun setupTracesConfiguration() {
val traceConfig = TraceConfiguration.Builder().build()
Trace.enable(traceConfig)
val tracer = AndroidTracer.Builder().build()
GlobalTracer.registerIfAbsent(tracer)
}
private fun getConfiguration(): Configuration {
return Configuration
.Builder(
clientToken = ...,
env = ...,
variant = ...,
service = ...
)
.useSite(site = DatadogSite.EU1)
.setCrashReportsEnabled(crashReportsEnabled = true)
.setFirstPartyHosts(tracedHosts)
.build()
}
class ViewTrackingStrategyProvider {
private val activityPredicate = object : ComponentPredicate<Activity> {
override fun accept(component: Activity): Boolean {
return true
}
override fun getViewName(component: Activity): String? {
return component.javaClass.simpleName
}
}
private val fragmentPredicate = object : ComponentPredicate<Fragment> {
override fun accept(component: Fragment): Boolean {
// Skip Glide Fragments
return (component is SupportRequestManagerFragment).not()
}
override fun getViewName(component: Fragment): String {
return component.javaClass.simpleName.toString()
}
}
@Suppress("deprecation")
private val fragmentLegacyPredicate = object : ComponentPredicate<android.app.Fragment> {
override fun accept(component: android.app.Fragment): Boolean {
return true
}
override fun getViewName(component: android.app.Fragment): String {
return component.javaClass.simpleName.toString()
}
}
fun get() = MixedViewTrackingStrategy(
trackExtras = true,
componentPredicate = activityPredicate,
supportFragmentComponentPredicate = fragmentPredicate,
defaultFragmentComponentPredicate = fragmentLegacyPredicate,
)
}
Steps to reproduce the issue: Just use the app in version 2.x and open multiple screens.
Describe what you expected: No views are duplicated, like version 1.x.
Additional context
- Android OS version: 33
- Datadog SDK version: 2.1.0
- Gradle Plugins: 7.4.2
Let me know if I can help with any extra information.
Thanks!
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 2
- Comments: 17
Hi @RamiTrabelsi I’m pretty sure this was a typo I’ll check with support to have a call much earlier than that
Hello 👋
If we don’t include the
MixedViewTrackingStrategy, the tracer is not duplicated, but we can see onlyActivities.btw, this class is marked as deprecated. Should we use another resource?
Thanks