scaffolding hermes flow and audit logging
This commit is contained in:
@@ -3,15 +3,19 @@ import SwiftUI
|
||||
struct RootView: View {
|
||||
@StateObject private var localization = LocalizationStore()
|
||||
@EnvironmentObject private var analytics: HermesAnalyticsClient
|
||||
@EnvironmentObject private var repository: HermesRepository
|
||||
|
||||
let onStartSession: (String) -> Void
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 24) {
|
||||
header
|
||||
OnboardingView()
|
||||
FeedView()
|
||||
RoundView()
|
||||
OnboardingView(onStartSession: { onStartSession(localization.localeCode) })
|
||||
FeedView(onWatchPreview: {}, onRetry: { onStartSession(localization.localeCode) })
|
||||
RoundView(onRetry: { onStartSession(localization.localeCode) })
|
||||
SessionView(onRetry: { onStartSession(localization.localeCode) })
|
||||
}
|
||||
.padding(.horizontal, HermesTheme.screenPadding)
|
||||
.padding(.vertical, 24)
|
||||
@@ -25,6 +29,15 @@ struct RootView: View {
|
||||
analytics.track("app_opened", attributes: ["screen_name": "home"])
|
||||
analytics.track("screen_viewed", attributes: ["screen_name": "home"])
|
||||
}
|
||||
.task(id: localization.localeCode) {
|
||||
onStartSession(localization.localeCode)
|
||||
}
|
||||
.task {
|
||||
while !Task.isCancelled {
|
||||
try? await Task.sleep(nanoseconds: 5_000_000_000)
|
||||
await analytics.flush(using: repository)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var header: some View {
|
||||
@@ -46,8 +59,8 @@ struct RootView: View {
|
||||
|
||||
private var localeToggle: some View {
|
||||
HStack(spacing: 8) {
|
||||
localeButton(title: "EN", localeCode: "en")
|
||||
localeButton(title: "SV", localeCode: "sv")
|
||||
localeButton(title: localization.localeName(for: "en"), localeCode: "en")
|
||||
localeButton(title: localization.localeName(for: "sv"), localeCode: "sv")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user