-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(analytics): other iOS GA updates (#652)
* feat(analytics): log searches * feat(analytics): log vehicle taps, separate legacy from new stop details * feat(analytics): log session/user variables * fix iOS tests * use the regular LocationDataManager for HomeMapView avoids creating a new one every time ContentView renders and thereby spamming GA with redundant location permission updates * set distance filter to 1m instead of 100m
- Loading branch information
1 parent
32f2fe7
commit 5a3ea0a
Showing
23 changed files
with
221 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// MapAnalytics.swift | ||
// iosApp | ||
// | ||
// Created by Horn, Melody on 2025-01-14. | ||
// Copyright © 2025 MBTA. All rights reserved. | ||
// | ||
|
||
protocol MapAnalytics { | ||
func tappedOnStop(stopId: String) | ||
func tappedVehicle(routeId: String) | ||
} | ||
|
||
extension AnalyticsProvider: MapAnalytics { | ||
func tappedOnStop(stopId: String) { | ||
logEvent( | ||
"tapped_on_stop", | ||
parameters: [ | ||
"stop_id": stopId, | ||
] | ||
) | ||
} | ||
|
||
func tappedVehicle(routeId: String) { | ||
logEvent("tapped_vehicle", parameters: ["route_id": routeId]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// SearchAnalytics.swift | ||
// iosApp | ||
// | ||
// Created by Horn, Melody on 2025-01-13. | ||
// Copyright © 2025 MBTA. All rights reserved. | ||
// | ||
|
||
import FirebaseAnalytics | ||
|
||
protocol SearchAnalytics { | ||
func performedSearch(query: String) | ||
} | ||
|
||
extension AnalyticsProvider: SearchAnalytics { | ||
func performedSearch(query: String) { | ||
logEvent("search", parameters: ["query": query]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// SessionAnalytics.swift | ||
// iosApp | ||
// | ||
// Created by Horn, Melody on 2025-01-14. | ||
// Copyright © 2025 MBTA. All rights reserved. | ||
// | ||
|
||
import CoreLocation | ||
import FirebaseAnalytics | ||
import SwiftUI | ||
|
||
protocol SessionAnalytics { | ||
func recordSession(colorScheme: ColorScheme) | ||
func recordSession(voiceOver: Bool) | ||
func recordSession(hideMaps: Bool) | ||
func recordSession(locationAccess: CLAuthorizationStatus, locationAccuracy: CLAccuracyAuthorization) | ||
} | ||
|
||
extension AnalyticsProvider: SessionAnalytics { | ||
func recordSession(colorScheme: ColorScheme) { | ||
let colorScheme = switch colorScheme { | ||
case .light: "light" | ||
case .dark: "dark" | ||
@unknown default: "unknown" | ||
} | ||
Analytics.setUserProperty(colorScheme, forName: "color_scheme") | ||
} | ||
|
||
func recordSession(voiceOver: Bool) { | ||
let voiceOver = switch voiceOver { | ||
case true: "true" | ||
case false: "false" | ||
} | ||
Analytics.setUserProperty(voiceOver, forName: "screen_reader_on") | ||
} | ||
|
||
func recordSession(hideMaps: Bool) { | ||
let hideMaps = switch hideMaps { | ||
case true: "true" | ||
case false: "false" | ||
} | ||
Analytics.setUserProperty(hideMaps, forName: "hide_maps_on") | ||
} | ||
|
||
func recordSession(locationAccess: CLAuthorizationStatus, locationAccuracy: CLAccuracyAuthorization) { | ||
let locationAllowed = switch locationAccess { | ||
case .authorizedAlways, .authorizedWhenInUse: true | ||
case .notDetermined, .denied, .restricted: false | ||
@unknown default: false | ||
} | ||
let locationAccess = switch (locationAllowed, locationAccuracy) { | ||
case (true, .fullAccuracy): "precise" | ||
case (true, _): "approximate" | ||
case (false, _): "off" | ||
} | ||
Analytics.setUserProperty(locationAccess, forName: "location_access") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// StopTripDetailsAnalytics.swift | ||
// iosApp | ||
// | ||
// Created by Horn, Melody on 2025-01-14. | ||
// Copyright © 2025 MBTA. All rights reserved. | ||
// | ||
|
||
protocol StopTripDetailsAnalytics: DestinationRowAnalytics { | ||
func tappedAlertDetails(routeId: String, stopId: String, alertId: String) | ||
func tappedRouteFilter(routeId: String, stopId: String) | ||
func toggledPinnedRouteAtStop(pinned: Bool, routeId: String) | ||
} | ||
|
||
extension AnalyticsProvider: StopTripDetailsAnalytics { | ||
func tappedAlertDetails(routeId: String, stopId: String, alertId: String) { | ||
logEvent( | ||
"tapped_alert_details", | ||
parameters: [ | ||
"route_id": routeId, | ||
"stop_id": stopId, | ||
"alertId": alertId, | ||
] | ||
) | ||
} | ||
|
||
func tappedRouteFilter(routeId: String, stopId: String) { | ||
logEvent( | ||
"tapped_route_filter", | ||
parameters: [ | ||
"route_id": routeId, | ||
"stop_id": stopId, | ||
] | ||
) | ||
} | ||
|
||
func toggledPinnedRouteAtStop(pinned: Bool, routeId: String) { | ||
logEvent( | ||
pinned ? "pin_route" : "unpin_route", | ||
parameters: [ | ||
"route_id": routeId, | ||
] | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.