Segment

Integration

A recipe for straightforward Segment integration on iOS.

let segmentConfiguration = SEGAnalyticsConfiguration(writeKey: SEGMENT_API_KEY)
    
let smartlookMiddleware = SEGBlockMiddleware(block: { (context, next) in
  switch (context.eventType) {
  case .track:
    if let track = context.payload as? SEGTrackPayload {
      let props = Properties()
      // fill props with payload properties
      Smartlook.track(event: track.event, props: props)
    }
  default:
    break
  }
  next(context)
})
segmentConfiguration.middlewares = [smartlookMiddleware]

SEGAnalytics.setup(with: segmentConfiguration)

 Full Segment documentation for mobile platforms can be found on the official website.