Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move analytics abstractions to shared #658

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 4 additions & 40 deletions iosApp/iosApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

39 changes: 0 additions & 39 deletions iosApp/iosApp/Analytics/AlertDetailsAnalytics.swift

This file was deleted.

36 changes: 36 additions & 0 deletions iosApp/iosApp/Analytics/AnalyticsExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// AnalyticsExtensions.swift
// iosApp
//
// Created by Horn, Melody on 2025-01-14.
// Copyright © 2025 MBTA. All rights reserved.
//

import CoreLocation
import shared
import SwiftUI

extension Analytics {
func recordSession(colorScheme: ColorScheme) {
let analyticsColorScheme: AnalyticsColorScheme = switch colorScheme {
case .light: .light
case .dark: .dark
@unknown default: .unknown
}
recordSession(colorScheme: analyticsColorScheme)
}

func recordSession(locationAccess: CLAuthorizationStatus, locationAccuracy: CLAccuracyAuthorization) {
let locationAllowed = switch locationAccess {
case .authorizedAlways, .authorizedWhenInUse: true
case .notDetermined, .denied, .restricted: false
@unknown default: false
}
let locationAccess: AnalyticsLocationAccess = switch (locationAllowed, locationAccuracy) {
case (true, .fullAccuracy): .precise
case (true, _): .approximate
case (false, _): .off
}
recordSession(locationAccess: locationAccess)
}
}
17 changes: 8 additions & 9 deletions iosApp/iosApp/Analytics/AnalyticsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@

import FirebaseAnalytics
import Foundation
import shared

class AnalyticsProvider {
class AnalyticsProvider: shared.Analytics {
static let shared = AnalyticsProvider()

/**
* The `file` param is automatically populated with the call sites file path which we parse the class name from.
* e.g.: `NearbyTransitAnalytics`
*/
func logEvent(_ name: String, parameters: [String: Any] = [:], file: String = #file) {
var params = parameters
params["class_name"] = URL(string: file)?.deletingPathExtension().lastPathComponent
Analytics.logEvent(name, parameters: params)
override func logEvent(name: String, parameters: [String: String]) {
FirebaseAnalytics.Analytics.logEvent(name, parameters: parameters)
}

override func setUserProperty(name: String, value: String) {
FirebaseAnalytics.Analytics.setUserProperty(value, forName: name)
}
}
57 changes: 0 additions & 57 deletions iosApp/iosApp/Analytics/DestinationRowAnalytics.swift

This file was deleted.

27 changes: 0 additions & 27 deletions iosApp/iosApp/Analytics/MapAnalytics.swift

This file was deleted.

30 changes: 0 additions & 30 deletions iosApp/iosApp/Analytics/NearbyTransitAnalytics.swift

This file was deleted.

33 changes: 0 additions & 33 deletions iosApp/iosApp/Analytics/ScreenTracker.swift

This file was deleted.

19 changes: 0 additions & 19 deletions iosApp/iosApp/Analytics/SearchAnalytics.swift

This file was deleted.

59 changes: 0 additions & 59 deletions iosApp/iosApp/Analytics/SessionAnalytics.swift

This file was deleted.

38 changes: 0 additions & 38 deletions iosApp/iosApp/Analytics/StopDetailsAnalytics.swift

This file was deleted.

Loading
Loading