-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFirebaseAnalyticsServiceProvider.swift
38 lines (29 loc) · 1.11 KB
/
FirebaseAnalyticsServiceProvider.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Foundation
public final class FirebaseAnalyticsServiceProvider: AbstractProvider, Service {
public var supportedTags: [Tag] = [.firebaseAnalytics, .analytics, .nativeEventParameters, .nativeProperties, .nativeUserId]
private let adapter: FirebaseAnalyticsServiceAdapter.Type
public init(adapter: FirebaseAnalyticsServiceAdapter.Type) {
self.adapter = adapter
}
public func trackEvent(_ event: Event) {
adapter.logEvent(event.name, parameters: event.parameters)
}
public func setUserId(_ userId: String) {
adapter.setUserID(userId)
}
public func resetUserId() {
adapter.setUserID(nil)
}
public func setProperty(_ key: String, value: String) {
userProperties[key] = value
adapter.setUserProperty(value, forName: key)
}
public func resetProperties() {
userProperties.keys.forEach { adapter.setUserProperty(nil, forName: $0) }
userProperties = [:]
}
public override func disableTracking(_ flag: Bool) {
super.disableTracking(flag)
adapter.setAnalyticsCollectionEnabled(!flag)
}
}