Complete the code to initialize Firebase Analytics in an Android Kotlin app.
val firebaseAnalytics = FirebaseAnalytics.[1](this)The getInstance method returns the FirebaseAnalytics instance for the given context.
Complete the code to log a custom event named "share_image" with Firebase Analytics.
val bundle = Bundle().apply {
putString(FirebaseAnalytics.Param.METHOD, "[1]")
}
firebaseAnalytics.logEvent("share_image", bundle)The putString method adds a parameter to the event bundle. Here, the method is set to "email" to indicate the sharing method.
Fix the error in the code to set the user ID for Firebase Analytics.
firebaseAnalytics.[1]("user_123")
The correct method to set the user ID is setUserId with a lowercase 'd'.
Fill both blanks to create a bundle with a parameter for item ID and log an event named "select_content".
val bundle = Bundle().apply {
putString(FirebaseAnalytics.Param.[1], "12345")
}
firebaseAnalytics.logEvent("[2]", bundle)The parameter key for item ID is ITEM_ID. The event name to log is select_content.
Fill all three blanks to create a bundle with item name and content type, then log a "view_item" event.
val bundle = Bundle().apply {
putString(FirebaseAnalytics.Param.[1], "Sunglasses")
putString(FirebaseAnalytics.Param.[2], "[3]")
}
firebaseAnalytics.logEvent("view_item", bundle)The parameter keys are ITEM_NAME and CONTENT_TYPE. The content type value is "accessories".