Add PostHog analytics integration for Android and iOS
Implement comprehensive analytics tracking across both platforms: Android (Kotlin): - Add PostHog SDK dependency and initialization in MainActivity - Create expect/actual pattern for cross-platform analytics (commonMain/androidMain/iosMain/jvmMain/jsMain/wasmJsMain) - Track screen views: registration, login, residences, tasks, contractors, documents, notifications, profile - Track key events: user_registered, user_signed_in, residence_created, task_created, contractor_created, document_created - Track paywall events: contractor_paywall_shown, documents_paywall_shown - Track sharing events: residence_shared, contractor_shared - Track theme_changed event iOS (Swift): - Add PostHog iOS SDK via SPM - Create PostHogAnalytics wrapper and AnalyticsEvents constants - Initialize SDK in iOSApp with session replay support - Track same screen views and events as Android - Track user identification after login/registration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,8 @@ import com.example.casera.models.ContractorUpdateRequest
|
||||
import com.example.casera.models.Residence
|
||||
import com.example.casera.network.ApiResult
|
||||
import com.example.casera.repository.LookupsRepository
|
||||
import com.example.casera.analytics.PostHogAnalytics
|
||||
import com.example.casera.analytics.AnalyticsEvents
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -53,8 +55,11 @@ fun AddContractorDialog(
|
||||
var expandedResidenceMenu by remember { mutableStateOf(false) }
|
||||
val contractorSpecialties by LookupsRepository.contractorSpecialties.collectAsState()
|
||||
|
||||
// Load residences for picker
|
||||
// Track screen view and load residences for picker
|
||||
LaunchedEffect(Unit) {
|
||||
if (contractorId == null) {
|
||||
PostHogAnalytics.screen(AnalyticsEvents.NEW_CONTRACTOR_SCREEN_SHOWN)
|
||||
}
|
||||
residenceViewModel.loadResidences()
|
||||
}
|
||||
|
||||
@@ -91,6 +96,7 @@ fun AddContractorDialog(
|
||||
|
||||
LaunchedEffect(createState) {
|
||||
if (createState is ApiResult.Success) {
|
||||
PostHogAnalytics.capture(AnalyticsEvents.CONTRACTOR_CREATED)
|
||||
onContractorSaved()
|
||||
viewModel.resetCreateState()
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.example.casera.models.TaskCategory
|
||||
import com.example.casera.models.TaskCreateRequest
|
||||
import com.example.casera.models.TaskFrequency
|
||||
import com.example.casera.models.TaskPriority
|
||||
import com.example.casera.analytics.PostHogAnalytics
|
||||
import com.example.casera.analytics.AnalyticsEvents
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -110,6 +112,11 @@ fun AddTaskDialog(
|
||||
showSuggestions = false
|
||||
}
|
||||
|
||||
// Track screen view
|
||||
LaunchedEffect(Unit) {
|
||||
PostHogAnalytics.screen(AnalyticsEvents.NEW_TASK_SCREEN_SHOWN)
|
||||
}
|
||||
|
||||
// Set defaults when data loads
|
||||
LaunchedEffect(frequencies) {
|
||||
if (frequencies.isNotEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user