snowplow / snowplow-ios-tracker

Snowplow event tracker for Swift and Objective-C. Add analytics to your iOS, macOS, tvOS and watchOS apps and games
http://snowplow.io
Apache License 2.0
81 stars 93 forks source link

Consider refactoring how we set mobile context #34

Closed jonalmeida closed 9 years ago

jonalmeida commented 10 years ago

When we have a determined/unchanging schema for how the context 'co' is going to be set, we should consider refactoring our 0.1 implementation to be configurable or generic. Right now, it feels a bit hard coded and ugly to read.

Early thoughts:

{
    schema: 'iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-0',
    data: [{
        eid: 'BBBAEB98-B556-43E6-8A07-80B6FD093C2E',
        vp: '320x480',
        p: 'mob',
        co: {
            schema: 'iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0',
            data: [{
                schema: 'iglu:com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-0',
                data: {
                    osType: '...',
                    osVersion: '...',
                    deviceVendor: '...',
                    deviceModel: '...',
                    carrier: '...'
                }
            }]
        },
        refr: 'myreferrer',
        url: 'http://foo.com',
        dtm: 1402062281979.792,
        tv: 'ios-0.1',
        tna: 'myname',
        lang: 'en',
        page: 'This is my foo',
        e: 'pv',
        aid: 'foo',
        res: '320x480'
    }]
}
jbeemster commented 9 years ago

This will be solved with a SelfDescribingJson class implementation.