forked from openedx/openedx-app-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:Customize the Firebase plugin to meet its data guidelines. (#49)
fix: Customize the Firebase plugin to meet its data guidelines. - Remove unsupported characters from analytic key and length restricted to 40 characters for FB. - truncate values to 100 character for FB - Update the segment and destination library - override the execution to update the data according to firebase data guidelines fix: LEARNER-10190
- Loading branch information
1 parent
191d87b
commit feba66f
Showing
4 changed files
with
77 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/src/main/java/org/openedx/app/analytics/AnalyticsUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.openedx.app.analytics | ||
|
||
import android.os.Bundle | ||
import com.braze.support.toBundle | ||
import com.segment.analytics.kotlin.core.Properties | ||
import kotlinx.serialization.json.buildJsonObject | ||
import kotlinx.serialization.json.put | ||
|
||
object AnalyticsUtils { | ||
fun makeFirebaseAnalyticsKey(value: String): String { | ||
return value.replace(Regex("[:\\- ]+"), "_").take(40) | ||
} | ||
|
||
fun formatFirebaseAnalyticsData(input: Map<String, Any?>): Bundle { | ||
return input.entries.associate { (key, value) -> | ||
// Format the key | ||
val formattedKey = makeFirebaseAnalyticsKey(key) | ||
// Truncate the string converted value to 100 characters | ||
val formattedValue = value.toString().take(100) | ||
// Return a Pair of the formatted key and value | ||
formattedKey to formattedValue | ||
}.toBundle() | ||
} | ||
|
||
fun formatFirebaseAnalyticsDataForSegment(properties: Properties): Properties { | ||
return buildJsonObject { | ||
for ((key, value) in properties) { | ||
put( | ||
makeFirebaseAnalyticsKey(key), | ||
value.toString().take(100) | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters