Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
1a9e884c
Commit
1a9e884c
authored
Mar 15, 2021
by
YKai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:ydl-net组件升级,增加接口返回错误埋点
parent
bf9d9ff1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
371 additions
and
7 deletions
+371
-7
config.gradle
config.gradle
+5
-4
build.gradle
ydl-net/build.gradle
+0
-1
ApiUtil.kt
ydl-net/src/main/java/com/ydl/ydlnet/builder/api/ApiUtil.kt
+29
-0
NetApi.kt
ydl-net/src/main/java/com/ydl/ydlnet/builder/api/NetApi.kt
+22
-0
ApiErrorActionBean.kt
ydl-net/src/main/java/com/ydl/ydlnet/builder/bean/ApiErrorActionBean.kt
+229
-0
BaseAPIResponse.java
ydl-net/src/main/java/com/ydl/ydlnet/builder/bean/BaseAPIResponse.java
+12
-0
RequestLogInterceptor.java
ydl-net/src/main/java/com/ydl/ydlnet/builder/interceptor/log/RequestLogInterceptor.java
+15
-0
ApiErrorCountUtils.kt
ydl-net/src/main/java/com/ydl/ydlnet/utils/ApiErrorCountUtils.kt
+59
-0
ActionCountUtils.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/actionutil/ActionCountUtils.kt
+0
-2
No files found.
config.gradle
View file @
1a9e884c
...
...
@@ -33,7 +33,7 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.39.8
6
"
,
"ydl-platform"
:
"0.0.39.8
7
"
,
//第二步 若干
"ydl-webview"
:
"0.0.38.36"
,
...
...
@@ -44,7 +44,7 @@ ext {
//以下 几乎不会动
"router"
:
"0.0.1"
,
"ydl-net"
:
"0.0.3.
1
"
,
"ydl-net"
:
"0.0.3.
3
"
,
"ydl-utils"
:
"0.0.3.1"
,
]
ydl_app
=
[
...
...
@@ -114,7 +114,7 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.39.8
6
"
,
"ydl-platform"
:
"0.0.39.8
7
"
,
//第二步 若干
"ydl-webview"
:
"0.0.38.36"
,
...
...
@@ -125,7 +125,8 @@ ext {
//以下 几乎不会动
"router"
:
"0.0.1"
,
"ydl-net"
:
"0.0.3.1"
,
"ydl-utils"
:
"0.0.3.1"
,
"ydl-net"
:
"0.0.3.3"
,
"ydl-utils"
:
"0.0.3.1"
,
]
dependencies
=
[
...
...
ydl-net/build.gradle
View file @
1a9e884c
...
...
@@ -50,6 +50,5 @@ dependencies {
api
rootProject
.
ext
.
dependencies
[
"retrofit-converter-gson"
]
api
rootProject
.
ext
.
dependencies
[
"retrofit-converter-scalars"
]
api
rootProject
.
ext
.
dependencies
[
"retrofit-adapter-rxjava2"
]
}
ydl-net/src/main/java/com/ydl/ydlnet/builder/api/ApiUtil.kt
0 → 100644
View file @
1a9e884c
package
com.ydl.ydlnet.builder.api
import
com.google.gson.Gson
import
com.ydl.ydlnet.YDLHttpUtils.Companion.obtainApi
import
com.ydl.ydlnet.builder.bean.ApiErrorActionBean
import
com.ydl.ydlnet.builder.bean.BaseAPIResponse
import
io.reactivex.Observable
import
okhttp3.MediaType
import
okhttp3.RequestBody
/**
* Created by Ykai on 2021/3/15.
*/
class
ApiUtil
{
companion
object
{
/**
* 行为数据埋点统计
*/
fun
actionDataCount
(
actionDataParams
:
ApiErrorActionBean
):
Observable
<
BaseAPIResponse
<
String
>>
{
val
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
Gson
().
toJson
(
actionDataParams
)
)
return
obtainApi
(
NetApi
::
class
.
java
).
actionDataCount
(
body
)
}
}
}
\ No newline at end of file
ydl-net/src/main/java/com/ydl/ydlnet/builder/api/NetApi.kt
0 → 100644
View file @
1a9e884c
package
com.ydl.ydlnet.builder.api
import
com.ydl.ydlnet.builder.bean.BaseAPIResponse
import
io.reactivex.Observable
import
okhttp3.RequestBody
import
retrofit2.http.Body
import
retrofit2.http.Headers
import
retrofit2.http.POST
/**
* Created by Ykai on 2021/3/15.
*/
interface
NetApi
{
/**
* 行为动作埋点统计
*/
@Headers
(
"Domain-Name:JAVA_BASE_URL"
)
@POST
(
"data/bigdata/maidian/writeMaiDianData"
)
fun
actionDataCount
(
@Body
body
:
RequestBody
):
Observable
<
BaseAPIResponse
<
String
>>
}
\ No newline at end of file
ydl-net/src/main/java/com/ydl/ydlnet/builder/bean/ApiErrorActionBean.kt
0 → 100644
View file @
1a9e884c
package
com.ydl.ydlnet.builder.bean
/**
* Created by xj on 2019/6/22.
*/
class
ApiErrorActionBean
private
constructor
(
builder
:
Builder
)
{
/**
* partId : sy_1 //埋点板块
* position : psychic_advisory_click //点击事件
* type : 1 //业务类型 1.埋点
* uid : 123 //用户ID
* channel :huawei //渠道
* deviceId : //设备ID Android端取imei做md5加密,iOS端取idfa做md5加密 为32位的串
* time : 1560389634000 //事件发生时间,毫秒级时间戳
* ip : 192.168.0.1 //IP地址
* appVersion : 3.8.00 //版本号
* appId : ydl-app-android-user
* url : https://www.baidu.com //访问地址
* server : 123
* api : https://www.baidu.com/api
* manufacturer : Apple //设备厂商,字符串类型,如"Apple"
* model : iphone6 //设备型号,字符串类型,如"iphone6"
* os : iOS //操作系统,字符串类型,如"iOS"
* osVersion : 8.1.1 //操作系统版本,字符串类型,如"8.1.1"
* screenHeight : 1920 //屏幕高度,数字类型,如1920
* screenWidth : 1080 //屏幕宽度,数字类型,如1080
* wifi : 1 //网络类型:1.2G 3.3G 4.4G 5.5G 6.WIFI
* sign1 :
* sign2 :
* sign3 :
* sign4 :
* sign5 :
*/
var
partId
:
String
?
=
null
var
type
:
Int
?
=
0
var
position
:
String
?
=
null
var
uid
:
String
?
=
null
var
channel
:
String
?
=
null
var
deviceId
:
String
?
=
null
var
time
:
Long
=
0
.
toLong
()
var
ip
:
String
?
=
null
var
appVersion
:
String
?
=
null
var
appId
:
String
?
=
null
var
url
:
String
?
=
null
var
server
:
String
?
=
null
var
api
:
String
?
=
null
var
manufacturer
:
String
?
=
null
var
model
:
String
?
=
null
var
os
:
String
?
=
null
var
osVersion
:
String
?
=
null
var
screenHeight
:
Int
=
0
var
screenWidth
:
Int
=
0
var
wifi
:
Int
=
0
var
sign1
:
String
?
=
null
var
sign2
:
String
?
=
null
var
sign3
:
String
?
=
null
var
sign4
:
String
?
=
null
var
sign5
:
String
?
=
null
init
{
this
.
partId
=
builder
.
partId
this
.
type
=
builder
.
type
this
.
position
=
builder
.
position
this
.
uid
=
builder
.
uid
this
.
channel
=
builder
.
channel
this
.
deviceId
=
builder
.
deviceId
this
.
time
=
builder
.
time
this
.
ip
=
builder
.
ip
this
.
appVersion
=
builder
.
appVersion
this
.
appId
=
builder
.
appId
this
.
url
=
builder
.
url
this
.
server
=
builder
.
server
this
.
api
=
builder
.
api
this
.
manufacturer
=
builder
.
manufacturer
this
.
model
=
builder
.
model
this
.
os
=
builder
.
os
this
.
osVersion
=
builder
.
osVersion
this
.
screenHeight
=
builder
.
screenHeight
this
.
screenWidth
=
builder
.
screenWidth
this
.
wifi
=
builder
.
wifi
this
.
sign1
=
builder
.
sign1
this
.
sign2
=
builder
.
sign2
this
.
sign3
=
builder
.
sign3
this
.
sign4
=
builder
.
sign4
this
.
sign5
=
builder
.
sign5
}
class
Builder
{
internal
var
partId
:
String
?
=
""
internal
var
type
:
Int
?
=
0
internal
var
position
:
String
?
=
""
internal
var
uid
:
String
?
=
""
internal
var
channel
:
String
?=
""
internal
var
deviceId
:
String
?
=
""
internal
var
time
:
Long
=
0
.
toLong
()
internal
var
ip
:
String
?
=
""
internal
var
appVersion
:
String
?
=
""
internal
var
appId
:
String
?
=
""
internal
var
url
:
String
?
=
""
internal
var
server
:
String
?
=
""
internal
var
api
:
String
?
=
""
internal
var
manufacturer
:
String
?
=
""
internal
var
model
:
String
?
=
""
internal
var
os
:
String
?
=
""
internal
var
osVersion
:
String
?
=
""
internal
var
screenHeight
:
Int
=
0
internal
var
screenWidth
:
Int
=
0
internal
var
wifi
:
Int
=
0
internal
var
sign1
:
String
?
=
""
internal
var
sign2
:
String
?
=
""
internal
var
sign3
:
String
?
=
""
internal
var
sign4
:
String
?
=
""
internal
var
sign5
:
String
?
=
""
fun
partId
(
partId
:
String
=
""
):
Builder
{
this
.
partId
=
partId
return
this
}
fun
type
(
type
:
Int
=
0
)
:
Builder
{
this
.
type
=
type
return
this
}
fun
position
(
position
:
String
=
""
):
Builder
{
this
.
position
=
position
return
this
}
fun
uid
(
uid
:
String
=
""
):
Builder
{
this
.
uid
=
uid
return
this
}
fun
channel
(
channel
:
String
=
""
):
Builder
{
this
.
channel
=
channel
return
this
}
fun
deviceId
(
deviceId
:
String
=
""
)
:
Builder
{
this
.
deviceId
=
deviceId
return
this
}
fun
time
(
time
:
Long
=
0
.
toLong
()):
Builder
{
this
.
time
=
time
return
this
}
fun
ip
(
ip
:
String
=
""
):
Builder
{
this
.
ip
=
ip
return
this
}
fun
appVersion
(
appVersion
:
String
=
""
):
Builder
{
this
.
appVersion
=
appVersion
return
this
}
fun
appId
(
appId
:
String
=
""
):
Builder
{
this
.
appId
=
appId
return
this
}
fun
url
(
url
:
String
=
""
):
Builder
{
this
.
url
=
url
return
this
}
fun
server
(
server
:
String
=
""
):
Builder
{
this
.
server
=
server
return
this
}
fun
api
(
api
:
String
=
""
):
Builder
{
this
.
api
=
api
return
this
}
fun
manufacturer
(
manufacturer
:
String
=
""
):
Builder
{
this
.
manufacturer
=
manufacturer
return
this
}
fun
model
(
model
:
String
=
""
):
Builder
{
this
.
model
=
model
return
this
}
fun
os
(
os
:
String
=
""
):
Builder
{
this
.
os
=
os
return
this
}
fun
osVersion
(
osVersion
:
String
=
""
):
Builder
{
this
.
osVersion
=
osVersion
return
this
}
fun
screenHeight
(
screenHeight
:
Int
=
0
):
Builder
{
this
.
screenHeight
=
screenHeight
return
this
}
fun
screenWidth
(
screenWidth
:
Int
=
0
):
Builder
{
this
.
screenWidth
=
screenWidth
return
this
}
fun
wifi
(
wifi
:
Int
=
0
):
Builder
{
this
.
wifi
=
wifi
return
this
}
fun
sign1
(
sign1
:
String
=
""
):
Builder
{
this
.
sign1
=
sign1
return
this
}
fun
sign2
(
sign2
:
String
=
""
):
Builder
{
this
.
sign2
=
sign2
return
this
}
fun
sign3
(
sign3
:
String
=
""
):
Builder
{
this
.
sign3
=
sign3
return
this
}
fun
sign4
(
sign4
:
String
=
""
):
Builder
{
this
.
sign4
=
sign4
return
this
}
fun
sign5
(
sign5
:
String
=
""
):
Builder
{
this
.
sign5
=
sign5
return
this
}
fun
build
()
:
ApiErrorActionBean
{
return
ApiErrorActionBean
(
this
)
}
}
}
\ No newline at end of file
ydl-net/src/main/java/com/ydl/ydlnet/builder/bean/BaseAPIResponse.java
0 → 100644
View file @
1a9e884c
package
com
.
ydl
.
ydlnet
.
builder
.
bean
;
/**
* 基础返回数据类(java接口使用)
* Created by Dog on 2015/5/8.
*/
public
class
BaseAPIResponse
<
T
>
{
public
String
code
;
public
String
msg
;
public
T
data
;
}
\ No newline at end of file
ydl-net/src/main/java/com/ydl/ydlnet/builder/interceptor/log/RequestLogInterceptor.java
View file @
1a9e884c
...
...
@@ -2,6 +2,7 @@ package com.ydl.ydlnet.builder.interceptor.log;
import
android.support.annotation.Nullable
;
import
com.ydl.ydlnet.utils.ApiErrorCountUtils
;
import
com.ydl.ydlnet.utils.CharacterHandler
;
import
com.ydl.ydlnet.utils.NetLogUtils
;
import
com.ydl.ydlnet.utils.UrlEncoderUtils
;
...
...
@@ -86,8 +87,22 @@ public class RequestLogInterceptor implements Interceptor {
mPrinter
.
printFileResponse
(
TimeUnit
.
NANOSECONDS
.
toMillis
(
t2
-
t1
),
isSuccessful
,
code
,
header
,
segmentList
,
message
,
url
);
}
}
else
{
int
code
=
originalResponse
.
code
();
// 接口返回错误的情况下,埋点告诉服务器原因
if
(
code
!=
200
){
String
params
=
""
;
Request
rq
=
originalResponse
.
request
();
if
(
rq
.
method
().
equals
(
"GET"
)){
params
=
rq
.
url
().
query
();
}
else
if
(
rq
.
method
().
equals
(
"POST"
)){
params
=
parseParams
(
rq
);
}
String
message
=
originalResponse
.
message
();
ApiErrorCountUtils
.
Companion
.
baiDuCount
(
"pardId-ydl_user_error_business"
,
"error_log"
,
params
,
message
);
}
}
return
originalResponse
;
}
...
...
ydl-net/src/main/java/com/ydl/ydlnet/utils/ApiErrorCountUtils.kt
0 → 100644
View file @
1a9e884c
package
com.ydl.ydlnet.utils
import
android.annotation.SuppressLint
import
android.util.Log
import
com.ydl.ydlnet.builder.api.ApiUtil
import
com.ydl.ydlnet.builder.bean.ApiErrorActionBean
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
/**
* Created by Ykai on 2021/3/15.
*/
class
ApiErrorCountUtils
{
companion
object
{
private
const
val
TAG
:
String
=
"ActionCountUtils"
/**
* 接口返回错误埋点调用该方法
* @param partId pardId-ydl_user_error_business
* @param position error_log
* @param sign1 访问接口对应的参数
* @param sign2 接口返回的错误信息
*/
fun
baiDuCount
(
partId
:
String
,
position
:
String
,
sign1
:
String
,
sign2
:
String
)
{
val
actionDataParams
=
ApiErrorActionBean
.
Builder
()
actionDataParams
.
partId
=
partId
actionDataParams
.
position
=
position
actionDataParams
.
sign1
=
sign1
actionDataParams
.
sign2
=
sign2
//请求
request
(
actionDataParams
.
build
())
}
/**
* 传入ActionDataParams参数,访问接口
*/
@SuppressLint
(
"CheckResult"
)
private
fun
request
(
actionDataBean
:
ApiErrorActionBean
)
{
try
{
ApiUtil
.
actionDataCount
(
actionDataBean
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
Log
.
i
(
TAG
,
it
.
data
)
})
{
Log
.
i
(
TAG
,
it
.
toString
())
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
}
}
\ No newline at end of file
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/actionutil/ActionCountUtils.kt
View file @
1a9e884c
package
com.ydl.ydlcommon.utils.actionutil
//import com.bun.miitmdid.content.ContextKeeper
//import com.ydl.devicesidlib.DemoHelper
import
android.annotation.SuppressLint
import
android.content.Context
import
android.net.ConnectivityManager
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment