Skip to content

Version 5.0.0-beta.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@mscwilson mscwilson released this 03 Feb 11:58
· 118 commits to master since this release

This is the third pre-release of the upcoming version 5 of the iOS tracker, written in Swift. This beta release brings new features as well as refactoring the tracker internals.

The headline feature is the ability to provide custom tracker plugins to intercept tracked events. Plugins provide callbacks that can enrich events with additional entities and inspect tracked events. See this snippet for a glimpse of a tracker plugin:

// identifier needs to uniquely identify the plugin
let plugin = PluginConfiguration(identifier: "myPlugin")

// entities closure can return context entities to enrich events
// the list of schemas to call the closure for is optional (it will be called for all events if null)
plugin.entities(schemas: ["iglu:..."]) { event in
    return [
        SelfDescribingJson(schema: "iglu:xx", andData: ["yy": true])
    ]
}

// after track callback called on a background thread to inspect final tracked events
// one can also supply a list of schemas to call the closure only for specific events
plugin.afterTrack { event in
    print("Tracked event with \(event.entities.count) entities")
}

// the plugin is supplied to the tracker as a configuration
let tracker = Snowplow.createTracker(namespace: "ns",
                                     network: networkConfig,
                                     configurations: [plugin])

There is also an option to use Swift DSL to configure a tracker instance making the configuration code easier to read:

Snowplow.createTracker(namespace: "appTracker", endpoint: COLLECTOR_URL) {
  TrackerConfiguration()
      .base64Encoding(false)
      .sessionContext(true)

  SessionConfiguration(
      foregroundTimeout: Measurement(value: 30, unit: .minutes),
      backgroundTimeout: Measurement(value: 30, unit: .minutes)
  )
}

Finally, we have refactored the tracker internals to simplify the code and improve it's maintainability. Apart from improvements under the hood, the tracker is now easier to use in Swift as the API doesn't enforce numbers and dictionaries to be passed as NSObject.

Enhancements

  • Add ability to provide custom tracker plugins to inspect and enrich tracked events (#750)
  • Use Swift DSL for building configurations and add builder functions for configurations and events (#755)

Under the hood

  • Remove requirement for all configurations to be serializable (#753)
  • Refactor event interface and rename contexts to entities (#757)
  • Refactor APIs to replace usage of NSObject in dictionaries with the Any type (#748)
  • Update year in copyright headers and remove authors from headers in source files (#759)