Skip to content

Commit 9d676de

Browse files
committed
Countly with args
1 parent 93d2d06 commit 9d676de

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

LogcatCoreLib/src/main/java/info/hannes/timber/DebugFormatTree.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ open class DebugFormatTree(private val newLogcat: Boolean = true) : Timber.Debug
3737
)
3838
}
3939

40-
// if there is an JSON string, try to print out pretty
4140
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
4241
var localMessage = message.trim()
4342
if (localMessage.startsWith("{") && localMessage.endsWith("}")) {
@@ -49,4 +48,5 @@ open class DebugFormatTree(private val newLogcat: Boolean = true) : Timber.Debug
4948
}
5049
super.log(priority, tag, "$method: $localMessage", t)
5150
}
51+
5252
}

LogcatCountlyLib/src/main/java/info/hannes/countly/Analytics.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ class Analytics : IAnalytics {
1919
return countlyInstance.isInitialized
2020
}
2121

22-
override fun recordEvent(event: String) {
22+
private fun toPair(vararg args: Any?) = args.map { param -> Pair(param.toString(), param.toString()) }
23+
24+
override fun recordEvent(event: String, vararg args: Any?) {
2325
if (isInitialized()) {
24-
countlyInstance.events().recordEvent(event, segmentation, 1)
26+
countlyInstance.events().recordEvent(event, segmentation.plus(toPair(args)), 1)
2527
}
2628
}
2729

28-
override fun recordError(message: String) {
30+
override fun recordError(message: String, vararg args: Any?) {
2931
if (isInitialized()) {
3032
countlyInstance.crashes().recordHandledException(RuntimeException(message))
3133
}
@@ -37,7 +39,7 @@ class Analytics : IAnalytics {
3739
}
3840
}
3941

40-
override fun recordWarning(message: String) {
42+
override fun recordWarning(message: String, vararg args: Any?) {
4143
if (isInitialized()) {
4244
countlyInstance.crashes().recordHandledException(RuntimeException(message))
4345
}

LogcatCountlyLib/src/main/java/info/hannes/countly/IAnalytics.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ interface IAnalytics {
66

77
fun isInitialized(): Boolean
88

9-
fun recordEvent(event: String)
9+
fun recordEvent(event: String, vararg args: Any?)
1010

11-
fun recordWarning(message: String)
11+
fun recordWarning(message: String, vararg args: Any?)
1212

13-
fun recordError(message: String)
13+
fun recordError(message: String, vararg args: Any?)
1414

1515
fun recordError(throwable: Throwable)
1616

LogcatCountlyLib/src/main/java/info/hannes/timber/CountlyTree.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class CountlyTree(private val analytics: Analytics, private val serverIgnoreToke
3131

3232
when {
3333
t != null -> analytics.recordError(t)
34-
priority == Log.WARN -> analytics.recordEvent(localMessage)
35-
else -> analytics.recordError(localMessage)
34+
priority == Log.WARN -> analytics.recordEvent(localMessage, args)
35+
else -> analytics.recordError(localMessage, args)
3636
}
3737
}
3838

0 commit comments

Comments
 (0)