Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Commit fd19bf4

Browse files
authored
Merge pull request #2593 from RocketChat/chore/audio_message_events
[CHORE] Add events to Directory & Audio Messages
2 parents 058aa24 + 224b114 commit fd19bf4

6 files changed

Lines changed: 41 additions & 9 deletions

File tree

Rocket.Chat.ShareExtension/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>3.4.0</string>
2121
<key>CFBundleVersion</key>
22-
<string>240</string>
22+
<string>242</string>
2323
<key>ITSEncryptionExportComplianceCode</key>
2424
<string></string>
2525
<key>NSExtension</key>

Rocket.Chat/Controllers/Chat/MessagesViewControllerComposerDelegate.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ extension MessagesViewController: ComposerViewExpandedDelegate {
2121

2222
func composerView(_ composerView: ComposerView, didFinishRecordingAudio url: URL) {
2323
upload(audioWithURL: url)
24+
25+
if let subscriptionType = viewModel.subscription?.type {
26+
AnalyticsManager.log(
27+
event: Event.audioMessage(subscriptionType: subscriptionType.rawValue
28+
))
29+
}
2430
}
2531

2632
func composerView(_ composerView: ComposerView, didConfigureOverlayView view: OverlayView) {

Rocket.Chat/Controllers/Directory/DirectoryViewController.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ final class DirectoryViewController: BaseTableViewController {
9191
let buttonActivity = UIBarButtonItem(customView: activity)
9292
activity.startAnimating()
9393
navigationItem.rightBarButtonItem = buttonActivity
94+
95+
AnalyticsManager.log(event: Event.directory(
96+
searchType: viewModel.type.rawValue,
97+
workspace: viewModel.workspace.rawValue
98+
))
9499
}
95100

96101
viewModel.loadMoreObjects { [weak self] in
@@ -226,18 +231,25 @@ extension DirectoryViewController: UISearchBarDelegate {
226231

227232
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
228233
if searchText == "" && !viewModel.query.isEmpty {
229-
viewModel.query = searchBar.text ?? ""
230-
tableView.reloadData()
231-
loadMoreData(reload: true)
234+
search()
232235
}
233236
}
234237

235-
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
236-
viewModel.query = searchBar.text ?? ""
238+
func search() {
239+
viewModel.query = searchBar?.text ?? ""
237240
tableView.reloadData()
238241
loadMoreData(reload: true)
239242
}
240243

244+
func searchBarShouldEndEditing(_ searchBar: UISearchBar) -> Bool {
245+
search()
246+
return true
247+
}
248+
249+
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
250+
search()
251+
}
252+
241253
func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
242254
searchBar.setShowsCancelButton(false, animated: true)
243255
searchBar.resignFirstResponder()

Rocket.Chat/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
</dict>
223223
</array>
224224
<key>CFBundleVersion</key>
225-
<string>240</string>
225+
<string>242</string>
226226
<key>Fabric</key>
227227
<dict>
228228
<key>APIKey</key>

Rocket.Chat/Managers/AnalyticsManager.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ enum Event {
2222
case updateStatus
2323
case replyNotification
2424
case openAdmin
25+
case directory(searchType: String, workspace: String)
2526
case screenView(screenName: String)
2627
case messageSent(subscriptionType: String, server: String)
2728
case mediaUpload(mediaType: String, subscriptionType: String)
@@ -31,6 +32,7 @@ enum Event {
3132
case updatedWebBrowser(browser: String)
3233
case updatedTheme(theme: String)
3334
case jitsiVideoCall(subscriptionType: String, server: String)
35+
case audioMessage(subscriptionType: String)
3436
}
3537

3638
enum UserProperty {
@@ -115,11 +117,13 @@ extension Event {
115117
case .messageSent: return "message_sent"
116118
case .mediaUpload: return "media_upload"
117119
case .reaction: return "reaction"
120+
case .directory: return "directory"
118121
case .serverSwitch: return "server_switch"
119122
case .updatedSubscriptionSorting: return "updated_subscriptions_sorting"
120123
case .updatedWebBrowser: return "updated_web_browser"
121124
case .updatedTheme: return "updated_theme"
122125
case .jitsiVideoCall: return "jitsi_video_call"
126+
case .audioMessage: return "audio_message"
123127
}
124128
}
125129

@@ -129,6 +133,8 @@ extension Event {
129133
return ["screen": screenName]
130134
case let .reaction(subscriptionType):
131135
return ["subscription_type": subscriptionType]
136+
case let .directory(searchType, workspace):
137+
return ["search_type": searchType, "workspace": workspace]
132138
case let .messageSent(subscriptionType, server):
133139
return ["subscription_type": subscriptionType, "server": server]
134140
case let .mediaUpload(mediaType, subscriptionType):
@@ -143,6 +149,8 @@ extension Event {
143149
return ["theme": theme]
144150
case let .jitsiVideoCall(subscriptionType, server):
145151
return ["subscription_type": subscriptionType, "server": server]
152+
case let .audioMessage(subscriptionType):
153+
return ["subscription_type": subscriptionType]
146154
default:
147155
return nil
148156
}

Rocket.ChatTests/Models/UserSpec.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,26 @@ class UserSpec: XCTestCase {
126126

127127
func testAvatarURLValid() {
128128
let auth = Auth.testInstance()
129+
auth.token = "token123"
130+
auth.userId = "userId123"
131+
129132
let user = User.testInstance()
130133
let avatarURL = user.avatarURL(auth)
131134
XCTAssertNotNil(avatarURL, "url is valid")
132-
XCTAssertEqual(avatarURL?.absoluteString, "https://open.rocket.chat/avatar/user-username?format=jpeg", "avatar url is valid")
135+
XCTAssertEqual(avatarURL?.absoluteString, "https://open.rocket.chat/avatar/user-username?format=jpeg&rc_uid=userId123&rc_token=token123", "avatar url is valid")
133136
}
134137

135138
func testAvatarURLRandomUsername() {
136139
let auth = Auth.testInstance()
140+
auth.token = "token123"
141+
auth.userId = "userId123"
142+
137143
let user = User.testInstance()
138144
user.username = String.random()
139145

140146
let avatarURL = user.avatarURL(auth)
141147
XCTAssertNotNil(avatarURL, "url is valid")
142-
XCTAssertEqual(avatarURL?.absoluteString, "https://open.rocket.chat/avatar/\(user.username ?? "")?format=jpeg", "avatar url is valid")
148+
XCTAssertEqual(avatarURL?.absoluteString, "https://open.rocket.chat/avatar/\(user.username ?? "")?format=jpeg&rc_uid=userId123&rc_token=token123", "avatar url is valid")
143149
}
144150

145151
func testAvatarURLInvalid() {

0 commit comments

Comments
 (0)