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
7 changes: 7 additions & 0 deletions WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ import Foundation
case freeToPaidPlansDashboardCardMenuTapped
case freeToPaidPlansDashboardCardHidden

// Widgets
case widgetsLoadedOnApplicationOpened

/// A String that represents the event
var value: String {
switch self {
Expand Down Expand Up @@ -1388,6 +1391,10 @@ import Foundation
case .freeToPaidPlansDashboardCardMenuTapped:
return "free_to_paid_plan_dashboard_card_menu_tapped"

// Widgets
case .widgetsLoadedOnApplicationOpened:
return "widgets_loaded_on_application_opened"

} // END OF SWITCH
}

Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Utility/Analytics/WPAppAnalytics.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ - (void)applicationDidBecomeActive:(NSNotification*)notification
[self incrementSessionCount];
[self trackApplicationOpened];
[SearchAdsAttribution.instance requestDetails];
[WidgetAnalytics trackLoadedWidgetsOnApplicationOpened];
}

- (void)applicationDidEnterBackground:(NSNotification*)notification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ struct LockScreenStatsWidget<T: LockScreenStatsWidgetConfig>: Widget {
placeholderContent: config.placeholderContent
)
) { (entry: LockScreenStatsWidgetEntry) -> LockScreenStatsWidgetsView in
defer {
tracks.trackWidgetUpdatedIfNeeded(entry: entry,
widgetKind: config.kind)
}
return LockScreenStatsWidgetsView(
timelineEntry: entry,
viewProvider: config.viewProvider
Expand Down
120 changes: 0 additions & 120 deletions WordPress/JetpackStatsWidgets/Tracks/Tracks+StatsWidgets.swift

This file was deleted.

68 changes: 68 additions & 0 deletions WordPress/JetpackStatsWidgets/Tracks/WidgetAnalytics.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import Foundation
import WidgetKit

@objcMembers class WidgetAnalytics: NSObject {
static func trackLoadedWidgetsOnApplicationOpened() {
guard AppConfiguration.isJetpack else { return }

WidgetCenter.shared.getCurrentConfigurations { result in
let properties = self.properties(from: result)
WPAnalytics.track(.widgetsLoadedOnApplicationOpened, properties: properties)
}
}

private static func properties(from widgetInfo: Result<[WidgetInfo], Error>) -> [String: String] {
guard let installedWidgets = try? widgetInfo.get() else {
return [:]
}

let widgetAnalyticNames: [String] = installedWidgets.map { widgetInfo in
guard let eventKind = AppConfiguration.Widget.Stats.Kind(rawValue: widgetInfo.kind) else {
DDLogWarn("⚠️ Make sure the widget: \(widgetInfo.kind), has the correct kind.")
return "\(widgetInfo.kind)_\(widgetInfo.family)"
}
return "\(Events.eventPrefix(for: eventKind).rawValue)_\(widgetInfo.family.description.lowercased())"
}

let dict = Dictionary(uniqueKeysWithValues: widgetAnalyticNames.map { name in
return (name, "true")
})

return dict
}

private enum Events: String {
case homeTodayWidget = "widget_today_home"
case homeAllTimeWidget = "widget_all_time_home"
case homeThisWeekWidget = "widget_this_week_home"
case lockScreenTodayViewsWidget = "widget_today_views_lockscreen"
case lockScreenTodayLikesCommentsWidget = "widget_today_likes_comments_lockscreen"
case lockScreenTodayViewsVisitorsWidget = "widget_today_views_visitors_lockscreen"
case lockScreenAllTimeViewsWidget = "widget_all_time_views_lockscreen"
case lockScreenAllTimeViewsVisitorsWidget = "widget_all_time_views_visitors_lockscreen"
case lockScreenAllTimePostsBestViewsWidget = "widget_all_time_posts_best_views_lockscreen"

static func eventPrefix(for widgetKind: AppConfiguration.Widget.Stats.Kind) -> Events {
switch widgetKind {
case .homeToday:
return .homeTodayWidget
case .homeAllTime:
return .homeAllTimeWidget
case .homeThisWeek:
return .homeThisWeekWidget
case .lockScreenTodayViews:
return .lockScreenTodayViewsWidget
case .lockScreenTodayLikesComments:
return .lockScreenTodayLikesCommentsWidget
case .lockScreenTodayViewsVisitors:
return .lockScreenTodayViewsVisitorsWidget
case .lockScreenAllTimeViews:
return .lockScreenAllTimeViewsWidget
case .lockScreenAllTimeViewsVisitors:
return .lockScreenAllTimeViewsVisitorsWidget
case .lockScreenAllTimePostsBestViews:
return .lockScreenAllTimePostsBestViewsWidget
}
}
}
}
6 changes: 0 additions & 6 deletions WordPress/JetpackStatsWidgets/Widgets/HomeWidgetAllTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ struct HomeWidgetAllTime: Widget {
placeholderContent: placeholderContent,
widgetKind: .allTime)
) { (entry: StatsWidgetEntry) -> StatsWidgetsView in

defer {
tracks.trackWidgetUpdatedIfNeeded(entry: entry,
widgetKind: AppConfiguration.Widget.Stats.Kind.homeAllTime)
}

return StatsWidgetsView(timelineEntry: entry)
}
.configurationDisplayName(LocalizableStrings.allTimeWidgetTitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ struct HomeWidgetThisWeek: Widget {
placeholderContent: placeholderContent,
widgetKind: .thisWeek)
) { (entry: StatsWidgetEntry) -> StatsWidgetsView in

defer {
tracks.trackWidgetUpdatedIfNeeded(entry: entry,
widgetKind: AppConfiguration.Widget.Stats.Kind.homeThisWeek)
}

return StatsWidgetsView(timelineEntry: entry)
}
.configurationDisplayName(LocalizableStrings.thisWeekWidgetTitle)
Expand Down
6 changes: 0 additions & 6 deletions WordPress/JetpackStatsWidgets/Widgets/HomeWidgetToday.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ struct HomeWidgetToday: Widget {
placeholderContent: placeholderContent,
widgetKind: .today)
) { (entry: StatsWidgetEntry) -> StatsWidgetsView in

defer {
tracks.trackWidgetUpdatedIfNeeded(entry: entry,
widgetKind: AppConfiguration.Widget.Stats.Kind.homeToday)
}

return StatsWidgetsView(timelineEntry: entry)
}
.configurationDisplayName(LocalizableStrings.todayWidgetTitle)
Expand Down
10 changes: 6 additions & 4 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
0107E0D028F97D5000DE87DB /* HomeWidgetThisWeek.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F8B138E25D09AA5004FAC0A /* HomeWidgetThisWeek.swift */; };
0107E0D128F97D5000DE87DB /* SingleStatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F5689EF254209790048A9E4 /* SingleStatView.swift */; };
0107E0D228F97D5000DE87DB /* UnconfiguredView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FAA18CB25797B85002B1911 /* UnconfiguredView.swift */; };
0107E0D328F97D5000DE87DB /* Tracks+StatsWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98390AC2254C984700868F0A /* Tracks+StatsWidgets.swift */; };
0107E0D428F97D5000DE87DB /* HomeWidgetData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F6DA04025646F96002AB88F /* HomeWidgetData.swift */; };
0107E0D528F97D5000DE87DB /* HomeWidgetTodayData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FB34ACA25672A90001A74A6 /* HomeWidgetTodayData.swift */; };
0107E0D628F97D5000DE87DB /* AllTimeWidgetStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BFF57D23984344008A1DCB /* AllTimeWidgetStats.swift */; };
Expand Down Expand Up @@ -195,6 +194,8 @@
019D69A12A5EBF47003B676D /* WordPressAuthenticatorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 019D699F2A5EBF47003B676D /* WordPressAuthenticatorProtocol.swift */; };
01A8508B2A8A126400BD8A97 /* support_chat_widget.css in Resources */ = {isa = PBXBuildFile; fileRef = 01A8508A2A8A126400BD8A97 /* support_chat_widget.css */; };
01A8508C2A8A126400BD8A97 /* support_chat_widget.css in Resources */ = {isa = PBXBuildFile; fileRef = 01A8508A2A8A126400BD8A97 /* support_chat_widget.css */; };
01ABF1702AD578B3004331BD /* WidgetAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01ABF16F2AD578B3004331BD /* WidgetAnalytics.swift */; };
01ABF1712AD578B3004331BD /* WidgetAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01ABF16F2AD578B3004331BD /* WidgetAnalytics.swift */; };
01CE5007290A889F00A9C2E0 /* TracksConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01CE5006290A889F00A9C2E0 /* TracksConfiguration.swift */; };
01CE5008290A88BD00A9C2E0 /* TracksConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01CE5006290A889F00A9C2E0 /* TracksConfiguration.swift */; };
01CE500E290A88C100A9C2E0 /* TracksConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01CE5006290A889F00A9C2E0 /* TracksConfiguration.swift */; };
Expand Down Expand Up @@ -5864,6 +5865,7 @@
019D699D2A5EA963003B676D /* RootViewCoordinatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewCoordinatorTests.swift; sourceTree = "<group>"; };
019D699F2A5EBF47003B676D /* WordPressAuthenticatorProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorProtocol.swift; sourceTree = "<group>"; };
01A8508A2A8A126400BD8A97 /* support_chat_widget.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = support_chat_widget.css; sourceTree = "<group>"; };
01ABF16F2AD578B3004331BD /* WidgetAnalytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetAnalytics.swift; sourceTree = "<group>"; };
01CE5006290A889F00A9C2E0 /* TracksConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TracksConfiguration.swift; sourceTree = "<group>"; };
01CE5010290A890300A9C2E0 /* TracksConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TracksConfiguration.swift; sourceTree = "<group>"; };
01D2FF5D2AA733690038E040 /* LockScreenFieldView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenFieldView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7765,7 +7767,6 @@
983002A722FA05D600F03DBB /* InsightsManagementViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsightsManagementViewController.swift; sourceTree = "<group>"; };
9833A29B257AE7CF006B8234 /* WordPress 105.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "WordPress 105.xcdatamodel"; sourceTree = "<group>"; };
9835F16D25E492EE002EFF23 /* CommentsList.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = CommentsList.storyboard; sourceTree = "<group>"; };
98390AC2254C984700868F0A /* Tracks+StatsWidgets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Tracks+StatsWidgets.swift"; sourceTree = "<group>"; };
983DBBA822125DD300753988 /* StatsTableFooter.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = StatsTableFooter.xib; sourceTree = "<group>"; };
983DBBA922125DD300753988 /* StatsTableFooter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatsTableFooter.swift; sourceTree = "<group>"; };
98458CB721A39D350025D232 /* StatsNoDataRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsNoDataRow.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -11668,7 +11669,7 @@
3FA59DCC2582E53F0073772F /* Tracks */ = {
isa = PBXGroup;
children = (
98390AC2254C984700868F0A /* Tracks+StatsWidgets.swift */,
01ABF16F2AD578B3004331BD /* WidgetAnalytics.swift */,
);
path = Tracks;
sourceTree = "<group>";
Expand Down Expand Up @@ -20869,7 +20870,6 @@
0188FE4C2AA62F800093EDA5 /* LockScreenTodayLikesCommentsStatWidgetConfig.swift in Sources */,
0107E0D228F97D5000DE87DB /* UnconfiguredView.swift in Sources */,
0107E1852900059300DE87DB /* LocalizationConfiguration.swift in Sources */,
0107E0D328F97D5000DE87DB /* Tracks+StatsWidgets.swift in Sources */,
0107E0D428F97D5000DE87DB /* HomeWidgetData.swift in Sources */,
01D2FF652AA77F790038E040 /* LockScreenTodayViewsVisitorsStatWidgetConfig.swift in Sources */,
0107E0D528F97D5000DE87DB /* HomeWidgetTodayData.swift in Sources */,
Expand Down Expand Up @@ -21813,6 +21813,7 @@
570265152298921800F2214C /* PostListTableViewHandler.swift in Sources */,
B5969E2220A49E86005E9DF1 /* UIAlertController+Helpers.swift in Sources */,
9A4E61F821A2C3BC0017A925 /* RevisionDiff+CoreData.swift in Sources */,
01ABF1702AD578B3004331BD /* WidgetAnalytics.swift in Sources */,
7E7947AB210BAC5E005BB851 /* NotificationCommentRange.swift in Sources */,
FE25C235271F23000084E1DB /* ReaderCommentsNotificationSheetViewController.swift in Sources */,
C32A6A2C2832BF02002E9394 /* SiteDesignCategoryThumbnailSize.swift in Sources */,
Expand Down Expand Up @@ -24408,6 +24409,7 @@
FABB22CB2602FC2C00C8785C /* FilterBarView.swift in Sources */,
98B88453261E4E09007ED7F8 /* LikeUserTableViewCell.swift in Sources */,
FABB22CC2602FC2C00C8785C /* BlogToBlogMigration_61_62.swift in Sources */,
01ABF1712AD578B3004331BD /* WidgetAnalytics.swift in Sources */,
FABB22CD2602FC2C00C8785C /* WebKitViewController.swift in Sources */,
FABB22CE2602FC2C00C8785C /* AnnouncementsDataSource.swift in Sources */,
FABB22CF2602FC2C00C8785C /* AssembledSiteView.swift in Sources */,
Expand Down