Skip to content

Commit 676c52a

Browse files
Add: Implement analytics tracking in JP overlay config
1 parent 0690289 commit 676c52a

File tree

4 files changed

+74
-7
lines changed

4 files changed

+74
-7
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import Foundation
2+
import AutomatticTracks
3+
4+
extension JetpackFullscreenOverlayGeneralConfig {
5+
6+
// MARK: Private Enum Decleration
7+
8+
private enum DismissalType: String {
9+
case close, swipe, `continue`
10+
}
11+
12+
// MARK: Static Property Keys
13+
14+
private static let phasePropertyKey = "phase"
15+
private static let sourcePropertyKey = "source"
16+
private static let dismiassalTypePropertyKey = "dismissal_type"
17+
18+
// MARK: Private Computed Property
19+
20+
private var defaultProperties: [String: String] {
21+
return [
22+
Self.phasePropertyKey: phase.rawValue,
23+
Self.sourcePropertyKey: source.rawValue
24+
]
25+
}
26+
27+
// MARK: Analytics Implementation
28+
29+
func trackOverlayDisplayed() {
30+
WPAnalytics.track(.jetpackFullscreenOverlayDisplayed, properties: defaultProperties)
31+
}
32+
33+
func trackLearnMoreTapped() {
34+
WPAnalytics.track(.jetpackFullscreenOverlayLinkTapped, properties: defaultProperties)
35+
}
36+
37+
func trackSwitchButtonTapped() {
38+
WPAnalytics.track(.jetpackFullscreenOverlayButtonTapped, properties: defaultProperties)
39+
}
40+
41+
func trackCloseButtonTapped() {
42+
trackOverlayDismissed(dismissalType: .close)
43+
}
44+
45+
func trackOverlaySwippedDown() {
46+
trackOverlayDismissed(dismissalType: .swipe)
47+
}
48+
49+
func trackContinueButtonTapped() {
50+
trackOverlayDismissed(dismissalType: .continue)
51+
}
52+
53+
// MARK: Helpers
54+
55+
private func trackOverlayDismissed(dismissalType: DismissalType) {
56+
var properties = defaultProperties
57+
properties[Self.dismiassalTypePropertyKey] = dismissalType.rawValue
58+
WPAnalytics.track(.jetpackFullscreenOverlayDismissed, properties: properties)
59+
}
60+
}

