Share
Embed
Implementing a New Diagnostic Tool for Slack Notifications
Kaya Thomas
June 05, 2018
Transcript
37 slides
-
Agenda • Notifications pitfalls • Idea behind creating the diagnostic
tool • What does the tool do? • Building the tool • Takeaways -
• Notifications pitfalls • Idea behind creating the diagnostic tool
• What does the tool do? • Building the tool • Takeaways Agenda -
• Notifications pitfalls • Idea behind creating the diagnostic tool
• What does the tool do? • Building the tool • Takeaways Agenda -
What could stop a user from receiving a notification? Slack
notification preferences System notification settings Invalid or old push token Bad network connection -
Diagnostic tool to the rescue! Andy Timmons, Backend Eng Andy
read 6 weeks worth of Zendesk tickets for notification issues and classified them all! The research helped us pinpoint a solution: a diagnostic tool focused on in-product education and token refreshing. -
How does in-product education help? We our customer support team.
By making our product easier to use and issues easier to self-diagnose & fix, it helps our CE team and our customers. -
• Notifications pitfalls • Idea behind creating the diagnostic tool
• What does the tool do? • Building the tool • Takeaways Agenda -
• Notifications pitfalls • Idea behind creating the diagnostic tool
• What does the tool do? • Building the tool • Takeaways Agenda -
Building the tool Swift enums + Reactive programming + UIKit
= Modern diagnostic tool -
Swift enums Apple documentation: “An enumeration defines a common type
for a group of related values and enables you to work with those values in a type-safe way within your code.” -
Reactive programming Reactive programming is programming with asynchronous data streams.
A stream (an observable) is a sequence of events which a subscriber listens to. -
Building the tool public enum SLKNotificationDiagnosticState { case notStarted case
running case success case failed } let slackNotificationStateObservable = Observable<SLKNotificationDiagnosticState>(.notStarted) let deviceSettingsStateObservable = Observable<SLKNotificationDiagnosticState>(.notStarted) let tokenStateObservable = Observable<SLKNotificationDiagnosticState>(.notStarted) let testStateObservable = Observable<SLKNotificationDiagnosticState>(.notStarted) -
Slack settings test private func performSlackSettingsCheck() { } guard let
dependencies = self.dependencies, let team = self.team else { return } let isDND = team.isDND || team.isSnoozed let isSlackNotifsOff = dependencies.notificationPrefs.notificationSetting == .nothing slackNotificationStateObservable.value = isDND || isSlackNotifsOff ? .failed : .success guard let dependencies = self.dependencies, let team = self.team else { return } let isDND = team.isDND || team.isSnoozed let isSlackNotifsOff = dependencies.notificationPrefs.notificationSetting == .nothing slackNotificationStateObservable.value = isDND || isSlackNotifsOff ? .failed : .success -
Device settings test private func performDeviceSettingsCheck() { } let center
= UNUserNotificationCenter.current() self.isAlertOffObservable.value = settings.alertSetting == .disabled self.isBadgeOffObservable.value = settings.badgeSetting == .disabled self.isSoundOffObservable.value = settings.soundSetting == .disabled self.deviceSettingsStateObservable.value = self.isAlertOffObservable.value || self.isBadgeOffObservable.value || self.isSoundOffObservable.value ? .failed : .success center.getNotificationSettings { (settings) in } let center = UNUserNotificationCenter.current() center.getNotificationSettings { (settings) in } self.isAlertOffObservable.value = settings.alertSetting == .disabled self.isBadgeOffObservable.value = settings.badgeSetting == .disabled self.isSoundOffObservable.value = settings.soundSetting == .disabled self.deviceSettingsStateObservable.value = self.isAlertOffObservable.value || self.isBadgeOffObservable.value || self.isSoundOffObservable.value ? .failed : .success -
Push token refreshing UIApplication.shared.registerForRemoteNotifications() application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) NSNotificationCenter Success! Failed! -
Sending a test notification ➔ Only call endpoint if alerts
are ON at system level for Slack ➔ Call test notification API endpoint ➔ Wait to receive notification from server from the backend in app delegate ➔ Check in handleForegroundPushWithNotificationPayload and format test notification ➔ If never receive notification from server, test failed -
Takeaways ➔ If your app has a lot of custom
settings ➔ Introduced complexity with dealing with third party services ➔ If your customer support team needs more automation or in product education to reduce repetitive issues When can a diagnostic tool be useful? Resources https://goo.gl/iWvGLo