@@ -8,6 +8,8 @@ import io.sentry.rrweb.RRWebSpanEvent
88import java.util.Date
99
1010private const val MILLIS_PER_SECOND = 1000.0
11+ private const val MAX_PATH_ITEMS = 4
12+ private const val MAX_PATH_IDENTIFIER_LENGTH = 20
1113
1214class SentryFlutterReplayBreadcrumbConverter : DefaultReplayBreadcrumbConverter () {
1315 internal companion object {
@@ -85,16 +87,12 @@ class SentryFlutterReplayBreadcrumbConverter : DefaultReplayBreadcrumbConverter(
8587 }
8688
8789 private fun getTouchPathMessage (maybePath : Any? ): String? {
88- if (maybePath !is List <* >) {
89- return null
90- }
91-
92- if (maybePath.isEmpty()) {
90+ if (maybePath !is List <* > || maybePath.isEmpty()) {
9391 return null
9492 }
9593
9694 val message = StringBuilder ()
97- for (i in Math .min(3 , maybePath.size - 1 ) downTo 0 ) {
95+ for (i in Math .min(MAX_PATH_ITEMS , maybePath.size) - 1 downTo 0 ) {
9896 val item = maybePath[i]
9997 if (item !is Map <* , * >) {
10098 continue
@@ -104,8 +102,8 @@ class SentryFlutterReplayBreadcrumbConverter : DefaultReplayBreadcrumbConverter(
104102
105103 var identifier = item[" label" ] ? : item[" name" ]
106104 if (identifier is String && identifier.isNotEmpty()) {
107- if (identifier.length > 20 ) {
108- identifier = identifier.substring(0 , 17 ) + " ..."
105+ if (identifier.length > MAX_PATH_IDENTIFIER_LENGTH ) {
106+ identifier = identifier.substring(0 , MAX_PATH_IDENTIFIER_LENGTH - " ... " .length ) + " ..."
109107 }
110108 message.append(" (" ).append(identifier).append(" )" )
111109 }
0 commit comments