Reviews
For meCreated
Refactor notification model and capture parse failures
☑ Ready for review⑂ 1h
Centralize driver app startup and session
☑ Ready for review⑂ 1d
Remove duplicate TLS verification failure
⊗ Changes requested⑂ 1h
Add authenticated API endpoint to retrieve
⊗ Checks failed⑂ 4h
Refactor trip summary details into view
☑ Approved⑂ 2h
Add driver signup API endpoint
☑ Approved⑂ 1d
Refactor notification model and capture parse failures
☑ Ready for review⑂ 1h
Centralize driver app startup and session
☑ Ready for review⑂ 1d
Remove duplicate TLS verification failure
⊗ Changes requested⑂ 1h
Add authenticated API endpoint to retrieve
⊗ Checks failed⑂ 4h
Refactor trip summary details into view
☑ Approved⑂ 2h
Add driver signup API endpoint
☑ Approved⑂ 1d
◉ DRIVE-882 › ⑂ Refactor notification model and capture parse failures +378 -149
ActivityGuideDiff
☷ Files 16  ⌁ Commits 6
⌁ NotificationCenter.swift driver/ios/DriverApp/Services/Notifications/+41 -52
26 self.inbox = inbox
27}
28
29/// Records a freshly-received notification (push or in-app delivery).
30/// Does not navigate — handleOpen covers user interest.
31func handleReceived(payload: [AnyHashable: Any], source: DriverNotification.Source) {
32 let notification = NotificationParser.parse(payload: payload, source: source)
33 let result = NotificationParser.parse(payload: payload, source: source)
34 analytics.received(notification)
35 inbox.store(notification)
36}
37
38/// Records that the user opened a notification and emits its route.
39@discardableResult
40func handleOpen(payload: [AnyHashable: Any], source: DriverNotification.Source) {
41 let notification = NotificationParser.parse(payload: payload, source: source)
42 let result = NotificationParser.parse(payload: payload, source: source)
43 guard case .success(let notification) = result else { return }
44 analytics.opened(notification)
45 inbox.store(notification)
46 return notification.route
47}
48
49/// Stash a result discovered during cold-start for use after app launch.
50func bufferColdStart(payload: [AnyHashable: Any], source: DriverNotification.Source) {
51 let result = NotificationParser.parse(payload: payload, source: source)
52 let notification = result.notification
53 analytics.received(notification)
54 reportFailure(result)
55 inbox.store(notification)
56 pendingColdStart = notification.route
57}
58
59private func reportFailure(_ result: DriverNotificationParseResult) {
60 if case .failure(let notification, let failure) = result {
61 analytics.routingFailed(notification, failure: failure)
62 }
63}
64
65func consumePendingColdStart() -> DriverNotificationRoute? {
66 defer { pendingColdStart = nil }
67 return pendingColdStart
68}
69}
⌁ NotificationCenter.swift driver/ios/DriverApp/Services/Notifications/+41 -52
26 self.inbox = inbox
27}
28
29/// Records a freshly-received notification (push or in-app delivery).
30/// Does not navigate — handleOpen covers user interest.
31func handleReceived(payload: [AnyHashable: Any], source: DriverNotification.Source) {
32 let notification = NotificationParser.parse(payload: payload, source: source)
33 let result = NotificationParser.parse(payload: payload, source: source)
34 analytics.received(notification)
35 inbox.store(notification)
36}
37
38/// Records that the user opened a notification and emits its route.
39@discardableResult
40func handleOpen(payload: [AnyHashable: Any], source: DriverNotification.Source) {
41 let notification = NotificationParser.parse(payload: payload, source: source)
42 let result = NotificationParser.parse(payload: payload, source: source)
43 guard case .success(let notification) = result else { return }
44 analytics.opened(notification)
45 inbox.store(notification)
46 return notification.route
47}
48
49/// Stash a result discovered during cold-start for use after app launch.
50func bufferColdStart(payload: [AnyHashable: Any], source: DriverNotification.Source) {
51 let result = NotificationParser.parse(payload: payload, source: source)
52 let notification = result.notification
53 analytics.received(notification)
54 reportFailure(result)
55 inbox.store(notification)
56 pendingColdStart = notification.route
57}
58
59private func reportFailure(_ result: DriverNotificationParseResult) {
60 if case .failure(let notification, let failure) = result {
61 analytics.routingFailed(notification, failure: failure)
62 }
63}
64
65func consumePendingColdStart() -> DriverNotificationRoute? {
66 defer { pendingColdStart = nil }
67 return pendingColdStart
68}
69}
◉ DRIVE-882 › ⑂ Refactor notification model and capture parse failures +378 -149
ActivityGuideDiff

