Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Implementing a New Diagnostic Tool for Slack Notifications

Implementing a New Diagnostic Tool for Slack Notifications

Kaya Thomas

June 05, 2018
Tweet

More Decks by Kaya Thomas

Other Decks in Programming

Transcript

  1. Agenda • Notifications pitfalls • Idea behind creating the diagnostic

    tool • What does the tool do? • Building the tool • Takeaways
  2. • Notifications pitfalls • Idea behind creating the diagnostic tool

    • What does the tool do? • Building the tool • Takeaways Agenda
  3. • Notifications pitfalls • Idea behind creating the diagnostic tool

    • What does the tool do? • Building the tool • Takeaways Agenda
  4. What could stop a user from receiving a notification? Slack

    notification preferences System notification settings Invalid or old push token Bad network connection
  5. 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.
  6. 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.
  7. • Notifications pitfalls • Idea behind creating the diagnostic tool

    • What does the tool do? • Building the tool • Takeaways Agenda
  8. • Notifications pitfalls • Idea behind creating the diagnostic tool

    • What does the tool do? • Building the tool • Takeaways Agenda
  9. 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.”
  10. Reactive programming Reactive programming is programming with asynchronous data streams.

    A stream (an observable) is a sequence of events which a subscriber listens to.
  11. 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)
  12. 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
  13. 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
  14. Push token refreshing UIApplication.shared.registerForRemoteNotifications() application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)

    application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) NSNotificationCenter Success! Failed!
  15. 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
  16. 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