Attaching a global context to the application install event on iOS

Hello!

We are trying to implement Snowplow tracker on both iOS and Android and are getting different behavior with identical implementations.

We want to send a custom context along with application_install event. After initializing the tracker we call:

tracker.globalContexts?.add(
    tag: userPreferencesContextKey,
    contextGenerator: GlobalContext(staticContexts: [
        SelfDescribingJson(
            schema: globalContextSchema,
            andData: getUserProperties().mapValuesToSwiftAny()
        )
    ])
)

On iOS the custom context is only sent with the next event. However, on Android it is sent along with the application_install. Is there a way we can match this behavior on iOS?

Could you try passing in the global context using GlobalContextsConfiguration when calling Snowplow.createTracker? There is an example at the top of the page here.

I think the problem here is that the install event is tracked too early on iOS before the tracker.globalContexts?.add() is called. Setting the global context in the createTracker() call could help.

1 Like

Yep, it works! Thanks!