WordPress/Classes/ViewRelated/Jetpack/Branding/Coordinator/JetpackFeaturesRemovalCoordinator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Foundation
44
class JetpackFeaturesRemovalCoordinator {
55

66
/// Enum descibing the current phase of the Jetpack features removal
7-
enum GeneralPhase {
7+
enum GeneralPhase: String {
88
case normal
99
case one
1010
case two

WordPress/Classes/ViewRelated/Jetpack/Branding/Overlay/JetpackFullscreenOverlayConfig.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ protocol JetpackFullscreenOverlayConfig {
1212
var continueButtonText: String? { get }
1313
var shouldShowCloseButton: Bool { get }
1414
var analyticsSource: String { get }
15+
16+
func trackOverlayDisplayed()
17+
func trackLearnMoreTapped()
18+
func trackSwitchButtonTapped()
19+
func trackCloseButtonTapped()
20+
func trackOverlaySwippedDown()
21+
func trackContinueButtonTapped()
1522
}
1623

1724
extension JetpackFullscreenOverlayConfig {

WordPress/WordPress.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,8 +1504,8 @@
15041504
7EFF208620EAD918009C4699 /* FormattableUserContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EFF208520EAD918009C4699 /* FormattableUserContent.swift */; };
15051505
7EFF208A20EADCB6009C4699 /* NotificationTextContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EFF208920EADCB6009C4699 /* NotificationTextContent.swift */; };
15061506
7EFF208C20EADF68009C4699 /* FormattableCommentContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EFF208B20EADF68009C4699 /* FormattableCommentContent.swift */; };
1507-
800035BD291DD0D7007D2D26 /* JetpackFullscreenOverlayAnalyticsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 800035BC291DD0D7007D2D26 /* JetpackFullscreenOverlayAnalyticsHelper.swift */; };
1508-
800035BE291DD0D7007D2D26 /* JetpackFullscreenOverlayAnalyticsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 800035BC291DD0D7007D2D26 /* JetpackFullscreenOverlayAnalyticsHelper.swift */; };
1507+
800035BD291DD0D7007D2D26 /* JetpackFullscreenOverlayGeneralConfig+Analytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 800035BC291DD0D7007D2D26 /* JetpackFullscreenOverlayGeneralConfig+Analytics.swift */; };
1508+
800035BE291DD0D7007D2D26 /* JetpackFullscreenOverlayGeneralConfig+Analytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 800035BC291DD0D7007D2D26 /* JetpackFullscreenOverlayGeneralConfig+Analytics.swift */; };
15091509
801D94EF2919E7D70051993E /* JetpackFullscreenOverlayGeneralPhaseConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 801D94EE2919E7D70051993E /* JetpackFullscreenOverlayGeneralPhaseConfig.swift */; };
15101510
801D94F02919E7D70051993E /* JetpackFullscreenOverlayGeneralPhaseConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 801D94EE2919E7D70051993E /* JetpackFullscreenOverlayGeneralPhaseConfig.swift */; };
15111511
801D950D291AB3CF0051993E /* JetpackReaderLogoAnimation_ltr.json in Resources */ = {isa = PBXBuildFile; fileRef = 801D9507291AB3CD0051993E /* JetpackReaderLogoAnimation_ltr.json */; };
@@ -6751,7 +6751,7 @@
67516751
7EFF208520EAD918009C4699 /* FormattableUserContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormattableUserContent.swift; sourceTree = "<group>"; };
67526752
7EFF208920EADCB6009C4699 /* NotificationTextContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationTextContent.swift; sourceTree = "<group>"; };
67536753
7EFF208B20EADF68009C4699 /* FormattableCommentContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormattableCommentContent.swift; sourceTree = "<group>"; };
6754-
800035BC291DD0D7007D2D26 /* JetpackFullscreenOverlayAnalyticsHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackFullscreenOverlayAnalyticsHelper.swift; sourceTree = "<group>"; };
6754+
800035BC291DD0D7007D2D26 /* JetpackFullscreenOverlayGeneralConfig+Analytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "JetpackFullscreenOverlayGeneralConfig+Analytics.swift"; sourceTree = "<group>"; };
67556755
801D94EE2919E7D70051993E /* JetpackFullscreenOverlayGeneralPhaseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackFullscreenOverlayGeneralPhaseConfig.swift; sourceTree = "<group>"; };
67566756
801D9507291AB3CD0051993E /* JetpackReaderLogoAnimation_ltr.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = JetpackReaderLogoAnimation_ltr.json; sourceTree = "<group>"; };
67576757
801D9508291AB3CD0051993E /* JetpackReaderLogoAnimation_rtl.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = JetpackReaderLogoAnimation_rtl.json; sourceTree = "<group>"; };
@@ -12267,7 +12267,7 @@
1226712267
isa = PBXGroup;
1226812268
children = (
1226912269
C3FBF4E728AFEDF8003797DF /* JetpackBrandingAnalyticsHelper.swift */,
12270-
800035BC291DD0D7007D2D26 /* JetpackFullscreenOverlayAnalyticsHelper.swift */,
12270+
800035BC291DD0D7007D2D26 /* JetpackFullscreenOverlayGeneralConfig+Analytics.swift */,
1227112271
);
1227212272
path = Analytics;
1227312273
sourceTree = "<group>";
@@ -20553,7 +20553,7 @@
2055320553
4A50668028B364CA00DD09F4 /* ContainerContextFactory.swift in Sources */,
2055420554
B0F2EFBF259378E600C7EB6D /* SiteSuggestionService.swift in Sources */,
2055520555
4388FF0020A4E19C00783948 /* NotificationsViewController+PushPrimer.swift in Sources */,
20556-
800035BD291DD0D7007D2D26 /* JetpackFullscreenOverlayAnalyticsHelper.swift in Sources */,
20556+
800035BD291DD0D7007D2D26 /* JetpackFullscreenOverlayGeneralConfig+Analytics.swift in Sources */,
2055720557
98517E5928220411001FFD45 /* BloggingPromptTableViewCell.swift in Sources */,
2055820558
5D3D559718F88C3500782892 /* ReaderPostService.m in Sources */,
2055920559
7EA30DB521ADA20F0092F894 /* EditorMediaUtility.swift in Sources */,
@@ -22937,7 +22937,7 @@
2293722937
FABB23112602FC2C00C8785C /* PostingActivityLegend.swift in Sources */,
2293822938
8B92D69727CD51FA001F5371 /* DashboardGhostCardCell.swift in Sources */,
2293922939
FABB23122602FC2C00C8785C /* WPImmuTableRows.swift in Sources */,
22940-
800035BE291DD0D7007D2D26 /* JetpackFullscreenOverlayAnalyticsHelper.swift in Sources */,
22940+
800035BE291DD0D7007D2D26 /* JetpackFullscreenOverlayGeneralConfig+Analytics.swift in Sources */,
2294122941
FABB23132602FC2C00C8785C /* WordPress-87-88.xcmappingmodel in Sources */,
2294222942
FABB23142602FC2C00C8785C /* UsersService.swift in Sources */,
2294322943
FABB23152602FC2C00C8785C /* SharePost+UIActivityItemSource.swift in Sources */,

0 commit comments

Comments
 (0)