I’m working on an Android application where I want to track user interactions across all Activities and Fragments. My goal is to implement a system that can log which views users are interacting with, similar to what tools like Instabug offer for tracking user journeys.
Approach Considered:
One approach that comes to mind is to register ActivityLifecycleCallbacks in the Application class and, in the onActivityCreated callback, recursively attach an OnTouchListener to all views in the activity. This would allow me to detect which view the user is interacting with across the entire application.
What I’m Looking For:
-
Is this approach ideal for a production environment, or are there better alternatives to achieve similar functionality with less overhead? This approach might introduce significant overhead since every view in the application would have a listener attached. This could lead to performance issues, especially in complex layouts with a large number of views.
-
What are the best practices for implementing a user journey tracking system that logs user interactions across the app in a way that is both efficient and minimally intrusive? Are there specific design patterns or tools (possibly existing libraries) that can help implement this kind of tracking more effectively?
-
How do tools like Instabug achieve this tracking without noticeable performance degradation?
Nauman Afzaal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.