App Install Event Not Tracked

Hey,

I’ve built a Kotlin and Swift wrapper for Android and iOS snowplow SDK’s respectively, I’ve turned off all automatic tracking features except setInstallAutoTracking. All the other manual events that I’ve created using custom schemas are being tracked successfully via the wrapped trackers.

For iOS, the tracker is able to track the ‘application_install’ event but with empty flower braces.
Ex:
image

For Android, the tracker doesn’t seem to track the ‘application_install’ event at all.

I’m not sure if I’m missing something or if I’m doing something wrong, could someone help me out?

Thank You!

Hi @siv,

The fact that the application_install event is tracked with no properties (empty braces) is as expected – it shouldn’t have any properties, it just signals the installation.

In the Android case, please make sure that you test with a clean installation of the app. So try uninstalling the app and reinstalling again. The tracker creates a flag in SharedPreferences after the install event is tracked to prevent from tracking again.

It could also be helpful if you could provide you configuration and the way you initialize the tracker. However, there shouldn’t be anything special needed with the install autotracking feature – enabling it in the configuration should be sufficient.

Hi @matus,

Thank you for responding. I’ve tried uninstalling the application and reinstalling it again, it didn’t work.

This is how the wrapper is called to create the tracker:
val tracker = wrappedSnowplowTracker(applicationContext,endpoint,apiKey)

The config for the tracker(okhttpclient to used to intercept and add key):

        networkConfig = NetworkConfiguration(
            this.endpoint,
            httpMethod
        ).okHttpClient(okHttpClient)

        foregroundTimeout = TimeMeasure(30, TimeUnit.MINUTES)
        backgroundTimeout = TimeMeasure(30, TimeUnit.MINUTES)
        sessionConfig = SessionConfiguration(
            foregroundTimeout,
            backgroundTimeout
        )

        emitRange = 500
        threadPoolSize = 20
        byteLimitGet = 52000
        byteLimitPost = 52000
        emitterConfig = EmitterConfiguration()
            .requestCallback(getRequestCallback())
            .emitRange(emitRange)
            .threadPoolSize(threadPoolSize)
            .byteLimitGet(byteLimitGet)
            .byteLimitPost(byteLimitPost)

        appId = "android"
        namespace = "android"
        devicePlatform = DevicePlatform.Mobile
        setBase64Encoding = true 
        setScreenContext = true
        setSessionContext = true
        setPlatformContext = true
        setApplicationContext = true
        setGeoLocationContext = true
        setDeepLinkContext = true
        setLifecycleAutoTracking = false
        setScreenViewAutoTracking = false
        setExceptionAutoTracking = false
        setInstallAutoTracking = true
        setDiagnosticAutoTracking = false
        trackerConfig = TrackerConfiguration(appId)
            .logLevel(LogLevel.VERBOSE)
            .loggerDelegate(this)
            .devicePlatform(devicePlatform)
            .base64encoding(setBase64Encoding)
            .sessionContext(setSessionContext)
            .screenContext(setScreenContext)
            .platformContext(setPlatformContext)
            .applicationContext(setApplicationContext)
            .geoLocationContext(setGeoLocationContext)
            .deepLinkContext(setDeepLinkContext)
            .lifecycleAutotracking(setLifecycleAutoTracking)
            .screenViewAutotracking(setScreenViewAutoTracking)
            .exceptionAutotracking(setExceptionAutoTracking)
            .installAutotracking(setInstallAutoTracking)
            .diagnosticAutotracking(setDiagnosticAutoTracking)

        tracker = Snowplow.createTracker(
            applicationContext,
            namespace,
            networkConfig,
            sessionConfig,
            emitterConfig,
            trackerConfig
        )

Hi @siv ,

As Matus said the install tracking works in a separate background task where it update the SharedPreferences with a flag and a timestamp.

My unique guess is that the tracker can’t correctly write or read from the SharedPreferences.
In this snippet the code involved to send the event. This would silently fail if the SharedPreferences is not accessible.
So far, we haven’t found any case where it wasn’t accessible.

Also, this operation happens in a background task. Would it be possible that the application terminates without leaving the background task to complete? It should be pretty fast but in some cases (e.g.: unit tests) it doesn’t start on time and the execution of the application terminates too early. Also, the event could be sent in a second moment if it hasn’t been sent at the first run.

Hey @Alex_Benini ,

I do not think that the app terminates before completing background task but I assume the tracker is somehow not able to access the SharedPreferences passed through the applicationContext.

I’m using the wrapped tracker(aar) in a bare minimum android application that has a few basic buttons to trigger manual events.

Is there something that I could try to diagnose the issue, I’m new to mobile development.

Thank you!

Hi @siv,

I tried to reproduce the issue under similar settings – Kotlin app with the tracker included as an aar package but wasn’t successful in doing that (the install events were tracked).

Could you please help us reproduce the problem by providing a minimal example for it? I created this repository with my reproduction attempt (here is the MainActivity where the tracker is initialized). If you could change this (or other) app to simulate the behaviour, that would be extremely helpful for us to identify and fix the issue!

1 Like

Hi @matus ,

Thanks for your reply. :slight_smile:

Excuse my delay in response.

The application structure is similar to what we are doing but we are using a wrapped snowplow tracker, i.e. the snowplow tracker aar is contained in another aar that we created and use.

I’ll modify the app code and ping here once done.

1 Like

Hey @matus,

I was not able to push the code to your repo.

I have created a repo of my own, could you use this?

Hi @siv ,

I’ve tried your application and I’m able to see the installation events on Snowplow Micro.
I would suggest to test the tracking there first, just to exclude any other issue.

I’ve also created a direct dependency between your app and your library (wrapped_tracker) so I could debug it deeper.

I have just few notes that maybe help to narrow down the problem:

  • In your WrappedSnowplowTracker you check the property setInstallAutoTracking using contains but I think that check the value so it would return always false. You should use containsKey which checks the key. If the problem is this, it’s an easy fix as technically the wrapper didn’t configure the tracker properly.

  • Another minor note is about the app permission. I added the INTERNET permission in the Android Manifest because it wasn’t able to send any event, but I don’t think this was your issue.

I would suggest to check on Micro first (maybe using ngrok to avoid any issue where the traffic is blocked). If it works on Micro but it doesn’t work with the real pipeline we should look into something else, but I don’t think this is the case.

2 Likes

Thank you @Alex_Benini! “containsKey” fixed it!! :slight_smile:

1 Like