Challenge 2: An Analytics Event with Parameters — Solution @HiltViewModel class TaskViewModel @Inject constructor( private val repository: TaskRepository ) : ViewModel() { fun addTask(title: String) { viewModelScope.launch { repository.addTask(Task(title = title)) FirebaseAnalytics.getInstance(/* context */ getApplication()).logEvent("task_added") { param("title_length", title.length.toLong()) } } } } // Why logging the raw title would be a bad idea: // // A task's title is USER-GENERATED CONTENT — it could contain anything // the user types, potentially including personal information (a name, a // phone number, an address, sensitive personal notes). Sending that raw // text into an analytics platform means it now exists in a THIRD-PARTY // system (Firebase's servers) outside the app's own data layer, subject // to Firebase's own retention and access policies rather than whatever // privacy guarantees the app itself makes. This directly connects to // Chapter 7's Data Safety form requirement in Play Console — declaring // "we send user-generated content to a third-party analytics service" // is a meaningfully different (and more concerning) disclosure than "we // send an anonymous integer." Logging only the character LENGTH // preserves a genuinely useful signal (are tasks generally short or // long?) with zero risk of leaking actual user content. Notes: - title.length.toLong() converts Kotlin's Int (from String.length) to Long, since Firebase Analytics' param() function for numeric values expects a Long specifically. - This same "log a derived/aggregated signal, not the raw sensitive value" principle applies broadly — the specific example here (length instead of content) generalizes to almost any analytics event involving user-entered text.