Commit 4673e6c2 by 万齐军

事件埋点修改

parent 385cfcd1
...@@ -48,6 +48,7 @@ import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler ...@@ -48,6 +48,7 @@ import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import com.ydl.ydl_av.voice.manager.YDLVoiceManager import com.ydl.ydl_av.voice.manager.YDLVoiceManager
import com.ydl.ydl_image.config.SimpleImageOpConfiger import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydlcommon.app.Apm
import com.ydl.ydlcommon.base.BaseMvpActivity import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.modular.findRouteService import com.ydl.ydlcommon.modular.findRouteService
...@@ -318,6 +319,7 @@ class AudioHomeActivity : ...@@ -318,6 +319,7 @@ class AudioHomeActivity :
if (err == 0 || err == 18) { if (err == 0 || err == 18) {
return return
} }
Apm.reportEvent("agora_android", "occur_error", "$err")
channelId?.let { YDLavManager.instances.callEndStatusUpdate(it, 4, "频道的错误回调信息$err") } channelId?.let { YDLavManager.instances.callEndStatusUpdate(it, 4, "频道的错误回调信息$err") }
} }
...@@ -369,8 +371,8 @@ class AudioHomeActivity : ...@@ -369,8 +371,8 @@ class AudioHomeActivity :
override fun onRtcStats(stats: IRtcEngineEventHandler.RtcStats?) { override fun onRtcStats(stats: IRtcEngineEventHandler.RtcStats?) {
super.onRtcStats(stats) super.onRtcStats(stats)
writeAgoraLog("声网onRtcStats:users:${stats?.users}") writeAgoraLog("声网onRtcStats:users:${stats?.users}")
AliYunRichLogsHelper.getInstance() // AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "声网onRtcStats:users:${stats?.users} channelId:${channelId}") // .sendRichLog(AliYunLogConfig.AGORA, "声网onRtcStats:users:${stats?.users} channelId:${channelId}")
// 不需要移动端做离开房间逻辑,服务端会判断进行踢人逻辑 // 不需要移动端做离开房间逻辑,服务端会判断进行踢人逻辑
//因为用户端直接加入了频道,防止该回调执行时,专家还未加入频道,因此在连接成功之后,才进行频道人数判断 //因为用户端直接加入了频道,防止该回调执行时,专家还未加入频道,因此在连接成功之后,才进行频道人数判断
// if (isConnectSuccess && null != stats?.users && stats.users == 1) { // if (isConnectSuccess && null != stats?.users && stats.users == 1) {
...@@ -388,6 +390,7 @@ class AudioHomeActivity : ...@@ -388,6 +390,7 @@ class AudioHomeActivity :
override fun onConnectionStateChanged(state: Int, reason: Int) { override fun onConnectionStateChanged(state: Int, reason: Int) {
super.onConnectionStateChanged(state, reason) super.onConnectionStateChanged(state, reason)
// 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑 // 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑
Apm.reportEvent("agora_android", "rtc_connection_failure", "$state,$reason")
if (reason == 3) { if (reason == 3) {
callEventSave("50", "通话结束:网络连接被服务器中止 该情况现在是因为后端踢人逻辑,原因(${reason}") callEventSave("50", "通话结束:网络连接被服务器中止 该情况现在是因为后端踢人逻辑,原因(${reason}")
writeAgoraLog("通话结束:网络连接被服务器中止 该情况现在是因为后端踢人逻辑,原因(${reason})") writeAgoraLog("通话结束:网络连接被服务器中止 该情况现在是因为后端踢人逻辑,原因(${reason})")
......
...@@ -166,7 +166,7 @@ class YDLavManager { ...@@ -166,7 +166,7 @@ class YDLavManager {
LogUtil.e("[agora]呼叫${response?.calleeId}用户失败:${response?.response}") LogUtil.e("[agora]呼叫${response?.calleeId}用户失败:${response?.response}")
AliYunRichLogsHelper.getInstance().sendRichLog( AliYunRichLogsHelper.getInstance().sendRichLog(
AliYunLogConfig.AGORA, AliYunLogConfig.AGORA,
"呼叫${response?.calleeId}用户失败:${response?.response}" "呼叫${response?.calleeId}用户失败:${response?.response},${errorCode}"
) )
val dimension = hashMapOf( val dimension = hashMapOf(
"call" to "call_fail", "call" to "call_fail",
...@@ -432,7 +432,7 @@ class YDLavManager { ...@@ -432,7 +432,7 @@ class YDLavManager {
override fun onFailure(msg: String?) { override fun onFailure(msg: String?) {
if (msg != "LOGIN_ERR_ALREADY_LOGGED_IN") { if (msg != "LOGIN_ERR_ALREADY_LOGGED_IN") {
Apm.reportCustom("agora_login_error", msg ?: "", Exception(msg)) Apm.reportEvent("rtm_android", "connectionstate_error", msg ?: "")
} }
LogUtil.e("[agora]实时消息登录失败:$msg") LogUtil.e("[agora]实时消息登录失败:$msg")
writeAgoraLog( writeAgoraLog(
...@@ -449,6 +449,7 @@ class YDLavManager { ...@@ -449,6 +449,7 @@ class YDLavManager {
} }
}) })
} else { } else {
Apm.reportEvent("rtm_android", "login_failure", "${it.code},${it.msg}")
LogUtil.e("声网token获取失败uid:" + userId + " error:" + it.msg) LogUtil.e("声网token获取失败uid:" + userId + " error:" + it.msg)
LogHelper.getInstance() LogHelper.getInstance()
.writeLogSync("声网token获取失败uid:" + userId + " error:" + it.msg) .writeLogSync("声网token获取失败uid:" + userId + " error:" + it.msg)
......
...@@ -345,12 +345,12 @@ public class WatchMessagePictureActivity extends UI { ...@@ -345,12 +345,12 @@ public class WatchMessagePictureActivity extends UI {
@Override @Override
public void onFailed(int i) { public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i))); Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + i);
} }
@Override @Override
public void onException(Throwable throwable) { public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable); Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + throwable.getMessage());
} }
}); });
} }
......
...@@ -509,12 +509,12 @@ public class WatchVideoActivity extends UI implements Callback { ...@@ -509,12 +509,12 @@ public class WatchVideoActivity extends UI implements Callback {
@Override @Override
public void onFailed(int i) { public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i))); Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + i);
} }
@Override @Override
public void onException(Throwable throwable) { public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable); Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + throwable.getMessage());
} }
}); });
downloading = true; downloading = true;
......
...@@ -1367,7 +1367,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy { ...@@ -1367,7 +1367,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
public void onFailed(int code) { public void onFailed(int code) {
if (msg != null) { if (msg != null) {
sendFailWithBlackList(code, msg); sendFailWithBlackList(code, msg);
Apm.INSTANCE.reportCustom("yx_sendmessage_error", "sessionId:" + msg.getSessionId(), new Exception(String.valueOf(code))); Apm.INSTANCE.reportEvent("yxim_android", "sendmessage_error", " 云信IM发送消息失败" + code + msg);
} }
} }
......
...@@ -849,12 +849,12 @@ public class MessageListPanelEx { ...@@ -849,12 +849,12 @@ public class MessageListPanelEx {
@Override @Override
public void onFailed(int i) { public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i))); Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + i);
} }
@Override @Override
public void onException(Throwable throwable) { public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable); Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + throwable.getMessage());;
} }
}); });
} }
...@@ -1163,8 +1163,7 @@ public class MessageListPanelEx { ...@@ -1163,8 +1163,7 @@ public class MessageListPanelEx {
@Override @Override
public void onFailed(int code) { public void onFailed(int code) {
String sessionId = item.getSessionId(); Apm.INSTANCE.reportEvent("yxim_android", "revoke_error", "云信IM回撤消息失败" + code);
Apm.INSTANCE.reportCustom("yx_revoke_error", "sessionId:" + sessionId, new Exception(String.valueOf(code)));
if (code == ResponseCode.RES_OVERDUE) { if (code == ResponseCode.RES_OVERDUE) {
ToastHelper.showToast(container.activity, R.string.im_revoke_failed); ToastHelper.showToast(container.activity, R.string.im_revoke_failed);
} else { } else {
......
...@@ -82,12 +82,12 @@ public class MsgViewHolderAudio extends MsgViewHolderBase { ...@@ -82,12 +82,12 @@ public class MsgViewHolderAudio extends MsgViewHolderBase {
@Override @Override
public void onFailed(int i) { public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i))); Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + i);
} }
@Override @Override
public void onException(Throwable throwable) { public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable); Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + throwable.getMessage());
} }
}); });
......
...@@ -151,12 +151,12 @@ public abstract class MsgViewHolderBase extends RecyclerViewHolder<BaseMultiItem ...@@ -151,12 +151,12 @@ public abstract class MsgViewHolderBase extends RecyclerViewHolder<BaseMultiItem
@Override @Override
public void onFailed(int i) { public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i))); Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + i);
} }
@Override @Override
public void onException(Throwable throwable) { public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable); Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + throwable.getMessage());
} }
}); });
} }
......
...@@ -73,7 +73,7 @@ class LoginObservable(val activity: Activity, private val media: SHARE_MEDIA): O ...@@ -73,7 +73,7 @@ class LoginObservable(val activity: Activity, private val media: SHARE_MEDIA): O
} }
override fun onError(p0: SHARE_MEDIA?, p1: Int, p2: Throwable?) { override fun onError(p0: SHARE_MEDIA?, p1: Int, p2: Throwable?) {
Apm.reportCustom("login", "third_auth_error", p2 ?: Exception("${p0},$p1")) Apm.reportEvent("login_android", "third_auth_error", "三方授权失败${p2?.message ?: p1}")
observer?.onError(p2?:Throwable("未知异常")) observer?.onError(p2?:Throwable("未知异常"))
} }
......
...@@ -507,7 +507,7 @@ object OneKeyLoginHelp { ...@@ -507,7 +507,7 @@ object OneKeyLoginHelp {
"一键登录失败 msg:${it.msg}" "一键登录失败 msg:${it.msg}"
) )
ToastUtil.toastShort(it.msg) ToastUtil.toastShort(it.msg)
Apm.reportCustom("login", "oneKey_error", Exception("${it.code},${it.msg}")) Apm.reportEvent("login_android", "oneKey_error", "一键登录失败报错${it.code},${it.msg}")
mPhoneNumberAuthHelper?.hideLoginLoading() mPhoneNumberAuthHelper?.hideLoginLoading()
} }
}, { }, {
...@@ -515,7 +515,7 @@ object OneKeyLoginHelp { ...@@ -515,7 +515,7 @@ object OneKeyLoginHelp {
AliYunLogConfig.LOGIN, AliYunLogConfig.LOGIN,
"一键登录Error msg:${it.message}" "一键登录Error msg:${it.message}"
) )
Apm.reportCustom("login", "oneKey_error", it) Apm.reportEvent("login_android", "oneKey_error", "一键登录失败报错${it.message}")
ToastUtil.toastShort(it.message) ToastUtil.toastShort(it.message)
mPhoneNumberAuthHelper?.hideLoginLoading() mPhoneNumberAuthHelper?.hideLoginLoading()
}) })
...@@ -527,7 +527,7 @@ object OneKeyLoginHelp { ...@@ -527,7 +527,7 @@ object OneKeyLoginHelp {
} }
override fun onTokenFailed(s: String) { override fun onTokenFailed(s: String) {
Apm.reportCustom("login", "oneKey_error", Exception("TokenFailed:${s}")) Apm.reportEvent("login_android", "oneKey_error", "一键登录失败TokenFailed:${s}")
LogUtil.e("onTokenFailed"+s) LogUtil.e("onTokenFailed"+s)
mIsGetTokenSuccess = false mIsGetTokenSuccess = false
val tokenRet = TokenRet.fromJson(s) val tokenRet = TokenRet.fromJson(s)
......
...@@ -115,12 +115,12 @@ class InputPassWordPresenterImpl : ...@@ -115,12 +115,12 @@ class InputPassWordPresenterImpl :
AliYunRichLogsHelper.getInstance() AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.LOGIN, "手机号密码 登录失败 msg: ${it.msg}") .sendRichLog(AliYunLogConfig.LOGIN, "手机号密码 登录失败 msg: ${it.msg}")
ToastUtil.toastShort(it.msg) ToastUtil.toastShort(it.msg)
Apm.reportCustom("login", "password_error", Exception("密码登录失败,$phoneCountryCode-$phone")) Apm.reportEvent("login_android", "password_error", "密码登录失败,$phoneCountryCode-$phone")
mView.startAnim() mView.startAnim()
} else { } else {
if (it.data.userInfo?.user_type == 2) { if (it.data.userInfo?.user_type == 2) {
mView.showNormalDialog() mView.showNormalDialog()
Apm.reportCustom("login", "isexpert", Exception("登录—专家帐号,$phoneCountryCode-$phone")) Apm.reportEvent("login_android", "isexpert", "登录—专家帐号,$phoneCountryCode-$phone")
} else { } else {
saveUserData(it.data) saveUserData(it.data)
if (it.data.firstLogin == 1) {//第一次登录:是注册 if (it.data.firstLogin == 1) {//第一次登录:是注册
...@@ -140,7 +140,7 @@ class InputPassWordPresenterImpl : ...@@ -140,7 +140,7 @@ class InputPassWordPresenterImpl :
} }
}, { }, {
YdlCommonOut.showToast(it.message!!) YdlCommonOut.showToast(it.message!!)
Apm.reportCustom("login", "password_error", it) Apm.reportEvent("login_android", "password_error", "密码登录失败${it.message}")
AliYunRichLogsHelper.getInstance() AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.LOGIN, "手机号密码 Error msg: ${it.message}") .sendRichLog(AliYunLogConfig.LOGIN, "手机号密码 Error msg: ${it.message}")
......
...@@ -168,7 +168,7 @@ class LoginPresenterImpl(view: ILoginContract.View) : ...@@ -168,7 +168,7 @@ class LoginPresenterImpl(view: ILoginContract.View) :
if (it.data.isRegistered == 1) { if (it.data.isRegistered == 1) {
mView.showLoading(false) mView.showLoading(false)
mView.showHasBindedDialog() mView.showHasBindedDialog()
Apm.reportCustom("login", "mobile_isbind", Exception("登录-手机被绑定,$countryCode-$phone")) Apm.reportEvent("login_android", "mobile_isbind", "登录-手机被绑定,$countryCode-$phone")
} else { } else {
mView.checkPhoneStatusSuccess(it.data, phone) mView.checkPhoneStatusSuccess(it.data, phone)
} }
...@@ -176,7 +176,7 @@ class LoginPresenterImpl(view: ILoginContract.View) : ...@@ -176,7 +176,7 @@ class LoginPresenterImpl(view: ILoginContract.View) :
if (it.data.isDoctor == 1) {//是专家账号 if (it.data.isDoctor == 1) {//是专家账号
mView.showLoading(false) mView.showLoading(false)
mView.showNormalDialog() mView.showNormalDialog()
Apm.reportCustom("login", "isexpert", Exception("登录—专家帐号,$countryCode-$phone")) Apm.reportEvent("login_android", "isexpert", "登录—专家帐号,$countryCode-$phone")
} else { } else {
mView.checkPhoneStatusSuccess(it.data, phone) mView.checkPhoneStatusSuccess(it.data, phone)
} }
...@@ -214,7 +214,7 @@ class LoginPresenterImpl(view: ILoginContract.View) : ...@@ -214,7 +214,7 @@ class LoginPresenterImpl(view: ILoginContract.View) :
.subscribe({ .subscribe({
mView.dismissProgressView() mView.dismissProgressView()
if (it?.data == null) { if (it?.data == null) {
Apm.reportCustom("login", "third_login_error", Exception("${it.code},${it.msg}")) Apm.reportEvent("login_android", "third_login_error", "三方登录失败${it.code},${it.msg}")
ToastUtil.toastShort(it.msg) ToastUtil.toastShort(it.msg)
return@subscribe return@subscribe
} }
...@@ -268,7 +268,7 @@ class LoginPresenterImpl(view: ILoginContract.View) : ...@@ -268,7 +268,7 @@ class LoginPresenterImpl(view: ILoginContract.View) :
}, { }, {
mView.dismissProgressView() mView.dismissProgressView()
Apm.reportCustom("login", "third_login_error", it) Apm.reportEvent("login", "third_login_error", it.message ?: "")
YdlCommonOut.showToast(it.message!!) YdlCommonOut.showToast(it.message!!)
AliYunRichLogsHelper.getInstance() AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.LOGIN, media.getName() + "登录失败") .sendRichLog(AliYunLogConfig.LOGIN, media.getName() + "登录失败")
......
...@@ -47,12 +47,12 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base ...@@ -47,12 +47,12 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base
mView.startCountdown(60) mView.startCountdown(60)
} else { } else {
mView.startAnim() mView.startAnim()
Apm.reportCustom("login", "getcode_error", Exception("${phone},${it.code},${it.msg}")) Apm.reportEvent("login_android", "getcode_error", "获取验证码失败${phone},${it.code},${it.msg}")
ToastUtil.toastShort(it.msg) ToastUtil.toastShort(it.msg)
} }
}, { }, {
mView.startAnim() mView.startAnim()
Apm.reportCustom("login", "getcode_error", it) Apm.reportEvent("login", "getcode_error", "获取验证码失败${it.message}")
ToastUtil.toastShort(it.message) ToastUtil.toastShort(it.message)
}) })
} }
...@@ -115,13 +115,13 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base ...@@ -115,13 +115,13 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base
} else { } else {
ToastUtil.toastShort(it.msg)//服务端返回{验证码错误&异常}信息 ToastUtil.toastShort(it.msg)//服务端返回{验证码错误&异常}信息
// mView.startAnim() // mView.startAnim()
Apm.reportCustom("login", "bind_mobile_error", Exception("${param.countryCode}-${param.phoneNumber},${it.code},${it.msg}")) Apm.reportEvent("login_android", "bind_mobile_error", " 手机号绑定失败${param.countryCode}-${param.phoneNumber},${it.code},${it.msg}")
mView.verificationErrorCode() mView.verificationErrorCode()
} }
}, { }, {
// mView.startAnim() // mView.startAnim()
mView.verificationErrorCode() mView.verificationErrorCode()
Apm.reportCustom("login", "bind_mobile_error", it) Apm.reportEvent("login_android", "bind_mobile_error", " 手机号绑定失败${param.countryCode}-${param.phoneNumber},${it.message}")
ToastUtil.toastShort(it.message) ToastUtil.toastShort(it.message)
}) })
...@@ -193,12 +193,12 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base ...@@ -193,12 +193,12 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base
} else { } else {
ToastUtil.toastShort(it.msg)//服务端返回{验证码错误&异常}信息 ToastUtil.toastShort(it.msg)//服务端返回{验证码错误&异常}信息
// mView.startAnim() // mView.startAnim()
Apm.reportCustom("login", "code_error", Exception("${phoneCountryCode}-${phone},${it.code},${it.msg}")) Apm.reportEvent("login_android", "code_error", "验证码登录失败${phoneCountryCode}-${phone},${it.code},${it.msg}")
mView.verificationErrorCode() mView.verificationErrorCode()
} }
}, { }, {
mView.startAnim() mView.startAnim()
Apm.reportCustom("login", "code_error", it) Apm.reportEvent("login", "code_error", it.message ?: "")
ToastUtil.toastShort(it.message) ToastUtil.toastShort(it.message)
}) })
} }
......
...@@ -4,9 +4,11 @@ import android.content.Context ...@@ -4,9 +4,11 @@ import android.content.Context
import com.apm.insight.MonitorCrash import com.apm.insight.MonitorCrash
import com.apm.insight.log.VLog import com.apm.insight.log.VLog
import com.bytedance.apm.insight.ApmInsight import com.bytedance.apm.insight.ApmInsight
import com.bytedance.apm.insight.ApmInsightAgent
import com.bytedance.apm.insight.ApmInsightInitConfig import com.bytedance.apm.insight.ApmInsightInitConfig
import com.bytedance.apm.insight.IDynamicParams import com.bytedance.apm.insight.IDynamicParams
import com.meituan.android.walle.WalleChannelReader import com.meituan.android.walle.WalleChannelReader
import org.json.JSONObject
object Apm { object Apm {
...@@ -46,6 +48,33 @@ object Apm { ...@@ -46,6 +48,33 @@ object Apm {
crash?.reportCustomErr(msg, type, throwable) crash?.reportCustomErr(msg, type, throwable)
} }
} }
fun reportEvent(event: String, dimension: String, value: String) {
try {
if (hasInit) {
val d = hashMapOf(dimension to value)
ApmInsightAgent.monitorEvent(event, d, hashMapOf())
}
} catch (throwable: Throwable) {
VLog.e("reportEvent", throwable.message)
}
}
fun reportEventWithExt(event: String, dimension: String, value: String, ext: Map<String, String>) {
try {
if (hasInit) {
val d = hashMapOf(dimension to value)
if (ext.isNotEmpty()) {
val json = JSONObject(ext)
ApmInsightAgent.monitorEvent(event, d, hashMapOf(), json)
} else {
ApmInsightAgent.monitorEvent(event, d, hashMapOf())
}
}
} catch (throwable: Throwable) {
VLog.e("reportEvent", throwable.message)
}
}
} }
private class ApmParams(val crash: MonitorCrash?, val uidCall: () -> String?) : IDynamicParams() { private class ApmParams(val crash: MonitorCrash?, val uidCall: () -> String?) : IDynamicParams() {
......
...@@ -194,16 +194,16 @@ class HttpConfig { ...@@ -194,16 +194,16 @@ class HttpConfig {
val message = resp.message() val message = resp.message()
val api = req.url().encodedPath() val api = req.url().encodedPath()
if (!resp.isSuccessful) { if (!resp.isSuccessful) {
Apm.reportCustom("network_request_error", "${api}(${code},${message})", Exception("${api}(${code},${message})")) Apm.reportEventWithExt("network_api", "resp_fail", api, mapOf("code" to code.toString(), "msg" to message))
} else { } else {
try { try {
val body = resp.body() ?: return@Interceptor resp val body = resp.body() ?: return@Interceptor resp
val buffer = body.source().buffer() val buffer = body.source().buffer()
if(!isPlaintext(buffer)) return@Interceptor resp if (!isPlaintext(buffer)) return@Interceptor resp
val readString = buffer.clone().readString(Charset.forName("UTF-8")) val readString = buffer.clone().readString(Charset.forName("UTF-8"))
val fromJson = Gson().fromJson<BaseAPIResponse<Any>>(readString, BaseAPIResponse::class.java) val fromJson = Gson().fromJson<BaseAPIResponse<Any>>(readString, BaseAPIResponse::class.java)
if (fromJson.code != "200" && fromJson.code != "0") { if (fromJson.code != "200" && fromJson.code != "0") {
Apm.reportCustom("network_business_error", "${api}(${fromJson.code},${fromJson.msg})", Exception("${api}(${fromJson.code},${fromJson.msg})")) Apm.reportEventWithExt("network_api", "business_fail", api, mapOf("code" to code.toString(), "msg" to message))
} }
} catch (throwable: Throwable) { } catch (throwable: Throwable) {
LogUtil.e(throwable.message) LogUtil.e(throwable.message)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment