File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed
Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,15 @@ struct LocalNotification {
2727 /// The action type in a local notification.
2828 enum Action : String {
2929 case contactSupport
30+ case loginWithWPCom
3031
3132 /// The title of the action in a local notification.
3233 var title : String {
3334 switch self {
3435 case . contactSupport:
3536 return NSLocalizedString ( " Contact support " , comment: " Local notification action to contact support. " )
37+ case . loginWithWPCom:
38+ return NSLocalizedString ( " Login with WordPress.com " , comment: " Local notification action to log in with WordPress.com. " )
3639 }
3740 }
3841 }
@@ -45,7 +48,7 @@ extension LocalNotification {
4548 self . init ( title: Localization . errorLoggingInTitle,
4649 body: Localization . errorLoggingInBody,
4750 scenario: . loginSiteAddressError,
48- actions: . init( category: . loginError, actions: [ . contactSupport] ) )
51+ actions: . init( category: . loginError, actions: [ . contactSupport, . loginWithWPCom ] ) )
4952 }
5053 }
5154}
Original file line number Diff line number Diff line change 11import Combine
22import Experiments
33import UIKit
4+ import WordPressAuthenticator
45import Yosemite
56import class AutomatticTracks. CrashLogging
67
@@ -253,6 +254,17 @@ private extension AppCoordinator {
253254 " action " : " contact_support " ,
254255 " type " : response. notification. request. identifier
255256 ] )
257+ case LocalNotification . Action. loginWithWPCom. rawValue:
258+ guard let loginNavigationController = window. rootViewController as? LoginNavigationController ,
259+ let viewController = loginNavigationController. topViewController else {
260+ return
261+ }
262+ let command = NavigateToEnterAccount ( )
263+ command. execute ( from: viewController)
264+ analytics. track ( . loginLocalNotificationTapped, withProperties: [
265+ " action " : " login_with_wpcom " ,
266+ " type " : response. notification. request. identifier
267+ ] )
256268 case UNNotificationDefaultActionIdentifier:
257269 // Triggered when the user taps on the notification itself instead of one of the actions.
258270 switch response. notification. request. identifier {
Original file line number Diff line number Diff line change @@ -230,6 +230,30 @@ final class AppCoordinatorTests: XCTestCase {
230230 XCTAssertEqual ( typePropertyValue, " site_address_error " )
231231 }
232232
233+ func test_loginLocalNotificationTapped_is_tracked_after_notification_loginWithWPCom_action( ) throws {
234+ // Given
235+ let analytics = MockAnalyticsProvider ( )
236+ let pushNotesManager = MockPushNotificationsManager ( )
237+ let appCoordinator = makeCoordinator ( window: window,
238+ stores: stores,
239+ authenticationManager: authenticationManager,
240+ analytics: WooAnalytics ( analyticsProvider: analytics) ,
241+ pushNotesManager: pushNotesManager)
242+ appCoordinator. start ( )
243+
244+ // When
245+ let response = try XCTUnwrap ( MockNotificationResponse ( actionIdentifier: LocalNotification . Action. loginWithWPCom. rawValue,
246+ requestIdentifier: LocalNotification . Scenario. loginSiteAddressError. rawValue) )
247+ pushNotesManager. sendLocalNotificationResponse ( response)
248+
249+ // Then
250+ XCTAssertEqual ( analytics. receivedEvents, [ WooAnalyticsStat . loginLocalNotificationTapped. rawValue] )
251+ let actionPropertyValue = try XCTUnwrap ( analytics. receivedProperties. first ? [ " action " ] as? String )
252+ XCTAssertEqual ( actionPropertyValue, " login_with_wpcom " )
253+ let typePropertyValue = try XCTUnwrap ( analytics. receivedProperties. first ? [ " type " ] as? String )
254+ XCTAssertEqual ( typePropertyValue, " site_address_error " )
255+ }
256+
233257 func test_loginLocalNotificationTapped_is_tracked_after_notification_tap_action( ) throws {
234258 // Given
235259 let analytics = MockAnalyticsProvider ( )
You can’t perform that action at this time.
0 commit comments