-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMixpanelServiceAdapter.swift
58 lines (48 loc) · 1.33 KB
/
MixpanelServiceAdapter.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import Foundation
/**
Adapter for the Mixpanel iOS library.
# Useful links:
- https://developer.mixpanel.com/docs/swift
# Package example:
```
// swift-tools-version: 5.10
import PackageDescription
let package = Package(
name: "Example",
dependencies: [
.package(name: "Tracker", path: "./swift-event-tracker"),
.package(url: "https://github.com/mixpanel/mixpanel-iphone", from: "5.0.0"),
],
targets: [
.target(name: "Example", dependencies: [.product(name: "Mixpanel", package: "mixpanel-iphone"), "Tracker"]),
]
)
```
# Integration example:
```
import Mixpanel
import Tracker
extension Mixpanel: MixpanelServiceAdapter {
public func resetUserId() {
identify(anonymousId)
}
public func set(property: String, to value: String) {
people.set(property, to: value)
}
public func unset(properties: [String]) {
people.unset(properties)
}
}
```
*/
// sourcery: AutoMockable
public protocol MixpanelServiceAdapter: AnyObject {
func identify(_ distinctId: String)
func resetUserId()
func hasOptedOutTracking() -> Bool
func optInTracking()
func optOutTracking()
func set(property: String, to value: String)
func track(_ event: String, properties: [AnyHashable: Any]?)
func unset(properties: [String])
}