<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andriy Nikitin on Medium]]></title>
        <description><![CDATA[Stories by Andriy Nikitin on Medium]]></description>
        <link>https://medium.com/@andriy.nikitin07?source=rss-3f59ee904421------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*rEHsVRU1x_0THy6Pd6ZDZg.jpeg</url>
            <title>Stories by Andriy Nikitin on Medium</title>
            <link>https://medium.com/@andriy.nikitin07?source=rss-3f59ee904421------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 03:36:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andriy.nikitin07/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Analytics events tracking system for Android]]></title>
            <link>https://medium.com/@andriy.nikitin07/analytics-events-tracking-system-for-android-1836679c2cff?source=rss-3f59ee904421------2</link>
            <guid isPermaLink="false">https://medium.com/p/1836679c2cff</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[analytics-platforms]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Andriy Nikitin]]></dc:creator>
            <pubDate>Tue, 21 Apr 2020 18:38:20 GMT</pubDate>
            <atom:updated>2020-04-21T22:09:32.491Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lu2VotVVxATx9FFzDqqe7w.jpeg" /></figure><p><strong>Introduction</strong></p><p>Big projects very often require scalable, well-designed decisions. It is especially important when you work on one code base with 15+ developers. Historically, our project consist of 7 different analytics providers (Mixpanel, Firebase etc) and we can’t remove any of them because different departments use different system.</p><p>Couple of month ago we decided to create our own analytics system and I’ve been asked to add one more provider and re-route all events there. At that moment our approach to track analytics events was not good, to put it mildly. It didn’t consider adding or removal any analytics provider and was very tightened to POJOs. So before adding we definitely needed to rewrite that part.</p><p>This article was written to describe our current approach for tracking events. It is quite flexible and scalable and satisfy all our needs.</p><p><strong>Prerequisites</strong></p><p>All examples are written in Kotlin using Dagger 2. We assume that each event consist of label and 0 or more properties. Firebase and Mixpanel providers are used as an example. This approach can be easily scaled to other providers as well.</p><p><strong>Creating base classes</strong></p><p>Before we start to implement main part we need to define some base classes. Let’s start from models.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee1a8698e32c1aaa440e3917958c80eb/href">https://medium.com/media/ee1a8698e32c1aaa440e3917958c80eb/href</a></iframe><p>AnalyticsPropertyKey will be used later to define property label for different events. <br>AnalyticsProperty defines scheme of property which includes property key and some value (could be any type, usually primitive or String)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9d8bdcfa8e60347c1b2a9030b6d96ba/href">https://medium.com/media/d9d8bdcfa8e60347c1b2a9030b6d96ba/href</a></iframe><p>AnalyticsEvent is the same as AnalyticsPropertyKey but for event label. <br>AnalyticsTrackingModel defines scheme of event. Basically it says that event label is mandatory for constructor. Properties are optional and defined as vararg for simplicity of usage without defining additional list/array in code. Each subclass of this class represents one of the analytics providers. For instance:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b45341815634ef696490a0f77daf729/href">https://medium.com/media/0b45341815634ef696490a0f77daf729/href</a></iframe><p>Later each of these models will be used to explicitly indicate which provider you want to send this event to.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8b6b156b88304fbf756d4f4fc50df83/href">https://medium.com/media/e8b6b156b88304fbf756d4f4fc50df83/href</a></iframe><p>This is a base class which should implement tracking logic. For example, your firebase tracker could be like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/920bdb451180b927662e9f4a49078524/href">https://medium.com/media/920bdb451180b927662e9f4a49078524/href</a></iframe><p>Here AnalyticsUtils.createBundleFromEventProperties(properties) is just a map function which creates Bundle object from passed properties.</p><p><strong>Building manager</strong></p><p>Now it’s time to compose a general class which will accept our base event class and pass it to certain tracker. Let’s name it AnalyticsManager .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a8833815b28d89acf943c4d5332b47f/href">https://medium.com/media/9a8833815b28d89acf943c4d5332b47f/href</a></iframe><p>The main and only entry point is method trackEvent . It accepts base analytics model and based on the passed class type it executes corresponding private helper method. Also AnalyticsManager is Singleton because it should be initialised once and then used for tracking. Also pay attention to special class DefaultTrackingModel processing. 99% of our events use exactly this model to track events. It also allows you easily to re-route most of the events to another provider or just remove one of them. <br>You might also ask why we still have a separate processing for Mixpanel events whilst having it in default implementation. Well, in some cases you may want to send particular event to one of the provider bypassing others. One of the cases is that some providers allow to configure triggers on certain events. That’s why it is pretty handy to have a separate model for each of the providers.</p><p><strong>Example of usage</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85327817617657c8747f10b410b9649c/href">https://medium.com/media/85327817617657c8747f10b410b9649c/href</a></iframe><p>A little bit of explanation. OnboardingProperty and OnboardingEvent are defined as sealed classes, so all events that related to particular group will be in one place and not somewhere outside. Each of subclass of these classes passing a label to constructor. By this label your BA can find this event/property in provider’s dashboard. Only one method from AnalyticsManager is used everywhere - trackEvent . Also it is worth noting, that this method accepts vararg as well, like AnalyticsTrackingModel class.<br>It means that if you need to add tracking one more provider to any of these methods it could be easily done in a concise way. For instance, trackLoginClicked can be written like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41445b89e01e4458592601c9983cf2f5/href">https://medium.com/media/41445b89e01e4458592601c9983cf2f5/href</a></iframe><p>Using this approach you will get pretty solid, flexible and scalable architecture for tracking analytics events. Adding/removal analytics providers, switching on/off any of the events is not a problem anymore. The real power of this solution can be observed in a large team of Android developers and a big amount amount of events (f.e. in our project we have 800+ events). It also allows you to group and systemise your events by any category (by feature, team etc)</p><p>Stay safe. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1836679c2cff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The dark side of transitive dependencies in Gradle.]]></title>
            <link>https://medium.com/@andriy.nikitin07/the-dark-side-of-transitive-dependencies-in-gradle-1b0e9ad02e69?source=rss-3f59ee904421------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b0e9ad02e69</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[exception]]></category>
            <category><![CDATA[retrofit]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[dependencies]]></category>
            <dc:creator><![CDATA[Andriy Nikitin]]></dc:creator>
            <pubDate>Mon, 22 Jul 2019 19:49:17 GMT</pubDate>
            <atom:updated>2019-07-22T19:52:32.309Z</atom:updated>
            <content:encoded><![CDATA[<p>Long time ago in a far away galaxy… Wait, wait, wait. This story is not about light sabres and courage Jedis, unfortunately(I wanted to write one, I swear).<br>I’m going to tell you about the dark force that silently tried to cut the ground from under ours feet. This story is about transitive dependencies that could crash you app in runtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*eC6bY9cptwS9jh2xQ_K2aA.png" /></figure><p><strong>Preamble</strong></p><p>A few days ago our QA encountered weird crashes that happened on devices with pre-Lollipop version on board:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*1GjiLRzivY8YQyA_A53bcg.png" /><figcaption>Exception thrown on app launch</figcaption></figure><p>We started investigating this issue with looking for last commits, which could cause it. The key condition was changes in our dependencies versions. But nothing criminal was found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*XTVx7Nhr4zCqy30SFl3QfQ.jpeg" /></figure><p><strong>Searching for roots</strong></p><p>Our next step in finding out the cause was looking at dependencies graph. There are very useful gradle tasks which helped us a lot before and in this case also! One of them called dependencies .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*nRnRo0yU_MaojjZWzj0bCg.png" /><figcaption>Command location in Gradle sidebar</figcaption></figure><p>It builds you a full graph of dependencies. But it may be cumbersome to read. So better to use its analogue with option to apply filter flag.</p><pre>./gradlew app:dependencyInsight --dependency okhttp --configuration internalDevDebugCompileClasspath</pre><p>Here app is your module which is needed to be analysed, okhttp is a problematic dependency name.</p><p>With mentioned above commands and after a few hours of searching, we finally found out what caused this exception. In our project we use Taplytics platform to make A/B testing. It turns out that they use dynamic version for Retrofit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*vCxXoodXDS87AVSBLp9PJQ.png" /><figcaption>Taplytics dependency in the graph</figcaption></figure><p>2.7.0-SNAPSHOT no longer supports devices with API lower than 21. So when Square released this version, Gradle automatically consumed and applied it to each Retrofit dependency (transitive and ours).</p><p><strong>Solution</strong></p><p>Firstly, we thought about excluding it from taplytics library by adding exclude directive in gradle script. But we wanted solution to be scalable, because if another dependency uses dynamic versioning too we will encounter the same exception.</p><p>So we decided to implement it in a much global way.</p><pre>configurations.all {<br>    resolutionStrategy.eachDependency { details -&gt;<br>        if (details.requested.group == &#39;com.squareup.okhttp3&#39;) {<br>            details.useVersion rootProject.ext.okhttpVersion<br>        }<br>        if (details.requested.group == &#39;com.squareup.retrofit2&#39;) {<br>            details.useVersion rootProject.ext.retrofitVersion<br>        }<br>    }<br>}</pre><p>This piece of script forces to use the dependency version that you specify for each dependency (doesn’t matter if it’s transitive or not). So in the future, if someone of library developers started to use dynamic versioning for Retrofit or OkHttp we will be safe &amp; sound.</p><blockquote>P.S. I’d not suggest to use dynamic versioning (like 1.+, [1.0,), [1.0, 2.0) ) in your project, ’cause it will give a lot of pain to find the cause.</blockquote><p>Happy coding to everyone! And may the force be with you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b0e9ad02e69" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>