package com.suno.android.ui.screens.home import com.suno.android.ui.screens.home.tabs.BottomNavTabItem import com.suno.android.ui.screens.navigation.NavDestination import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json object HomeScreenNavGraphAnalytics { const val SCREEN = "HomeScreenNavGraph" const val CREATE_TAB_NAME = "create" fun createMetadata( navDestination: NavDestination, ): String { val metadata = buildMap { val tabName = resolveTabName(navDestination) tabName?.let { put("tab_name", tabName) } } return Json.encodeToString(metadata) } // Resolves tab_name if NavDestination is a bottom tab private fun resolveTabName( navDestination: NavDestination, ): String? { val bottomNavTabItem = BottomNavTabItem.entries.find { it.destination == navDestination } return when (bottomNavTabItem) { is BottomNavTabItem -> bottomNavTabItem.value null -> if (navDestination is NavDestination.Create) CREATE_TAB_NAME else null } } }