-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathUXCamServiceProvider.swift
44 lines (34 loc) · 1.21 KB
/
UXCamServiceProvider.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
39
40
41
42
43
44
import Foundation
public final class UXCamServiceProvider: AbstractProvider, Service {
public var supportedTags: [Tag] = [.uxCam, .analytics, .nativeEventParameters, .nativeProperties, .nativeUserId]
public override var trackingDisabled: Bool { !adapter.optInOverallStatus() }
private let adapter: UXCamServiceAdapter.Type
public init(adapter: UXCamServiceAdapter.Type) {
self.adapter = adapter
}
public func trackEvent(_ event: Event) {
adapter.logEvent(event.name, withProperties: event.parameters)
}
public func setUserId(_ userId: String) {
adapter.setUserIdentity(userId)
}
public func resetUserId() {
adapter.setUserIdentity("")
}
public func setProperty(_ key: String, value: String) {
userProperties[key] = value
adapter.setUserProperty(key, value: value)
}
public func resetProperties() {
userProperties.keys.forEach { adapter.setUserProperty($0, value: "") }
userProperties = [:]
}
public override func disableTracking(_ flag: Bool) {
super.disableTracking(flag)
if flag {
adapter.optOutOverall()
} else {
adapter.optInOverall()
}
}
}