Skip to content

Commit d3737eb

Browse files
committed
Add TTFD to articles list screen
1 parent 26977a1 commit d3737eb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Modules/Sources/ArticlesListFeature/ArticlesListFeature.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public struct ArticlesListFeature: Reducer, Sendable {
4848

4949
public var scrollToTop: Bool = false
5050

51+
var didLoadOnce = false
52+
5153
public init(
5254
destination: Destination.State? = nil,
5355
appSettings: AppSettings = .default,
@@ -88,6 +90,7 @@ public struct ArticlesListFeature: Reducer, Sendable {
8890

8991
@Dependency(\.apiClient) private var apiClient
9092
@Dependency(\.cacheClient) private var cacheClient
93+
@Dependency(\.analyticsClient) private var analyticsClient
9194
@Dependency(\.pasteboardClient) private var pasteboardClient
9295
@Dependency(\.hapticClient) private var hapticClient
9396
@Dependency(\.continuousClock) private var clock
@@ -168,16 +171,24 @@ public struct ArticlesListFeature: Reducer, Sendable {
168171
}
169172
state.offset += state.loadAmount
170173
state.isLoading = false
174+
reportFullyDisplayed(&state)
171175
return .none
172176

173177
case ._articlesResponse(.failure):
174178
state.isLoading = false
175179
state.destination = .alert(.failedToConnect)
180+
reportFullyDisplayed(&state)
176181
return .none
177182
}
178183
}
179184
.ifLet(\.$destination, action: \.destination)
180185

181186
Analytics()
182187
}
188+
189+
private func reportFullyDisplayed(_ state: inout State) {
190+
guard !state.didLoadOnce else { return }
191+
analyticsClient.reportFullyDisplayed()
192+
state.didLoadOnce = true
193+
}
183194
}

0 commit comments

Comments
 (0)