Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions WooCommerce/Classes/Analytics/WooAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,8 @@ extension WooAnalyticsEvent {
enum AnalyticsHub {
enum Keys: String {
case option
case calendar
case timezone
}

/// Tracks when the "See more" button is tapped in My Store, to open the Analytics Hub.
Expand All @@ -1799,5 +1801,14 @@ extension WooAnalyticsEvent {
static func dateRangeOptionSelected(_ option: String) -> WooAnalyticsEvent {
WooAnalyticsEvent(statName: .analyticsHubDateRangeOptionSelected, properties: [Keys.option.rawValue: option])
}

/// Tracks when the date range selection fails, due to an error generating the date range from the selection.
/// Includes the current device calendar and timezone, for debugging the failure.
///
static func dateRangeSelectionFailed(for option: AnalyticsHubTimeRangeSelection.SelectionType) -> WooAnalyticsEvent {
WooAnalyticsEvent(statName: .analyticsHubDateRangeSelectionFailed, properties: [Keys.option.rawValue: option.rawValue,
Keys.calendar.rawValue: Locale.current.calendar.debugDescription,
Keys.timezone.rawValue: TimeZone.current.debugDescription])
}
}
}
1 change: 1 addition & 0 deletions WooCommerce/Classes/Analytics/WooAnalyticsStat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public enum WooAnalyticsStat: String {
//
case analyticsHubDateRangeButtonTapped = "analytics_hub_date_range_button_tapped"
case analyticsHubDateRangeOptionSelected = "analytics_hub_date_range_option_selected"
case analyticsHubDateRangeSelectionFailed = "analytics_hub_date_range_selection_failed"

// MARK: Products Onboarding Events
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ final class AnalyticsHubViewModel: ObservableObject {
try await retrieveOrderStats()
} catch is AnalyticsHubTimeRangeSelection.TimeRangeGeneratorError {
dismissNotice = Notice(title: Localization.timeRangeGeneratorError, feedbackType: .error)
ServiceLocator.analytics.track(event: .AnalyticsHub.dateRangeSelectionFailed(for: timeRangeSelectionType))
DDLogWarn("⚠️ Error selecting analytics time range: \(timeRangeSelectionType.description)")
} catch {
switchToErrorState()
Expand Down