I want to track event using fabric. Which is working for me via using
import Answers
func trackEvent() {
Answers.logCustomEvent(withName: "testEvent", customAttributes: ["Category":"test", "Player":50])
}
But I have to import the answers class in every view, where I need to track any event. Is there any other way or method to track events without the need of importing answer class every single time.
How about this? Create a class say Tracker
and import Answers
their.
import Answers
class Tracker {
static func logCustomEvent(withName:String, customAttributes:[String:Any]) {
Answers.logCustomEvent(withName: withName, customAttributes: customAttributes)
}
}
And then use your class everywhere without importing anything.
Tracker.logCustomEvent(withName: "testEvent", customAttributes: ["Category":"test", "Player":50])