shushu加入 common 和 user param
This commit is contained in:
parent
7a7af80d31
commit
1b80c05503
|
|
@ -87,10 +87,12 @@ object StatisticUtil {
|
|||
|
||||
override fun setCommonParams(params: Map<String, Any>) {
|
||||
FireBaseManager.instance().setCommonParams(params)
|
||||
ShushuManager.instance().setCommonParams(params)
|
||||
}
|
||||
|
||||
override fun setUserParams(params: Map<String, Any>) {
|
||||
FireBaseManager.instance().setUserParams(params)
|
||||
ShushuManager.instance().setUserParams(params)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import cn.thinkingdata.analytics.TDAnalytics.TDAutoTrackEventType
|
|||
import cn.thinkingdata.analytics.TDConfig
|
||||
import cn.thinkingdata.analytics.ThinkingAnalyticsSDK
|
||||
import com.ama.core.architecture.BaseApp
|
||||
import com.ama.core.architecture.util.AndroidUtil.Companion.gson
|
||||
import com.gamedog.statisticreporter.StatisticLogger
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
|
|
@ -108,7 +110,46 @@ class ShushuManager private constructor() {
|
|||
TDAnalytics.enableAutoTrack(TDAutoTrackEventType.APP_START or TDAutoTrackEventType.APP_END or TDAutoTrackEventType.APP_INSTALL )
|
||||
}
|
||||
|
||||
private fun mapToJsonObject(map: Map<String, Any>): JSONObject {
|
||||
return try {
|
||||
val jsonString = gson.toJson(map)
|
||||
JSONObject(jsonString)
|
||||
} catch (e: Exception) {
|
||||
StatisticLogger.e("Map转JSONObject失败: ${e.message}")
|
||||
JSONObject()
|
||||
}
|
||||
}
|
||||
|
||||
fun setCommonParams(params: Map<String, Any>) {
|
||||
try {
|
||||
// 将Map转换为JSONObject
|
||||
val jsonObject = mapToJsonObject(params)
|
||||
|
||||
// 数数SDK使用userSet设置用户属性,传入JSONObject
|
||||
TDAnalytics.setSuperProperties(jsonObject)
|
||||
|
||||
StatisticLogger.d("数数SDK公共参数设置完成: $jsonObject")
|
||||
|
||||
} catch (e: Exception) {
|
||||
StatisticLogger.e("数数SDK设置公共参数失败", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun setUserParams(params: Map<String, Any>) {
|
||||
try {
|
||||
// 将Map转换为JSONObject
|
||||
val jsonObject = mapToJsonObject(params)
|
||||
|
||||
// 数数SDK使用userSet设置用户属性,传入JSONObject
|
||||
TDAnalytics.userSet(jsonObject)
|
||||
|
||||
StatisticLogger.d("数数SDK用户参数设置完成: $jsonObject")
|
||||
|
||||
} catch (e: Exception) {
|
||||
StatisticLogger.e("数数SDK设置用户参数失败", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue