Commit a518e9b8 by 刘鹏

Merge branch 'feat/qj/event_point' into 'd/v4.4.05'

事件埋点修改

See merge request app_android_lib/YDL-Component!269
parents 49b3ef50 4673e6c2
......@@ -48,6 +48,7 @@ import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import com.ydl.ydl_av.voice.manager.YDLVoiceManager
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydlcommon.app.Apm
import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.modular.findRouteService
......@@ -318,6 +319,7 @@ class AudioHomeActivity :
if (err == 0 || err == 18) {
return
}
Apm.reportEvent("agora_android", "occur_error", "$err")
channelId?.let { YDLavManager.instances.callEndStatusUpdate(it, 4, "频道的错误回调信息$err") }
}
......@@ -369,8 +371,8 @@ class AudioHomeActivity :
override fun onRtcStats(stats: IRtcEngineEventHandler.RtcStats?) {
super.onRtcStats(stats)
writeAgoraLog("声网onRtcStats:users:${stats?.users}")
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "声网onRtcStats:users:${stats?.users} channelId:${channelId}")
// AliYunRichLogsHelper.getInstance()
// .sendRichLog(AliYunLogConfig.AGORA, "声网onRtcStats:users:${stats?.users} channelId:${channelId}")
// 不需要移动端做离开房间逻辑,服务端会判断进行踢人逻辑
//因为用户端直接加入了频道,防止该回调执行时,专家还未加入频道,因此在连接成功之后,才进行频道人数判断
// if (isConnectSuccess && null != stats?.users && stats.users == 1) {
......@@ -388,6 +390,7 @@ class AudioHomeActivity :
override fun onConnectionStateChanged(state: Int, reason: Int) {
super.onConnectionStateChanged(state, reason)
// 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑
Apm.reportEvent("agora_android", "rtc_connection_failure", "$state,$reason")
if (reason == 3) {
callEventSave("50", "通话结束:网络连接被服务器中止 该情况现在是因为后端踢人逻辑,原因(${reason}")
writeAgoraLog("通话结束:网络连接被服务器中止 该情况现在是因为后端踢人逻辑,原因(${reason})")
......
......@@ -166,7 +166,7 @@ class YDLavManager {
LogUtil.e("[agora]呼叫${response?.calleeId}用户失败:${response?.response}")
AliYunRichLogsHelper.getInstance().sendRichLog(
AliYunLogConfig.AGORA,
"呼叫${response?.calleeId}用户失败:${response?.response}"
"呼叫${response?.calleeId}用户失败:${response?.response},${errorCode}"
)
val dimension = hashMapOf(
"call" to "call_fail",
......@@ -432,7 +432,7 @@ class YDLavManager {
override fun onFailure(msg: String?) {
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")
writeAgoraLog(
......@@ -449,6 +449,7 @@ class YDLavManager {
}
})
} else {
Apm.reportEvent("rtm_android", "login_failure", "${it.code},${it.msg}")
LogUtil.e("声网token获取失败uid:" + userId + " error:" + it.msg)
LogHelper.getInstance()
.writeLogSync("声网token获取失败uid:" + userId + " error:" + it.msg)
......
......@@ -345,12 +345,12 @@ public class WatchMessagePictureActivity extends UI {
@Override
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
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 {
@Override
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
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
Apm.INSTANCE.reportEvent("yxim_android", "attchment_error", "云信IM收取消息" + throwable.getMessage());
}
});
downloading = true;
......
......@@ -1367,7 +1367,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
public void onFailed(int code) {
if (msg != null) {
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 {
@Override
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
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 {
@Override
public void onFailed(int code) {
String sessionId = item.getSessionId();
Apm.INSTANCE.reportCustom("yx_revoke_error", "sessionId:" + sessionId, new Exception(String.valueOf(code)));
Apm.INSTANCE.reportEvent("yxim_android", "revoke_error", "云信IM回撤消息失败" + code);
if (code == ResponseCode.RES_OVERDUE) {
ToastHelper.showToast(container.activity, R.string.im_revoke_failed);
} else {
......
......@@ -82,12 +82,12 @@ public class MsgViewHolderAudio extends MsgViewHolderBase {
@Override
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
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
@Override
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
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
}
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("未知异常"))
}
......
......@@ -507,7 +507,7 @@ object OneKeyLoginHelp {
"一键登录失败 msg:${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()
}
}, {
......@@ -515,7 +515,7 @@ object OneKeyLoginHelp {
AliYunLogConfig.LOGIN,
"一键登录Error msg:${it.message}"
)
Apm.reportCustom("login", "oneKey_error", it)
Apm.reportEvent("login_android", "oneKey_error", "一键登录失败报错${it.message}")
ToastUtil.toastShort(it.message)
mPhoneNumberAuthHelper?.hideLoginLoading()
})
......@@ -527,7 +527,7 @@ object OneKeyLoginHelp {
}
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)
mIsGetTokenSuccess = false
val tokenRet = TokenRet.fromJson(s)
......
......@@ -115,12 +115,12 @@ class InputPassWordPresenterImpl :
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.LOGIN, "手机号密码 登录失败 msg: ${it.msg}")
ToastUtil.toastShort(it.msg)
Apm.reportCustom("login", "password_error", Exception("密码登录失败,$phoneCountryCode-$phone"))
Apm.reportEvent("login_android", "password_error", "密码登录失败,$phoneCountryCode-$phone")
mView.startAnim()
} else {
if (it.data.userInfo?.user_type == 2) {
mView.showNormalDialog()
Apm.reportCustom("login", "isexpert", Exception("登录—专家帐号,$phoneCountryCode-$phone"))
Apm.reportEvent("login_android", "isexpert", "登录—专家帐号,$phoneCountryCode-$phone")
} else {
saveUserData(it.data)
if (it.data.firstLogin == 1) {//第一次登录:是注册
......@@ -140,7 +140,7 @@ class InputPassWordPresenterImpl :
}
}, {
YdlCommonOut.showToast(it.message!!)
Apm.reportCustom("login", "password_error", it)
Apm.reportEvent("login_android", "password_error", "密码登录失败${it.message}")
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.LOGIN, "手机号密码 Error msg: ${it.message}")
......
......@@ -168,7 +168,7 @@ class LoginPresenterImpl(view: ILoginContract.View) :
if (it.data.isRegistered == 1) {
mView.showLoading(false)
mView.showHasBindedDialog()
Apm.reportCustom("login", "mobile_isbind", Exception("登录-手机被绑定,$countryCode-$phone"))
Apm.reportEvent("login_android", "mobile_isbind", "登录-手机被绑定,$countryCode-$phone")
} else {
mView.checkPhoneStatusSuccess(it.data, phone)
}
......@@ -176,7 +176,7 @@ class LoginPresenterImpl(view: ILoginContract.View) :
if (it.data.isDoctor == 1) {//是专家账号
mView.showLoading(false)
mView.showNormalDialog()
Apm.reportCustom("login", "isexpert", Exception("登录—专家帐号,$countryCode-$phone"))
Apm.reportEvent("login_android", "isexpert", "登录—专家帐号,$countryCode-$phone")
} else {
mView.checkPhoneStatusSuccess(it.data, phone)
}
......@@ -214,7 +214,7 @@ class LoginPresenterImpl(view: ILoginContract.View) :
.subscribe({
mView.dismissProgressView()
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)
return@subscribe
}
......@@ -268,7 +268,7 @@ class LoginPresenterImpl(view: ILoginContract.View) :
}, {
mView.dismissProgressView()
Apm.reportCustom("login", "third_login_error", it)
Apm.reportEvent("login", "third_login_error", it.message ?: "")
YdlCommonOut.showToast(it.message!!)
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.LOGIN, media.getName() + "登录失败")
......
......@@ -47,12 +47,12 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base
mView.startCountdown(60)
} else {
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)
}
}, {
mView.startAnim()
Apm.reportCustom("login", "getcode_error", it)
Apm.reportEvent("login", "getcode_error", "获取验证码失败${it.message}")
ToastUtil.toastShort(it.message)
})
}
......@@ -115,13 +115,13 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base
} else {
ToastUtil.toastShort(it.msg)//服务端返回{验证码错误&异常}信息
// 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.startAnim()
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)
})
......@@ -193,12 +193,12 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base
} else {
ToastUtil.toastShort(it.msg)//服务端返回{验证码错误&异常}信息
// 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.startAnim()
Apm.reportCustom("login", "code_error", it)
Apm.reportEvent("login", "code_error", it.message ?: "")
ToastUtil.toastShort(it.message)
})
}
......
......@@ -4,9 +4,11 @@ import android.content.Context
import com.apm.insight.MonitorCrash
import com.apm.insight.log.VLog
import com.bytedance.apm.insight.ApmInsight
import com.bytedance.apm.insight.ApmInsightAgent
import com.bytedance.apm.insight.ApmInsightInitConfig
import com.bytedance.apm.insight.IDynamicParams
import com.meituan.android.walle.WalleChannelReader
import org.json.JSONObject
object Apm {
......@@ -46,6 +48,33 @@ object Apm {
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() {
......
......@@ -194,16 +194,16 @@ class HttpConfig {
val message = resp.message()
val api = req.url().encodedPath()
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 {
try {
val body = resp.body() ?: return@Interceptor resp
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 fromJson = Gson().fromJson<BaseAPIResponse<Any>>(readString, BaseAPIResponse::class.java)
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) {
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