Skip to content

Commit 191025c

Browse files
adborbasclaude
andcommitted
Move analytics mapping extensions to analytics file
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6b49a8f commit 191025c

File tree

5 files changed

+30
-26
lines changed

5 files changed

+30
-26
lines changed

WooCommerce/Classes/Analytics/WooAnalyticsEvent+PushNotificationsSetup.swift

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,33 @@ extension WooAnalyticsEvent {
2222
properties: [Keys.buttonLabel.rawValue: buttonLabel.rawValue])
2323
}
2424

25-
static func flowButtonTap(buttonLabel: FlowButtonLabel) -> WooAnalyticsEvent {
25+
static func flowButtonTap(_ buttonLabel: FlowButtonLabel) -> WooAnalyticsEvent {
2626
WooAnalyticsEvent(statName: .pushNotificationsSetupFlowButtonTap,
2727
properties: [Keys.buttonLabel.rawValue: buttonLabel.rawValue])
2828
}
2929

3030
}
3131
}
32+
33+
// MARK: - Analytics mapping extensions
34+
35+
extension SetupStep {
36+
var analyticsFlowStep: String {
37+
switch self {
38+
case .checkPlugin: return "plugin_compatibility"
39+
case .connect: return "connect_wpcom"
40+
case .enablePush: return "enable_push_notifications"
41+
}
42+
}
43+
}
44+
45+
extension WPComConnectionSetupStep.ErrorType: LocalizedError {
46+
var errorDescription: String? {
47+
switch self {
48+
case .outdatedPlugin(let version):
49+
return "Outdated plugin version: \(version)"
50+
case .generic(let reason):
51+
return reason
52+
}
53+
}
54+
}

WooCommerce/Classes/Authentication/WPComLogin/WPComConnectionSetup/WPComConnectionSetupHandlerProtocol.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ enum SetupStep: Int, CaseIterable {
55
case checkPlugin = 0
66
case connect = 1
77
case enablePush = 2
8-
9-
var analyticsFlowStep: String {
10-
switch self {
11-
case .checkPlugin: return "plugin_compatibility"
12-
case .connect: return "connect_wpcom"
13-
case .enablePush: return "enable_push_notifications"
14-
}
15-
}
168
}
179

1810
@MainActor

WooCommerce/Classes/Authentication/WPComLogin/WPComConnectionSetup/WPComConnectionSetupStep.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,3 @@ struct WPComConnectionSetupStep: Identifiable {
1717
let status: Status
1818
let id = UUID()
1919
}
20-
21-
extension WPComConnectionSetupStep.ErrorType: LocalizedError {
22-
var errorDescription: String? {
23-
switch self {
24-
case .outdatedPlugin(let version):
25-
return "Outdated plugin version: \(version)"
26-
case .generic(let reason):
27-
return reason
28-
}
29-
}
30-
}

WooCommerce/Classes/Authentication/WPComLogin/WPComConnectionSetup/WPComConnectionSetupViewModel.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,19 @@ final class WPComConnectionSetupViewModel: ObservableObject {
118118
func primaryButtonTapped() {
119119
switch setupState {
120120
case .completed:
121-
analytics.track(event: .PushNotificationsSetup.flowButtonTap(buttonLabel: .goToMyStore))
121+
analytics.track(event: .PushNotificationsSetup.flowButtonTap( .goToMyStore))
122122
onGoToStore()
123123
case .failed(let step, let checkPluginError):
124124
switch step {
125125
case .connect, .enablePush:
126-
analytics.track(event: .PushNotificationsSetup.flowButtonTap(buttonLabel: .tryAgain))
126+
analytics.track(event: .PushNotificationsSetup.flowButtonTap( .tryAgain))
127127
retrySetup()
128128
case .checkPlugin:
129129
if checkPluginError == .outdated {
130-
analytics.track(event: .PushNotificationsSetup.flowButtonTap(buttonLabel: .updatePlugin))
130+
analytics.track(event: .PushNotificationsSetup.flowButtonTap( .updatePlugin))
131131
onUpdatePlugin()
132132
} else {
133-
analytics.track(event: .PushNotificationsSetup.flowButtonTap(buttonLabel: .tryAgain))
133+
analytics.track(event: .PushNotificationsSetup.flowButtonTap( .tryAgain))
134134
retrySetup()
135135
}
136136
}
@@ -140,7 +140,7 @@ final class WPComConnectionSetupViewModel: ObservableObject {
140140
}
141141

142142
func secondaryButtonTapped() {
143-
analytics.track(event: .PushNotificationsSetup.flowButtonTap(buttonLabel: .tryAgain))
143+
analytics.track(event: .PushNotificationsSetup.flowButtonTap( .tryAgain))
144144
retrySetup()
145145
}
146146

WooCommerce/WooCommerceTests/Analytics/WooAnalyticsEvent+PushNotificationsSetupTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct WooAnalyticsEvent_PushNotificationsSetupTests {
3737

3838
for (label, expected) in cases {
3939
// When
40-
let event = WooAnalyticsEvent.PushNotificationsSetup.flowButtonTap(buttonLabel: label)
40+
let event = WooAnalyticsEvent.PushNotificationsSetup.flowButtonTap(label)
4141

4242
// Then
4343
#expect(event.statName == .pushNotificationsSetupFlowButtonTap)

0 commit comments

Comments
 (0)