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>
This commit is contained in:
@@ -24,7 +24,7 @@ struct CustomWigetView: View {
|
||||
.frame(width: 50, height: 50)
|
||||
.cornerRadius(10)
|
||||
.onTapGesture {
|
||||
EventLogger.log(event: "show_widget")
|
||||
AnalyticsManager.shared.track(.widgetViewed)
|
||||
selectedWidget.selectedItem = widget.copy() as? CustomWidgetModel
|
||||
selectedWidget.showSheet = true
|
||||
}
|
||||
@@ -35,7 +35,7 @@ struct CustomWigetView: View {
|
||||
Image(systemName: "plus")
|
||||
)
|
||||
.onTapGesture {
|
||||
EventLogger.log(event: "tap_create_new_widget")
|
||||
AnalyticsManager.shared.track(.widgetCreateTapped)
|
||||
selectedWidget.selectedItem = CustomWidgetModel.randomWidget
|
||||
selectedWidget.showSheet = true
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ struct IconPickerView: View {
|
||||
HStack {
|
||||
Button(action: {
|
||||
UIApplication.shared.setAlternateIconName(nil)
|
||||
EventLogger.log(event: "change_icon_title", withData: ["title": "default"])
|
||||
AnalyticsManager.shared.track(.appIconChanged(iconTitle: "default"))
|
||||
}, label: {
|
||||
Image("AppIconImage", bundle: .main)
|
||||
.resizable()
|
||||
@@ -73,7 +73,7 @@ struct IconPickerView: View {
|
||||
UIApplication.shared.setAlternateIconName(iconSet.1) { (error) in
|
||||
// FIXME: Handle error
|
||||
}
|
||||
EventLogger.log(event: "change_icon_title", withData: ["title": iconSet.1])
|
||||
AnalyticsManager.shared.track(.appIconChanged(iconTitle: iconSet.1))
|
||||
}, label: {
|
||||
Image(iconSet.0, bundle: .main)
|
||||
.resizable()
|
||||
|
||||
@@ -45,7 +45,7 @@ struct ImagePackPickerView: View {
|
||||
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||
impactMed.impactOccurred()
|
||||
imagePack = images
|
||||
EventLogger.log(event: "change_image_pack_id", withData: ["id": images.rawValue])
|
||||
AnalyticsManager.shared.track(.iconPackChanged(packId: images.rawValue))
|
||||
}
|
||||
if images.rawValue != (MoodImages.allCases.sorted(by: { $0.rawValue > $1.rawValue }).first?.rawValue) ?? 0 {
|
||||
Divider()
|
||||
|
||||
@@ -41,14 +41,10 @@ struct PersonalityPackPickerView: View {
|
||||
.padding(5)
|
||||
)
|
||||
.onTapGesture {
|
||||
// if aPack.rawValue == PersonalityPack.Rude.rawValue && !showNSFW {
|
||||
// showOver18Alert = true
|
||||
// EventLogger.log(event: "show_over_18_alert")
|
||||
// } else {
|
||||
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||
impactMed.impactOccurred()
|
||||
personalityPack = aPack
|
||||
EventLogger.log(event: "change_personality_pack", withData: ["pack_title": aPack.title()])
|
||||
AnalyticsManager.shared.track(.personalityPackChanged(packTitle: aPack.title()))
|
||||
LocalNotification.rescheduleNotifiations()
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ struct ShapePickerView: View {
|
||||
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||
impactMed.impactOccurred()
|
||||
shape = ashape
|
||||
EventLogger.log(event: "change_mood_shape_id", withData: ["id": shape.rawValue])
|
||||
AnalyticsManager.shared.track(.moodShapeChanged(shapeId: shape.rawValue))
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.background(
|
||||
|
||||
@@ -71,7 +71,7 @@ struct ThemePickerView: View {
|
||||
selectedTheme = theme
|
||||
}
|
||||
|
||||
EventLogger.log(event: "change_theme_id", withData: ["id": theme.rawValue])
|
||||
AnalyticsManager.shared.track(.themeChanged(themeId: theme.rawValue))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ struct VotingLayoutPickerView: View {
|
||||
votingLayoutStyle = layout.rawValue
|
||||
}
|
||||
}
|
||||
EventLogger.log(event: "change_voting_layout", withData: ["layout": layout.displayName])
|
||||
AnalyticsManager.shared.track(.votingLayoutChanged(layout: layout.displayName))
|
||||
}) {
|
||||
VStack(spacing: 6) {
|
||||
layoutIcon(for: layout)
|
||||
|
||||
Reference in New Issue
Block a user