Refactor notification model and capture parse failures

brian · rideshare#1557

◉ DRIVE-882 › ⑂ Refactor notification model and capture parse failures +378 -149
ActivityGuideDiff
● brian · rideshare#1557 · main ← brian/drive-882-547d
01 / 03

Shared Notification Model

Separating category, route, and parse-result concepts keeps the driver notification shape consistent across Android and iOS. The category types now own default copy, while the parse result carries either a usable notification or the failure that should be reported.

⌁ DriverNotification.ktdriver/common/notifications/+41 -52
⌁ NotificationCategory.ktdriver/common/notifications/+57
⌁ DriverNotificationRoute.ktdriver/common/notifications/+38
⌁ DriverNotificationParseResult.ktdriver/common/notifications/+20
⌁ NotificationParseFailure.ktdriver/common/notifications/+41
⌁ DriverNotification.swiftdriver/common/notifications/+42
⌁ NotificationCategory.swiftdriver/common/notifications/+28
⌁ DriverNotification.kt driver/ios/DriverApp/Services/Notifications/+41 -52
1package com.rideshare.driver.common.notifications
2
3import java.time.Instant
4
5/**
6 * Standardized notification model for the Driver app.
7 *
8 * Push payloads, in-app events, and deep links are all parsed into
9 * DriverNotification so routing, read-state updates, and analytics use a
10 * consistent shape regardless of the surface the notification arrived on.
11 */
12data class DriverNotification(
13 val id: String,
14 val category: Category,
15 val category: NotificationCategory,
16 val title: String,
17 val body: String,
18 val route: DriverNotificationRoute,
19 val receivedAt: Instant,
20 val source: Source,
21 val raw: Map<String, String>,
22 ) {
23 enum class Category(val value: String) {
24 TRIP_REQUEST("trip_request"),
25 TRIP_UPDATE("trip_update"),
26 EARNINGS("earnings"),
27 UNKNOWN("unknown");
28 }
29 enum class Source(val value: String) {
30 PUSH("push"),
31 IN_APP("in_app"),
32 DEEP_LINK("deep_link"),
33 }
34}
⌁ NotificationCategory.kt driver/ios/DriverApp/Services/Notifications/+41 -52
1enum class NotificationCategory(
2 val rawValue: String,
3 val defaultTitle: String,
4 val defaultBody: String,
5) {
6 TripRequest(
7 rawValue = "trip_request",
8 defaultTitle = "New trip request",
9 defaultBody = "Tap to review the request.",
10 ),
11 TripUpdate(
12 rawValue = "trip_update",
13 defaultTitle = "Trip update",
14 defaultBody = "You have a trip update.",
15 ),
16 Earnings(
17 rawValue = "earnings",
18 defaultTitle = "Earnings",
19 defaultBody = "Your earnings were updated.",
20 ),
21 Delivery(
22 rawValue = "delivery",
23 defaultTitle = "Delivery update",
24 defaultBody = "You have a delivery to manage.",
25 );
26
27 companion object {
28 fun from(rawValue: String?): NotificationCategory? {
29 return entries.firstOrNull { it.rawValue == rawValue }
30 }
31 }
32}
02 / 03

Parser Failure Capture

The parser now returns success or failure explicitly, while still producing a notification that can be stored, shown, and routed. Missing category, missing body copy, missing route identifiers, and malformed external links are detected before the notification leaves parsing.

