Skip to content

Instantly share code, notes, and snippets.

@bsneed
Created May 18, 2020 19:32
Show Gist options
  • Save bsneed/5cf69e0d93a47c98ac2b30a7191d9f96 to your computer and use it in GitHub Desktop.
Save bsneed/5cf69e0d93a47c98ac2b30a7191d9f96 to your computer and use it in GitHub Desktop.
Segment Middleware Example
let checkConsentOfEvent = SEGBlockMiddleware { (context, next) in
if context.eventType == .track {
if (hasConsent(for: blah)) {
next(context)
} else {
return
}
} else {
next(context)
}
}
configuration.integrationMiddleware = [
SEGIntegrationMiddleware(key: mixpanelIntegration.key(), middleware: [checkConsentOfEvent])
]
SEGAnalytics.setup(with: configuration)
SEGAnalytics.shared()?.identify("brandon")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment