Mobile Development 8 min read

Implementing Event Tracking in Mobile Apps Using Kotlin and Selenium

This article discusses implementing event tracking in mobile applications using Kotlin, including creating extension methods for cleaner code, handling third-party platform limitations with Selenium, and sharing practical experiences from multiple project versions.

ByteDance Dali Intelligent Technology Team
ByteDance Dali Intelligent Technology Team
ByteDance Dali Intelligent Technology Team
Implementing Event Tracking in Mobile Apps Using Kotlin and Selenium

This article discusses implementing event tracking in mobile applications using Kotlin, including creating extension methods for cleaner code, handling third-party platform limitations with Selenium, and sharing practical experiences from multiple project versions.

The author describes a scenario where a third-party platform doesn't provide an API for event tracking, requiring the use of Selenium to simulate browser operations as a workaround. While not elegant, this approach proved effective compared to the alternative of being constrained by the platform's limitations.

To simplify tracking code, the team created an extension method that makes the final tracking code more readable and focused on the key-value pairs themselves rather than complex method calls. The implementation shows a clean syntax where developers only need to specify the event name and associated key-value pairs.

The article provides the actual Kotlin code for the extension methods, demonstrating how to create a log function that accepts variable pairs of strings and any type, constructs an event object, populates its parameters, and logs it with an optional handler.

The author shares that this tracking workflow has been successfully implemented across multiple versions of their project with minimal issues. The main challenge mentioned is coordinating with the Data Analytics (DA) team to ensure tracking points are properly configured in the tracking platform before implementation. The author humorously suggests team composition considerations for better collaboration.

The article concludes by discussing how practical experience with tracking workflows has led to exploring how Live Templates can be better utilized in project engineering to improve development efficiency. The author encourages colleagues to share their experiences and ideas to further enhance productivity.

mobile developmentKotlinevent trackingdata analyticsSeleniumExtension MethodsLive Templates
ByteDance Dali Intelligent Technology Team
Written by

ByteDance Dali Intelligent Technology Team

Technical practice sharing from the ByteDance Dali Intelligent Technology Team

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.