Skip to content

Commit

Permalink
Fix FirebaseAnalyticsModifier (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelacaron committed Nov 21, 2023
1 parent 88fd367 commit 81507f3
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "-FIRAnalyticsDebugEnabled"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "-FIRDebugEnabled"
isEnabled = "NO">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct AddMaintenanceView: View {
comment: "Notes text field header")
}
}
.analyticsView()
.analyticsView("\(Self.self)")
.navigationTitle(Text("Add Maintenance",
comment: "Nagivation title for Add Maintenance view"))
.toolbar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct DashboardView: View {
}
.listStyle(.inset)
}
.analyticsView()
.analyticsView("\(Self.self)")
.searchable(text: $viewModel.searchText)
.overlay {
if viewModel.isLoading {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct EditMaintenanceEventView: View {
Text("Notes")
}
}
.analyticsView()
.analyticsView("\(Self.self)")
.onAppear {
guard let selectedEvent = selectedEvent else { return }
setMaintenanceEventValues(event: selectedEvent)
Expand Down
2 changes: 2 additions & 0 deletions Basic-Car-Maintenance/Shared/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FirebaseAutomaticScreenReportingEnabled</key>
<false/>
<key>UIApplicationShortcutItems</key>
<array>
<dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ struct AddOdometerReadingView: View {
}
}
}
.analyticsView("\(Self.self)")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct OdometerView: View {
await viewModel.getVehicles()
}
}
.analyticsView()
.analyticsView("\(Self.self)")
}

private func makeAddOdometerView() -> some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct AddVehicleView: View {
Text("License Plate Number")
}
}
.analyticsView()
.analyticsView("\(Self.self)")
.toolbar {
ToolbarItem {
Button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct AuthenticationView: View {
}
}
}
.analyticsView()
.analyticsView("\(Self.self)")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct ChooseAppIconView: View {
}
}
.navigationTitle("Choose App Icon")
.analyticsView("\(Self.self)")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct ContributorsListView: View {
ProgressView()
}
}
.analyticsView()
.analyticsView("\(Self.self)")
.task {
Task {
await viewModel.getContributors()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ struct SettingsView: View {
.animation(.linear(duration: 0.2), value: copiedAppVersion)
}
}
.analyticsView()
.analyticsView("\(Self.self)")
.navigationDestination(isPresented: $isShowingAddVehicle) {
AddVehicleView() { vehicle in
Task {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
import SwiftUI
import FirebaseAnalyticsSwift

struct FireBaseAnalyticsModifier: ViewModifier {
struct FirebaseAnalyticsModifier: ViewModifier {

let screenName: String

func body(content: Content) -> some View {
content
.analyticsScreen(name: "\(Self.self)")
.analyticsScreen(name: screenName)
}
}

extension View {
func analyticsView() -> some View {
modifier(FireBaseAnalyticsModifier())
func analyticsView(_ name: String) -> some View {
modifier(FirebaseAnalyticsModifier(screenName: name))
}
}

0 comments on commit 81507f3

Please sign in to comment.