@@ -103,11 +103,10 @@ class FirebaseDestination(
103
103
eventName = makeKey(eventName)
104
104
}
105
105
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 )" )
111
110
112
111
return returnPayload
113
112
}
@@ -117,7 +116,9 @@ class FirebaseDestination(
117
116
118
117
val tempActivity = activity
119
118
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)
121
122
}
122
123
123
124
return returnPayload
@@ -134,7 +135,9 @@ class FirebaseDestination(
134
135
packageManager.getActivityInfo(activity.componentName, PackageManager .GET_META_DATA )
135
136
.let {
136
137
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)
138
141
analytics.log(
139
142
" firebaseAnalytics.setCurrentScreen(activity, $activityName , null"
140
143
)
@@ -184,7 +187,6 @@ class FirebaseDestination(
184
187
}
185
188
}
186
189
187
-
188
190
// Don't return a valid bundle if there wasn't anything added
189
191
if (bundle?.isEmpty == true ) {
190
192
bundle = null
@@ -214,11 +216,10 @@ class FirebaseDestination(
214
216
return mappedProducts
215
217
}
216
218
217
- // Make sure keys do not contain ".", "-", " ", ":"
219
+ // Make sure keys do not contain ".", "-", " ", ":" and are replaced with _
218
220
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, " _" )
222
223
}
223
224
224
225
// Adds the appropriate value & type to a supplied bundle
0 commit comments