Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: log push notification status #102

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Core/Core/Analytics/CoreAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ public enum AnalyticsEvent: String {
case discussionFollowToggle = "Dicussion:Post Follow Toggle"
case discussionLikeToggle = "Discussion:Like Toggle"
case discussionReportToggle = "Discussion:Report Toggle"
case notificationSettingPermissionStatus = "Notification:Setting Permission Status"

}

Expand Down Expand Up @@ -443,6 +444,7 @@ public enum EventBIValue: String {
case discussionFollowToggle = "edx.bi.app.discussion.follow_toggle"
case discussionLikeToggle = "edx.bi.app.discussion.like_toggle"
case discussionReportToggle = "edx.bi.app.discussion.report_toggle"
case notificationSettingPermissionStatus = "edx.bi.app.notification.permission_settings.status"
}

public struct EventParamKey {
Expand Down Expand Up @@ -501,6 +503,7 @@ public struct EventParamKey {
public static let like = "like"
public static let report = "report"
public static let discussionType = "discussion_type"
public static let status = "status"
}

public struct EventCategory {
Expand Down
10 changes: 10 additions & 0 deletions OpenEdX/Managers/AnalyticsManager/AnalyticsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ class AnalyticsManager: AuthorizationAnalytics,
trackScreenEvent(.mainDashboardProgramsClicked, biValue: .mainDashboardProgramsClicked)
}

public func notificationPermissionStatus(status: String) {
trackEvent(
.notificationSettingPermissionStatus,
biValue: .notificationSettingPermissionStatus,
parameters: [
EventParamKey.status: status
]
)
}

// MARK: Discovery

public func discoverySearchBarClicked() {
Expand Down
2 changes: 2 additions & 0 deletions OpenEdX/Managers/AnalyticsManager/MainScreenAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public protocol MainScreenAnalytics {
func mainProgramsTabClicked()
func mainCoursesClicked()
func mainProgramsClicked()
func notificationPermissionStatus(status: String)
}

#if DEBUG
Expand All @@ -25,5 +26,6 @@ public class MainScreenAnalyticsMock: MainScreenAnalytics {
public func mainProgramsTabClicked() {}
public func mainProgramsClicked() {}
public func mainCoursesClicked() {}
public func notificationPermissionStatus(status: String) {}
}
#endif
11 changes: 11 additions & 0 deletions OpenEdX/View/MainScreenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Core
import Profile
import Combine
import Authorization
import UserNotifications

final class MainScreenViewModel: ObservableObject {

Expand All @@ -35,6 +36,16 @@ final class MainScreenViewModel: ObservableObject {
self.profileInteractor = profileInteractor
self.sourceScreen = sourceScreen
addObservers()

UNUserNotificationCenter.current().getNotificationSettings(completionHandler: { (settings) in
if settings.authorizationStatus == .notDetermined {
analytics.notificationPermissionStatus(status: "notDetermined")
} else if settings.authorizationStatus == .denied {
analytics.notificationPermissionStatus(status: "denied")
} else if settings.authorizationStatus == .authorized {
analytics.notificationPermissionStatus(status: "authorized")
}
})
}

private func addObservers() {
Expand Down
Loading