@@ -103,11 +103,10 @@ class FirebaseDestination(
103103 eventName = makeKey(eventName)
104104 }
105105
106- payload.properties.let {
107- val formattedProperties = formatProperties(it)
108- firebaseAnalytics.logEvent(eventName, formattedProperties)
109- analytics.log(" firebaseAnalytics.logEvent($eventName , $formattedProperties )" )
110- }
106+ val bundledProperties = formatProperties(payload.properties)
107+
108+ firebaseAnalytics.logEvent(eventName, bundledProperties)
109+ analytics.log(" firebaseAnalytics.logEvent($eventName , $bundledProperties )" )
111110
112111 return returnPayload
113112 }
@@ -117,7 +116,9 @@ class FirebaseDestination(
117116
118117 val tempActivity = activity
119118 if (tempActivity != null ) {
120- firebaseAnalytics.setCurrentScreen(tempActivity, payload.name, null );
119+ val bundle = Bundle ()
120+ bundle.putString(FirebaseAnalytics .Param .SCREEN_NAME , payload.name)
121+ firebaseAnalytics.logEvent(FirebaseAnalytics .Event .SCREEN_VIEW , bundle)
121122 }
122123
123124 return returnPayload
@@ -134,7 +135,9 @@ class FirebaseDestination(
134135 packageManager.getActivityInfo(activity.componentName, PackageManager .GET_META_DATA )
135136 .let {
136137 it.loadLabel(packageManager).toString().let { activityName ->
137- firebaseAnalytics.setCurrentScreen(activity, activityName, null )
138+ val bundle = Bundle ()
139+ bundle.putString(FirebaseAnalytics .Param .SCREEN_NAME , activityName)
140+ firebaseAnalytics.logEvent(FirebaseAnalytics .Event .SCREEN_VIEW , bundle)
138141 analytics.log(
139142 " firebaseAnalytics.setCurrentScreen(activity, $activityName , null"
140143 )
@@ -184,7 +187,6 @@ class FirebaseDestination(
184187 }
185188 }
186189
187-
188190 // Don't return a valid bundle if there wasn't anything added
189191 if (bundle?.isEmpty == true ) {
190192 bundle = null
@@ -214,11 +216,10 @@ class FirebaseDestination(
214216 return mappedProducts
215217 }
216218
217- // Make sure keys do not contain ".", "-", " ", ":"
219+ // Make sure keys do not contain ".", "-", " ", ":" and are replaced with _
218220 private fun makeKey (key : String ): String {
219- val charsToFilter = " .- :"
220- // only filter out the characters in charsToFilter by relying on the other characters not being found
221- return key.filter { charsToFilter.indexOf(it) == - 1 }
221+ val charsToFilter = """ [\. \-:]""" .toRegex()
222+ return key.replace(charsToFilter, " _" )
222223 }
223224
224225 // Adds the appropriate value & type to a supplied bundle
0 commit comments