提交 7359ba44 编写于 作者: wuyunfeng's avatar wuyunfeng

添加几个分析字段

上级 6f08e1da
...@@ -158,6 +158,7 @@ object SessionProcessTerm { ...@@ -158,6 +158,7 @@ object SessionProcessTerm {
StructField("module_class2", StringType, true), StructField("module_class2", StringType, true),
StructField("device_brand", StringType, true), StructField("device_brand", StringType, true),
StructField("device_model", StringType, true), StructField("device_model", StringType, true),
StructField("view_class", StringType, true),
StructField("view_path", StringType, true), StructField("view_path", StringType, true),
StructField("alternate_info", StringType, true), StructField("alternate_info", StringType, true),
StructField("first_app_version", StringType, true), StructField("first_app_version", StringType, true),
...@@ -226,7 +227,7 @@ object SessionProcessTerm { ...@@ -226,7 +227,7 @@ object SessionProcessTerm {
|(cast(c.session_end_time as bigint)-cast(c.session_begin_time as bigint))/1000 session_time_diff, |(cast(c.session_end_time as bigint)-cast(c.session_begin_time as bigint))/1000 session_time_diff,
|a.pre_session_id, |a.pre_session_id,
|case when a.user_id=0 then a.device_token else a.user_id end user_identity_id, |case when a.user_id=0 then a.device_token else a.user_id end user_identity_id,
|a.view_path, a.alternate_info, a.first_app_version,a.service_name,a.tag8,a.tag9,a.component_tag |a.view_class,a.view_path, a.alternate_info, a.first_app_version,a.service_name,a.tag8,a.tag9,a.component_tag
|from refer_result_table a |from refer_result_table a
|left join refer_menu_table b on a.session_id=b.session_id and a.device_token=b.device_token and a.user_id=b.user_id and a.menu_code=b.menu_code and a.created_time=b.created_time and a.action_type in('ACTION_VIEW','ACTION_HEART') |left join refer_menu_table b on a.session_id=b.session_id and a.device_token=b.device_token and a.user_id=b.user_id and a.menu_code=b.menu_code and a.created_time=b.created_time and a.action_type in('ACTION_VIEW','ACTION_HEART')
|left join session_end_table c on a.session_id = c.session_id |left join session_end_table c on a.session_id = c.session_id
...@@ -428,7 +429,7 @@ class SessionProcessTerm { ...@@ -428,7 +429,7 @@ class SessionProcessTerm {
var app_version = StringUtils.getNotNullString(row.getAs[String]("app_version")) var app_version = StringUtils.getNotNullString(row.getAs[String]("app_version"))
var is_need = true //添加一个字段,下一步计算时长使用, var is_need = true //添加一个字段,下一步计算时长使用,
// 针对3.4.5之后的版本,使用ACTION_ACTIVITY_RESUME计算页面起止 // 针对3.4.5之后的版本,使用ACTION_ACTIVITY_RESUME计算页面起止
if(app_version.length<8 && app_version>="3.4.5" && action=="ACTION_ACTIVITY_CREATE"){ if(app_version.length<8 && app_version>="3.4.5" && action=="ACTION_ACTIVITY_CREATE" && menu_code_new!="017" ){
is_need = false is_need = false
} }
resList += SessionTerm(pseudo_session, resList += SessionTerm(pseudo_session,
...@@ -459,7 +460,7 @@ class SessionProcessTerm { ...@@ -459,7 +460,7 @@ class SessionProcessTerm {
"menu_code", "menu_code_new","menu_code_offset", "action_code", "position", "label_value", "label_class", "module_class1", "module_class2", "app_version", "device_type", "device_brand", "device_model", "menu_code", "menu_code_new","menu_code_offset", "action_code", "position", "label_value", "label_class", "module_class1", "module_class2", "app_version", "device_type", "device_brand", "device_model",
"net_type", "created_time", "date_time", "alternate_info", "first_app_version", "service_name", "tag8", "tag9", "is_need") "net_type", "created_time", "date_time", "alternate_info", "first_app_version", "service_name", "tag8", "tag9", "is_need")
println("baseDF.show=======>") println("baseDF.show=======>")
baseDF.where("action_code !=''").show() baseDF.where("menu_code_new ='017'").show()
baseDF.printSchema() baseDF.printSchema()
baseDF baseDF
} }
...@@ -539,6 +540,7 @@ class SessionProcessTerm { ...@@ -539,6 +540,7 @@ class SessionProcessTerm {
.filter("is_need") .filter("is_need")
println("actionCommonDF.show()===========") println("actionCommonDF.show()===========")
actionCommonDF.filter("menu_code='017'").show()
actionCommonDF.printSchema() actionCommonDF.printSchema()
//计算session中menu_code的起始时间,对于ACTION_HEART_BEAT的埋点记录剔除冗余数据 //计算session中menu_code的起始时间,对于ACTION_HEART_BEAT的埋点记录剔除冗余数据
val groupRdd = actionCommonDF.rdd.groupBy(r => r.getAs[String]("pseudo_session"))//.repartition(100) val groupRdd = actionCommonDF.rdd.groupBy(r => r.getAs[String]("pseudo_session"))//.repartition(100)
...@@ -578,8 +580,8 @@ class SessionProcessTerm { ...@@ -578,8 +580,8 @@ class SessionProcessTerm {
var needPut = true var needPut = true
if ("ACTION_VIEW".equals(actionType) || "ACTION_HEART".equals(actionType)) { if ("ACTION_VIEW".equals(actionType) || "ACTION_HEART".equals(actionType)) {
if (appVersion >= "3.4.5") { //针对3.4.5之后的版本单独处理 if (appVersion >= "3.4.5") { //针对3.4.5之后的版本单独处理
//如果本条记录为ACTION_ACTIVITY_RESUME类型或者ACTION_HEART类型,则入库 //如果本条记录为ACTION_ACTIVITY_RESUME类型或者ACTION_HEART类型或者menu_code为017表示外部方式启动app,则入库
if ("ACTION_ACTIVITY_RESUME".equals(action) || "ACTION_HEART".equals(actionType) ||"ACTION_WEB_ENTER".equals(action)) {//有些h5页面没有对应的ACTION_ACTIVITY_RESUME,需要补进来 if ("ACTION_ACTIVITY_RESUME".equals(action) || "ACTION_HEART".equals(actionType) ||"ACTION_WEB_ENTER".equals(action)|| "017".equals(menuCode)) {//有些h5页面没有对应的ACTION_ACTIVITY_RESUME,需要补进来
needPut = true needPut = true
}else{ }else{
needPut = false needPut = false
...@@ -634,6 +636,7 @@ class SessionProcessTerm { ...@@ -634,6 +636,7 @@ class SessionProcessTerm {
row.getAs[String]("module_class2"), row.getAs[String]("module_class2"),
row.getAs[String]("device_brand"), row.getAs[String]("device_brand"),
row.getAs[String]("device_model"), row.getAs[String]("device_model"),
row.getAs[String]("view_class"),
row.getAs[String]("view_path"), row.getAs[String]("view_path"),
row.getAs[String]("alternate_info"), row.getAs[String]("alternate_info"),
row.getAs[String]("first_app_version"), row.getAs[String]("first_app_version"),
...@@ -684,7 +687,7 @@ class SessionProcessTerm { ...@@ -684,7 +687,7 @@ class SessionProcessTerm {
| cast(menu_begin_time as string), cast(menu_end_time as string), menu_time_diff, | cast(menu_begin_time as string), cast(menu_end_time as string), menu_time_diff,
| action_step,device_type,device_brand,device_model, app_version, net_type ,created_time,date_time, | action_step,device_type,device_brand,device_model, app_version, net_type ,created_time,date_time,
| cast(session_begin_time as string) , cast(session_end_time as string), session_time_diff, | cast(session_begin_time as string) , cast(session_end_time as string), session_time_diff,
| pre_session_id, user_identity_id,view_path,alternate_info,first_app_version,service_name,tag8,tag9,component_tag | pre_session_id, user_identity_id,view_class,view_path,alternate_info,first_app_version,service_name,tag8,tag9,component_tag
| from result_view t1 | from result_view t1
""".stripMargin """.stripMargin
sparkSession.sql(loadDataSql) sparkSession.sql(loadDataSql)
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册