Skip to content

Commit 466a9be

Browse files
committed
Add analytics to forum list screen
1 parent cfaabc7 commit 466a9be

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

ForPDA.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@
590590
B867C0872D8C397000F1D060 /* FavoriteRootFeature+Analytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = B867C0852D8C397000F1D060 /* FavoriteRootFeature+Analytics.swift */; };
591591
B867C08B2D8C438C00F1D060 /* FavoriteRootFeature+Analytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = B867C08A2D8C438C00F1D060 /* FavoriteRootFeature+Analytics.swift */; };
592592
B867C08D2D8C46D500F1D060 /* FavoritesEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = B867C08C2D8C46D500F1D060 /* FavoritesEvent.swift */; };
593+
B867C0912D8C521200F1D060 /* ForumsListFeature+Analytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = B867C0902D8C521200F1D060 /* ForumsListFeature+Analytics.swift */; };
594+
B867C0932D8C528D00F1D060 /* ForumsListEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = B867C0922D8C528D00F1D060 /* ForumsListEvent.swift */; };
593595
B8C498CEC48C5FCB4B97B06D /* LoggerClient.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE5B4E69183CAF50E2DD9C72 /* LoggerClient.framework */; };
594596
B8E07DB61EE1FE92476B3009 /* ArticleElementParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9364E09A93E9A621F26CEF92 /* ArticleElementParser.swift */; };
595597
B94FEA79A90DAADEAF9BA3BF /* FavoriteParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF90BDDA3C9FFDCACFC7076 /* FavoriteParser.swift */; };
@@ -2802,6 +2804,8 @@
28022804
B867C0852D8C397000F1D060 /* FavoriteRootFeature+Analytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FavoriteRootFeature+Analytics.swift"; sourceTree = "<group>"; };
28032805
B867C08A2D8C438C00F1D060 /* FavoriteRootFeature+Analytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FavoriteRootFeature+Analytics.swift"; sourceTree = "<group>"; };
28042806
B867C08C2D8C46D500F1D060 /* FavoritesEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesEvent.swift; sourceTree = "<group>"; };
2807+
B867C0902D8C521200F1D060 /* ForumsListFeature+Analytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ForumsListFeature+Analytics.swift"; sourceTree = "<group>"; };
2808+
B867C0922D8C528D00F1D060 /* ForumsListEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForumsListEvent.swift; sourceTree = "<group>"; };
28052809
BA6BE98BF8DC0AE85F30CC8B /* ZNSTextAttachment.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZNSTextAttachment.framework; sourceTree = BUILT_PRODUCTS_DIR; };
28062810
BA750927EA08B8979A02EE54 /* Links.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Links.swift; sourceTree = "<group>"; };
28072811
BABB677D51B18FF16F4CAEC2 /* TuistBundle+ForumsListFeature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TuistBundle+ForumsListFeature.swift"; sourceTree = "<group>"; };
@@ -3961,6 +3965,7 @@
39613965
4A3312770397847D61EEA170 /* ForumsListFeature */ = {
39623966
isa = PBXGroup;
39633967
children = (
3968+
B867C08F2D8C50CE00F1D060 /* Analytics */,
39643969
9FD78A8F0F8F36FC9B6B72FC /* Models */,
39653970
65702CB96488AE9200D9F02F /* Resources */,
39663971
03503F291FA92B3B3B754F43 /* ForumsListFeature.swift */,
@@ -4017,6 +4022,7 @@
40174022
670EF6A1CF3FF11D91D3F5DD /* ProfileEvent.swift */,
40184023
962C7DDA1EA5D4A2A5DB1F7D /* SettingsEvent.swift */,
40194024
B867C0812D8C0B0900F1D060 /* FavoritesRootEvent.swift */,
4025+
B867C0922D8C528D00F1D060 /* ForumsListEvent.swift */,
40204026
B867C08C2D8C46D500F1D060 /* FavoritesEvent.swift */,
40214027
);
40224028
path = Events;
@@ -4648,6 +4654,14 @@
46484654
path = Analytics;
46494655
sourceTree = "<group>";
46504656
};
4657+
B867C08F2D8C50CE00F1D060 /* Analytics */ = {
4658+
isa = PBXGroup;
4659+
children = (
4660+
B867C0902D8C521200F1D060 /* ForumsListFeature+Analytics.swift */,
4661+
);
4662+
path = Analytics;
4663+
sourceTree = "<group>";
4664+
};
46514665
B982053D2330F26673C85EF0 /* Resources */ = {
46524666
isa = PBXGroup;
46534667
children = (
@@ -6560,6 +6574,7 @@
65606574
B3018A8E7A3C5788FD3862B1 /* TuistFonts+AnalyticsClient.swift in Sources */,
65616575
266201A1FD4838E0011C5C46 /* AnalyticsClient.swift in Sources */,
65626576
884032C038F0BCC1C762A929 /* ArticleEvent.swift in Sources */,
6577+
B867C0932D8C528D00F1D060 /* ForumsListEvent.swift in Sources */,
65636578
7E8C015D7CEA545034FEB4B8 /* ArticlesListEvent.swift in Sources */,
65646579
F40F9D534A092D3DBF800787 /* AuthEvent.swift in Sources */,
65656580
7C412E466DD27226FCF2D207 /* CommentEvent.swift in Sources */,
@@ -6777,6 +6792,7 @@
67776792
E881E5C65B1FD325100CBCEF /* ForumsListFeature.swift in Sources */,
67786793
03E6F986E22FBB2CC34D91AB /* ForumsListScreen.swift in Sources */,
67796794
DFE1FC541AF185F6935349F3 /* ForumRow.swift in Sources */,
6795+
B867C0912D8C521200F1D060 /* ForumsListFeature+Analytics.swift in Sources */,
67806796
);
67816797
runOnlyForDeploymentPostprocessing = 0;
67826798
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// ForumsListEvent.swift
3+
// AnalyticsClient
4+
//
5+
// Created by Ilia Lubianoi on 20.03.2025.
6+
//
7+
8+
import Foundation
9+
10+
public enum ForumsListEvent: Event {
11+
case settingsButtonTapped
12+
case forumRedirectTapped(URL)
13+
case forumTapped(Int, String)
14+
case forumListLoadSuccess
15+
case forumListLoadFailure(any Error)
16+
17+
public var name: String {
18+
return "Forums List " + eventName(for: self).inProperCase
19+
}
20+
21+
public var properties: [String: String]? {
22+
switch self {
23+
case let .forumRedirectTapped(url):
24+
return ["url": url.absoluteString]
25+
26+
case let .forumTapped(id, name):
27+
return ["id": String(id), "name": name]
28+
29+
default:
30+
return nil
31+
}
32+
}
33+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// ForumsListFeature+Analytics.swift
3+
// ForPDA
4+
//
5+
// Created by Ilia Lubianoi on 20.03.2025.
6+
//
7+
8+
import ComposableArchitecture
9+
import AnalyticsClient
10+
11+
extension ForumsListFeature {
12+
13+
struct Analytics: Reducer {
14+
typealias State = ForumsListFeature.State
15+
typealias Action = ForumsListFeature.Action
16+
17+
@Dependency(\.analyticsClient) var analytics
18+
19+
var body: some Reducer<State, Action> {
20+
Reduce<State, Action> { state, action in
21+
switch action {
22+
case .onAppear:
23+
break
24+
25+
case .settingsButtonTapped:
26+
analytics.log(ForumsListEvent.settingsButtonTapped)
27+
28+
case let .forumRedirectTapped(url):
29+
analytics.log(ForumsListEvent.forumRedirectTapped(url))
30+
31+
case let .forumTapped(id: id, name: name):
32+
analytics.log(ForumsListEvent.forumTapped(id, name))
33+
34+
case let ._forumsListResponse(response):
35+
switch response {
36+
case .success:
37+
analytics.log(ForumsListEvent.forumListLoadSuccess)
38+
case let .failure(error):
39+
analytics.log(ForumsListEvent.forumListLoadFailure(error))
40+
}
41+
}
42+
43+
return .none
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)