Skip to content

Commit e555fad

Browse files
committed
add local_notification_displayed case
1 parent ce12416 commit e555fad

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Modules/Sources/WooFoundationCore/Analytics/WooAnalyticsStat.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public enum WooAnalyticsStat: String {
115115
case localNotificationTapped = "local_notification_tapped"
116116
case localNotificationDismissed = "local_notification_dismissed"
117117
case localNotificationScheduled = "local_notification_scheduled"
118+
case localNotificationDisplayed = "local_notification_displayed"
118119
case localNotificationCanceled = "local_notification_canceled"
119120

120121
// MARK: Dashboard View Events

WooCommerce/Classes/Analytics/WooAnalyticsEvent+LocalNotification.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ extension WooAnalyticsEvent {
2323
properties: getTracksProperties(type: type, userInfo: userInfo))
2424
}
2525

26+
static func displayed(type: String, userInfo: [AnyHashable: Any]) -> WooAnalyticsEvent {
27+
WooAnalyticsEvent(statName: .localNotificationDisplayed,
28+
properties: getTracksProperties(type: type, userInfo: userInfo))
29+
}
30+
2631
static func canceled(type: String, userInfo: [AnyHashable: Any]) -> WooAnalyticsEvent {
2732
WooAnalyticsEvent(statName: .localNotificationCanceled,
2833
properties: getTracksProperties(type: type, userInfo: userInfo))

WooCommerce/Classes/Notifications/PushNotificationsManager.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ extension PushNotificationsManager {
264264
// Check if this is a local notification
265265
if !content.isRemoteNotification {
266266
// Display local notifications with banner and sound when app is in foreground
267+
let identifier = notification.request.identifier
268+
analytics.track(event: .LocalNotification.displayed(type: LocalNotification.Scenario.identifierForAnalytics(identifier),
269+
userInfo: content.userInfo))
267270
return [.banner, .sound, .list]
268271
}
269272
}
@@ -284,7 +287,7 @@ extension PushNotificationsManager {
284287
guard let self = self else { return }
285288
self.presentDetails(for: foregroundNotification)
286289
self.foregroundNotificationsToViewSubject.send(foregroundNotification)
287-
self.analytics.track(.viewInAppPushNotificationPressed,
290+
self.analytics.track(.viewInAppPushNotificationPressed, //
288291
withProperties: [AnalyticKey.type: foregroundNotification.kind.rawValue])
289292
}
290293

0 commit comments

Comments
 (0)