Files
Reflect/Shared/AppDelegate.swift
Trey t e0330dbc8d Replace EventLogger with typed AnalyticsManager using PostHog
Complete analytics overhaul: delete EventLogger.swift, create Analytics.swift
with typed event enum (~45 events), screen tracking, super properties
(theme, icon pack, voting layout, etc.), session replay with kill switch,
autocapture, and network telemetry. Replace all 99 call sites across 38 files
with compiler-enforced typed events in object_action naming convention.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 15:12:33 -06:00

69 lines
2.5 KiB
Swift

//
// AppDelegate.swift
// Feels (iOS)
//
// Created by Trey Tartt on 1/10/22.
//
import Foundation
import UserNotifications
import UIKit
import SwiftUI
class AppDelegate: NSObject, UIApplicationDelegate {
private let savedOnboardingData = UserDefaultsStore.getOnboarding()
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@MainActor
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
DataController.shared.removeNoForDates()
DataController.shared.fillInMissingDates()
UNUserNotificationCenter.current().delegate = self
UIPageControl.appearance().currentPageIndicatorTintColor = UIColor(theme.currentTheme.labelColor)
UIPageControl.appearance().pageIndicatorTintColor = UIColor.systemGray
let appearance = UITabBarAppearance()
appearance.configureWithOpaqueBackground()
UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = appearance
return true
}
}
extension AppDelegate: @preconcurrency UNUserNotificationCenterDelegate {
func requestAuthorization() { }
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.badge, .banner, .sound])
}
@MainActor
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
if let action = LocalNotification.ActionType(rawValue: response.actionIdentifier) {
let date = ShowBasedOnVoteLogics.getCurrentVotingDate(onboardingData: savedOnboardingData)
let mood: Mood
switch action {
case .horrible:
mood = .horrible
case .bad:
mood = .bad
case .average:
mood = .average
case .good:
mood = .good
case .great:
mood = .great
}
// Use centralized mood logger
MoodLogger.shared.logMood(mood, for: date, entryType: .notification)
UNUserNotificationCenter.current().setBadgeCount(0)
}
completionHandler()
}
}