-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAnalyticsEvent.swift
More file actions
164 lines (145 loc) ยท 5.56 KB
/
AnalyticsEvent.swift
File metadata and controls
164 lines (145 loc) ยท 5.56 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import Foundation
/// Analytics ์ด๋ฒคํธ ํ์
public enum AnalyticsEvent {
case app_open(deviceOS: String, appVersion: String)
case view_splash
case login_start(method: LoginMethod)
case login_complete(method: LoginMethod)
case interest_select(interests: [String])
case onboarding_complete
case view_home_pokit(entryPoint: String)
case view_home_recommend(entryPoint: String)
case add_folder(folderName: String)
case add_link(folderId: String, linkDomain: String, entryPoint: String? = nil, linkId: String? = nil, positionIndex: Int? = nil, algoVersion: String? = nil)
case view_folder_detail(folderId: String)
case view_link_detail(linkId: String, linkDomain: String, entryPoint: String? = nil, positionIndex: Int? = nil, cardType: String? = nil, algoVersion: String? = nil)
case share_link(linkId: String, shareTarget: String)
case session_end(duration: Int)
/// ์ด๋ฒคํธ๋ช
(rawValue)
public var eventName: String {
switch self {
case .app_open: return "app_open"
case .view_splash: return "view_splash"
case .login_start: return "login_start"
case .login_complete: return "login_complete"
case .interest_select: return "interest_select"
case .onboarding_complete: return "onboarding_complete"
case .view_home_pokit: return "view_home_pokit"
case .view_home_recommend: return "view_home_recommend"
case .add_folder: return "add_folder"
case .add_link: return "add_link"
case .view_folder_detail: return "view_folder_detail"
case .view_link_detail: return "view_link_detail"
case .share_link: return "share_link"
case .session_end: return "session_end"
}
}
/// Amplitude์ ์ ์กํ ์์ฑ๊ฐ
public var properties: [String: Any] {
switch self {
case let .app_open(deviceOS, appVersion):
return [
PropertyKey.device_os.rawValue: deviceOS,
PropertyKey.app_version.rawValue: appVersion
]
case .view_splash:
return [:]
case let .login_start(method):
return [PropertyKey.method.rawValue: method.rawValue]
case let .login_complete(method):
return [PropertyKey.method.rawValue: method.rawValue]
case let .interest_select(interests):
return [PropertyKey.interests.rawValue: interests]
case .onboarding_complete:
return [:]
case let .view_home_pokit(entryPoint):
return [PropertyKey.entry_point.rawValue: entryPoint]
case let .view_home_recommend(entryPoint):
return [PropertyKey.entry_point.rawValue: entryPoint]
case let .add_folder(folderName):
return [PropertyKey.folder_name.rawValue: folderName]
case let .add_link(folderId, linkDomain, entryPoint, linkId, positionIndex, algoVersion):
var props: [String: Any] = [
PropertyKey.folder_id.rawValue: folderId,
PropertyKey.link_domain.rawValue: linkDomain
]
if let entryPoint = entryPoint {
props[PropertyKey.entry_point.rawValue] = entryPoint
}
if let linkId = linkId {
props[PropertyKey.link_id.rawValue] = linkId
}
if let positionIndex = positionIndex {
props[PropertyKey.position_index.rawValue] = positionIndex
}
if let algoVersion = algoVersion {
props[PropertyKey.algo_version.rawValue] = algoVersion
}
return props
case let .view_folder_detail(folderId):
return [PropertyKey.folder_id.rawValue: folderId]
case let .view_link_detail(linkId, linkDomain, entryPoint, positionIndex, cardType, algoVersion):
var props: [String: Any] = [
PropertyKey.link_id.rawValue: linkId,
PropertyKey.link_domain.rawValue: linkDomain
]
if let entryPoint = entryPoint {
props[PropertyKey.entry_point.rawValue] = entryPoint
}
if let positionIndex = positionIndex {
props[PropertyKey.position_index.rawValue] = positionIndex
}
if let cardType = cardType {
props[PropertyKey.card_type.rawValue] = cardType
}
if let algoVersion = algoVersion {
props[PropertyKey.algo_version.rawValue] = algoVersion
}
return props
case let .share_link(linkId, shareTarget):
return [
PropertyKey.link_id.rawValue: linkId,
PropertyKey.share_target.rawValue: shareTarget
]
case let .session_end(duration):
return [PropertyKey.duration.rawValue: duration]
}
}
}
/// Analytics ์์ฑ ํค
public enum PropertyKey: String {
case device_os
case app_version
case method
case interests
case entry_point
case folder_name
case folder_id
case link_domain
case link_id
case share_target
case duration
case position_index
case card_type
case algo_version
}
/// ๋ก๊ทธ์ธ ๋ฐฉ์
public enum LoginMethod: String {
case apple = "Apple"
case google = "Google"
case kakao = "Kakao"
}
extension LoginMethod {
init?(authPlatform: String) {
switch authPlatform.lowercased() {
case "apple":
self = .apple
case "google":
self = .google
case "kakao":
self = .kakao
default:
return nil
}
}
}