⌁ NotificationParser.ktdriver/common/notifications/+41 -52
⌁ NotificationParser.swiftdriver/common/notifications/+57
⌁ NotificationParser.kt driver/ios/DriverApp/Services/Notifications/+41 -52
1package com.rideshare.driver.common.notifications
2
3import java.net.URI
4import java.net.URISyntaxException
5import java.time.Instant
6import java.util.UUID
7
8/**
9 * Parses raw notification payloads from any surface into DriverNotification.
10 * All entry points route through parse so categorization and routing are
11 * derived in one place.
12 */
13object NotificationParser {
14 fun parse(payload: Map<String, String>, source: DriverNotification.Source) {
15 fun parse(payload: Map<String, String>, source: DriverNotification.Source) {
16 val id = payload["id"] ?: UUID.randomUUID().toString()
17
18 val category = DriverNotification.Category.from(payload["category"])
19 val title = payload["title"] ?: defaultTitle(category)
20 val body = payload["body"]
21 val resolvedCategory = NotificationCategory.from(payload["category"])
22 val category = resolvedCategory ?: NotificationCategory.Unknown
23 val title = payload["title"] ?: category.defaultTitle
24 val body = payload["body"] ?: category.defaultBody
25
26 val notification = DriverNotification(
27 id = id, category = category, title = title, body = body,
28 source = source, receivedAt = Instant.now(), raw = payload,
29 )
30 val failure: NotificationParseFailure? = when {
31 resolvedCategory == null -> NotificationParseFailure.MissingCategory
32 !hasBodyCopy -> NotificationParseFailure.MissingBody
33 else -> null
34 }
35 return if (failure == null) {
36 DriverNotificationParseResult.Success(notification)
37 } else {
38 DriverNotificationParseResult.Failure(notification, failure)
39 }
40 }
41}
⌁ NotificationParser.swift driver/ios/DriverApp/Services/Notifications/+41 -52
26 self.inbox = inbox
27}
28
29/// Records a freshly-received notification (push or in-app delivery).
30/// Does not navigate — handleOpen covers user interest.
31func handleReceived(payload: [AnyHashable: Any], source: DriverNotification.Source) {
32 let notification = NotificationParser.parse(payload: payload, source: source)
33 let result = NotificationParser.parse(payload: payload, source: source)
34 analytics.received(notification)
35 inbox.store(notification)
36}
37
38/// Records that the user opened a notification and emits its route.
39@discardableResult
40func handleOpen(payload: [AnyHashable: Any], source: DriverNotification.Source) {
41 let notification = NotificationParser.parse(payload: payload, source: source)
42 let result = NotificationParser.parse(payload: payload, source: source)
43 guard case .success(let notification) = result else { return }
44 analytics.opened(notification)
45 inbox.store(notification)
46 return notification.route
47}
48
49/// Stash a result discovered during cold-start for use after app launch.
50func bufferColdStart(payload: [AnyHashable: Any], source: DriverNotification.Source) {
51 let result = NotificationParser.parse(payload: payload, source: source)
52 let notification = result.notification
53 analytics.received(notification)
54 reportFailure(result)
55 inbox.store(notification)
56 pendingColdStart = notification.route
57}
58
59private func reportFailure(_ result: DriverNotificationParseResult) {
60 if case .failure(let notification, let failure) = result {
61 analytics.routingFailed(notification, failure: failure)
62 }
63}
64
65func consumePendingColdStart() -> DriverNotificationRoute? {
66 defer { pendingColdStart = nil }
67 return pendingColdStart
68}
69}
03 / 03

Analytics Reporting

Parse failures are reported from received, opened, and cold-start paths so malformed payloads are visible no matter how a driver opens the app. Analytics now receives the structured failure object, preserving both the status code and the placeholder message planned for later copy updates.

⌁ DriverNotificationCenter.ktdriver/common/notifications/+41 -52
⌁ NotificationAnalytics.ktdriver/common/notifications/+57
⌁ NotificationCenter.swiftdriver/common/notifications/+38
⌁ NotificationAnalytics.swiftdriver/common/notifications/+20
⌁ NotificationCenter.swift driver/ios/DriverApp/Services/Notifications/+41 -52
26 self.inbox = inbox
27}
28
29/// Records a freshly-received notification (push or in-app delivery).
30/// Does not navigate — handleOpen covers user interest.
31func handleReceived(payload: [AnyHashable: Any], source: DriverNotification.Source) {
32 let notification = NotificationParser.parse(payload: payload, source: source)
33 let result = NotificationParser.parse(payload: payload, source: source)
34 analytics.received(notification)
35 inbox.store(notification)
36}
37
38/// Records that the user opened a notification and emits its route.
39@discardableResult
40func handleOpen(payload: [AnyHashable: Any], source: DriverNotification.Source) {
41 let notification = NotificationParser.parse(payload: payload, source: source)
42 let result = NotificationParser.parse(payload: payload, source: source)
43 guard case .success(let notification) = result else { return }
44 analytics.opened(notification)
45 inbox.store(notification)
46 return notification.route
47}
48
49/// Stash a result discovered during cold-start for use after app launch.
50func bufferColdStart(payload: [AnyHashable: Any], source: DriverNotification.Source) {
51 let result = NotificationParser.parse(payload: payload, source: source)
52 let notification = result.notification
53 analytics.received(notification)
54 reportFailure(result)
55 inbox.store(notification)
56 pendingColdStart = notification.route
57}
58
59private func reportFailure(_ result: DriverNotificationParseResult) {
60 if case .failure(let notification, let failure) = result {
61 analytics.routingFailed(notification, failure: failure)
62 }
63}
64
65func consumePendingColdStart() -> DriverNotificationRoute? {
66 defer { pendingColdStart = nil }
67 return pendingColdStart
68}
69}
⌁ NotificationAnalytics.kt driver/ios/DriverApp/Services/Notifications/+41 -52
1/** Reports notification lifecycle events for the Driver app. */
2interface NotificationAnalytics {
3 fun received(notification: DriverNotification)
4 fun opened(notification: DriverNotification)
5 fun routingFailed(notification: DriverNotification, failure: NotificationParseFailure)
6 fun permissionChanged(isAuthorized: Boolean)
7}
8interface NotificationAnalytics {
9 fun received(notification: DriverNotification)
10 fun opened(notification: DriverNotification)
11 fun routingFailed(notification: DriverNotification, failure: NotificationParseFailure)
12}
13
14class DefaultNotificationAnalytics(
15 private val events: NotificationEventLogger,
16 ) : NotificationAnalytics {
17 override fun received(notification: DriverNotification) {
18 log("notification_received", notification)
19 }
20
21 override fun opened(notification: DriverNotification) {
22 log("notification_opened", notification)
23 }
24
25 override fun routingFailed(notification: DriverNotification, failure: String) {
26 override fun routingFailed(notification: DriverNotification, failure: NotificationParseFailure) {
27 events.track("notification_routing_failed", mapOf(
28 "notification_id" to notification.id,
29 "notification_category" to notification.category.rawValue,
30 "failure" to failure.toString(),
31 ))
32 }
33}
♧ ⑂
➤
☷
⌁ NotificationCenter.swift driver/ios/DriverApp/Services/Notifications/+41 -52
54func bufferColdStart(payload: [AnyHashable: Any], source: DriverNotification.Source) {
55 let result = NotificationParser.parse(payload: payload, source: source)
56 let notification = result.notification
57 analytics.received(notification)
58 reportFailure(result)
59 inbox.store(notification)
60 pendingColdStart = notification.route
61}
62
63private func reportFailure(_ result: DriverNotificationParseResult) {
64 if case .failure(let notification, let failure) = result {
65 analytics.routingFailed(notification, failure: failure)
66 }
67}
68
69func consumePendingColdStart() -> DriverNotificationRoute? {
70 defer { pendingColdStart = nil }
71 return pendingColdStart
72}
73}
➤
⌁ NotificationCenter.swift · R58
⌁ NotificationCenter.swift driver/ios/DriverApp/Services/Notifications/+41 -52
54func bufferColdStart(payload: [AnyHashable: Any], source: DriverNotification.Source) {
55 let result = NotificationParser.parse(payload: payload, source: source)
56 let notification = result.notification
57 analytics.received(notification)
58 reportFailure(result)
59 inbox.store(notification)
60 pendingColdStart = notification.route
61}
62
63private func reportFailure(_ result: DriverNotificationParseResult) {
64 if case .failure(let notification, let failure) = result {
65 analytics.routingFailed(notification, failure: failure)
66 }
67}
68
69func consumePendingColdStart() -> DriverNotificationRoute? {
70 defer { pendingColdStart = nil }
71 return pendingColdStart
72}
73}
⌁ NotificationCenter.swift · R58 Rename reportFailure to reportParseFailure and update its call sites│
♧ ↑

Renamed the helper to better reflect its purpose and updated 3 call sites.

♧ ↑
⌁ NotificationCenter.swift driver/ios/DriverApp/Services/Notifications/+41 -52
63private func reportFailure(_ result: DriverNotificationParseResult) {
64 if case .failure(let notification, let failure) = result {
65 analytics.routingFailed(notification, failure: failure)
66 }
67}
68
69func consumePendingColdStart() -> DriverNotificationRoute? {
70 defer { pendingColdStart = nil }
71 return pendingColdStart
72}
73}
✓ Approve
Experience the diff
Linear