This commit is contained in:
juntao
2021-03-23 16:36:19 +08:00
parent 79b7a15f7d
commit 7f4d3ffe3e
9 changed files with 211 additions and 10 deletions

View File

@ -26,7 +26,6 @@ import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.qa.entity.Questions;
import com.gh.gamecenter.retrofit.EmptyResponse;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.google.gson.Gson;
import com.halo.assistant.HaloApp;
import com.lightgame.utils.Utils;
@ -35,7 +34,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import androidx.annotation.Nullable;
@ -710,6 +708,100 @@ public class LogUtils {
LoghubUtils.log(object, "event", false);
}
public static void logServerTestAccessEvent(String entrance,
String entranceDetail,
String serverTestName,
String serverTestNote) {
JSONObject payload = new JSONObject();
try {
payload.put("server_test_name", serverTestName);
payload.put("server_test_note", serverTestNote);
payload.put("entrance", entrance);
payload.put("entrance_detail", entranceDetail);
} catch (JSONException e) {
e.printStackTrace();
}
logServerTestEvent("access_to_server_test", payload);
}
public static void logServerTestSelectTypeEvent(String buttonText,
String serverTestName,
String serverTestNote) {
JSONObject payload = new JSONObject();
try {
payload.put("server_test_name", serverTestName);
payload.put("server_test_note", serverTestNote);
payload.put("button_text", buttonText);
} catch (JSONException e) {
e.printStackTrace();
}
logServerTestEvent("server_test_select_type", payload);
}
public static void logServerTestSelectTimeEvent(String buttonText,
String serverTestName,
String serverTestNote) {
JSONObject payload = new JSONObject();
try {
payload.put("server_test_name", serverTestName);
payload.put("server_test_note", serverTestNote);
payload.put("button_text", buttonText);
} catch (JSONException e) {
e.printStackTrace();
}
logServerTestEvent("server_test_select_time", payload);
}
public static void logServerTestClickAllEvent(String serverTestName,
String serverTestNote) {
JSONObject payload = new JSONObject();
try {
payload.put("server_test_name", serverTestName);
payload.put("server_test_note", serverTestNote);
} catch (JSONException e) {
e.printStackTrace();
}
logServerTestEvent("server_test_click_all", payload);
}
public static void logServerTestClickMoreEvent(String serverTestName,
String serverTestNote,
String redirectType,
String redirectLink) {
JSONObject payload = new JSONObject();
try {
payload.put("server_test_name", serverTestName);
payload.put("server_test_note", serverTestNote);
payload.put("redirect_type", redirectType);
payload.put("redirect_link", redirectLink);
} catch (JSONException e) {
e.printStackTrace();
}
logServerTestEvent("server_test_click_more", payload);
}
private static void logServerTestEvent(String event, JSONObject payload) {
JSONObject object = new JSONObject();
try {
object.put("event", event);
object.put("meta", getMetaObject());
object.put("timestamp", System.currentTimeMillis() / 1000);
object.put("payload", payload);
} catch (JSONException e) {
e.printStackTrace();
}
if (BuildConfig.DEBUG) {
Utils.log("LogUtils->" + object.toString());
}
LoghubUtils.log(object, "event", false);
}
public static void logNewCatalogAppearanceEvent(String entrance, String key) {
logCatalogEvent("access_to_classification", entrance, key, -1, -1, -1, -1);
}
@ -817,7 +909,7 @@ public class LogUtils {
LoghubUtils.log(object, "event", false);
}
public static void uploadPackageCheck(String event, String action, GameEntity gameEntity, String linkTitle, String linkDesc,String downloadGameId,String downloadGameName) {
public static void uploadPackageCheck(String event, String action, GameEntity gameEntity, String linkTitle, String linkDesc, String downloadGameId, String downloadGameName) {
PackageDialogEntity packageDialog = gameEntity.getPackageDialog();
if (packageDialog == null) return;
JSONObject object = new JSONObject();

View File

@ -0,0 +1,33 @@
package com.gh.common.util
import com.lightgame.utils.AppManager
/**
* 用来简单获取上一个跳转页面的跳转信息的辅助类
* 简单解藕,不想层层传递数据可以把简单数据放这里面
* 暂只支持单页面(上一 activity)记录,不支持连续跨页
*/
object PageSwitchDataHelper {
const val PAGE_BUSINESS_NAME = "page_business_name"
const val PAGE_BUSINESS_TYPE = "page_business_type"
private var mDataFromTheLastPage: Pair<String, HashMap<String, String>>? = null
fun popLastPageData(): HashMap<String, String>? {
AppManager.getInstance().previousActivity()?.let {
if (System.identityHashCode(it).toString() == mDataFromTheLastPage?.first
&& mDataFromTheLastPage?.second != null) {
return mDataFromTheLastPage!!.second.also { mDataFromTheLastPage = null }
}
}
return null
}
fun pushCurrentPageData(data: HashMap<String, String>) {
AppManager.getInstance().currentActivity()?.let {
mDataFromTheLastPage = Pair(System.identityHashCode(it).toString(), data)
}
}
}

View File

@ -179,6 +179,7 @@ class GameFragmentAdapter(context: Context,
holder.binding.root.setOnClickListener {
MtaHelper.onEvent("游戏专题", "全部", itemData.gallery?.name)
setPageSwitchData()
DirectUtils.directToSubject(holder.binding.root.context, itemData.gallery?.id
?: "", itemData.gallery?.name, "(游戏-专题)")
}
@ -204,6 +205,7 @@ class GameFragmentAdapter(context: Context,
?: "", prefixedPosition, "(首页游戏)")
} else {
MtaHelper.onEvent("游戏专题合集", "首页合集图片", gameEntity.name)
setPageSwitchData()
DirectUtils.directToLinkPage(mContext, LinkEntity(link = gameEntity.link, type = gameEntity.type), "(首页游戏)", "游戏-专题")
}
}
@ -219,6 +221,7 @@ class GameFragmentAdapter(context: Context,
?: "", 0, "(首页游戏)")
} else {
MtaHelper.onEvent("游戏专题合集", "首页合集图片", data.name)
setPageSwitchData()
DirectUtils.directToLinkPage(mContext, LinkEntity(link = data.link, type = data.type), "(首页游戏)", "游戏-专题")
}
}
@ -301,6 +304,9 @@ class GameFragmentAdapter(context: Context,
val linkEntity = LinkEntity()
linkEntity.link = entity?.link
linkEntity.type = entity?.type
PageSwitchDataHelper.pushCurrentPageData(hashMapOf(
Pair(PageSwitchDataHelper.PAGE_BUSINESS_TYPE, "游戏专题-大图"),
Pair(PageSwitchDataHelper.PAGE_BUSINESS_NAME, entity?.subjectName ?: "")))
DirectUtils.directToLinkPage(mContext, linkEntity, "(游戏-专题:" + entity?.name + "-大图)", "首页游戏", entity?.exposureEvent)
}
@ -385,6 +391,7 @@ class GameFragmentAdapter(context: Context,
linkEntity.name = entity.name
linkEntity.community = entity.community
linkEntity.display = entity.display
setPageSwitchData()
DirectUtils.directToLinkPage(mContext, linkEntity, "(游戏-专题:$name-大图)", mViewModel.blockData?.name
?: "", mItemDataList[position].exposureEvent)
}
@ -432,6 +439,7 @@ class GameFragmentAdapter(context: Context,
// else -> DialogUtils.showLowVersionDialog(mContext)
else -> {
val linkEntity = LinkEntity(name = entity.name, link = entity.link, text = entity.text, type = entity.type, display = entity.display)
setPageSwitchData(false)
DirectUtils.directToLinkPage(mContext, linkEntity, "(推荐入口)", "")
}
}
@ -571,7 +579,16 @@ class GameFragmentAdapter(context: Context,
DirectUtils.directToColumnCollection(mContext, column.id!!, -1, "(推荐入口)")
} else {
if (column.indexRightTopLink != null) {
DirectUtils.directToLinkPage(mContext, column.indexRightTopLink!!, "(游戏-专题:" + column.name + "-全部)", "")
val link = column.indexRightTopLink!!
setPageSwitchData()
// ugly ugly ugly as hell
if (holder.binding.headMore.text == "更多") {
LogUtils.logServerTestClickMoreEvent(link.text, column.remark, link.type, link.link)
} else {
LogUtils.logServerTestClickAllEvent(link.text, column.remark)
}
DirectUtils.directToLinkPage(mContext, link, "(游戏-专题:" + column.name + "-全部)", "")
} else {
SubjectActivity.startSubjectActivity(mContext, column.id, column.getFilterName(), column.isOrder, "(游戏-专题:" + column.name + "-全部)")
}
@ -665,6 +682,13 @@ class GameFragmentAdapter(context: Context,
return positionList
}
private fun setPageSwitchData(isContent: Boolean = true) {
PageSwitchDataHelper.pushCurrentPageData(hashMapOf(
Pair(PageSwitchDataHelper.PAGE_BUSINESS_TYPE, if (isContent) "版块-内容列表" else "版块-推荐位"),
Pair(PageSwitchDataHelper.PAGE_BUSINESS_NAME, mViewModel.blockData?.name ?: "")
))
}
override fun getEventByPosition(pos: Int): ExposureEvent? {
return mItemDataList[pos].exposureEvent
}

View File

@ -717,6 +717,9 @@ class DescAdapter(context: Context,
it.text = mViewModel.game?.getGameCategory().toString()
DirectUtils.directToLinkPage(mContext, it, StringUtils.buildString(mEntrance, "游戏详情[", gameName, "]:自定义栏目"), "")
} else {
PageSwitchDataHelper.pushCurrentPageData(hashMapOf(
Pair(PageSwitchDataHelper.PAGE_BUSINESS_TYPE, "游戏详情-自定义栏目"),
Pair(PageSwitchDataHelper.PAGE_BUSINESS_NAME, gameName ?: "")))
DirectUtils.directToLinkPage(mContext, it, StringUtils.buildString(mEntrance, "游戏详情[", gameName, "]:自定义栏目"), "")
}
}

View File

@ -4,6 +4,7 @@ import com.gh.base.BaseRecyclerViewHolder
import com.gh.base.OnViewClickListener
import com.gh.common.util.DirectUtils
import com.gh.common.util.MtaHelper
import com.gh.common.util.PageSwitchDataHelper
import com.gh.gamecenter.databinding.HomeRecommendItemBinding
import com.gh.gamecenter.entity.HomeRecommend
@ -11,7 +12,7 @@ class HomeRecommendItemViewHolder(val binding: HomeRecommendItemBinding) : BaseR
fun bindRecommend(recommends: List<HomeRecommend>) {
binding.list = recommends
binding.clickListener = OnViewClickListener<Int> { v, position ->
binding.clickListener = OnViewClickListener<Int> { _, position ->
// 很奇怪这里居然抛出 IndexOutOfBoundsException 异常(有可能数据改变了,页面还没刷新导致)
if (position >= recommends.size) return@OnViewClickListener
@ -21,6 +22,7 @@ class HomeRecommendItemViewHolder(val binding: HomeRecommendItemBinding) : BaseR
if (recommend.linkType == "top_game_comment") {
MtaHelper.onEvent("安利墙", "进入", "首页推荐入口")
}
PageSwitchDataHelper.pushCurrentPageData(hashMapOf(Pair(PageSwitchDataHelper.PAGE_BUSINESS_TYPE, "首页-推荐位")))
DirectUtils.directToLinkPage(binding.root.context, recommend.transformLinkEntity(), "", "新首页-推荐入口")
}
}

View File

@ -196,6 +196,7 @@ class LegacyHomeFragmentAdapterAssistant(private var mContext: Context,
DirectUtils.directToColumnCollection(mContext, columnCollection.id
?: "", prefixedPosition, "(首页游戏)")
} else {
setPageSwitchData()
DirectUtils.directToLinkPage(mContext, LinkEntity(link = gameEntity.link, type = gameEntity.type), "(首页游戏)", "游戏-专题")
}
}
@ -215,6 +216,7 @@ class LegacyHomeFragmentAdapterAssistant(private var mContext: Context,
DirectUtils.directToColumnCollection(mContext, columnCollection.id
?: "", 0, "(首页游戏)")
} else {
setPageSwitchData()
DirectUtils.directToLinkPage(mContext, LinkEntity(link = data.link, type = data.type), "(首页游戏)", "游戏-专题")
}
}
@ -313,6 +315,9 @@ class LegacyHomeFragmentAdapterAssistant(private var mContext: Context,
val linkEntity = LinkEntity()
linkEntity.link = entity?.link
linkEntity.type = entity?.type
PageSwitchDataHelper.pushCurrentPageData(hashMapOf(
Pair(PageSwitchDataHelper.PAGE_BUSINESS_TYPE, "游戏专题-大图"),
Pair(PageSwitchDataHelper.PAGE_BUSINESS_NAME, entity?.subjectName ?: "")))
DirectUtils.directToLinkPage(mContext, linkEntity, "(游戏-专题:" + entity?.name + "-大图)", "首页游戏", exposureEventList.firstOrNull())
}
@ -410,6 +415,7 @@ class LegacyHomeFragmentAdapterAssistant(private var mContext: Context,
val linkEntity = LinkEntity()
linkEntity.link = link
linkEntity.type = entity.type
setPageSwitchData()
DirectUtils.directToLinkPage(mContext, linkEntity, "(游戏-专题:$name-大图)", "首页游戏")
}
@ -503,7 +509,17 @@ class LegacyHomeFragmentAdapterAssistant(private var mContext: Context,
DirectUtils.directToAmway(mContext, null, "(游戏-专题:" + column.name + "-全部)", "")
} else {
if (column.indexRightTopLink != null) {
DirectUtils.directToLinkPage(mContext, column.indexRightTopLink!!, "(游戏-专题:" + column.name + "-全部)", "")
val link = column.indexRightTopLink!!
setPageSwitchData()
// ugly ugly ugly as hell
if (holder.binding.headMore.text == "更多") {
LogUtils.logServerTestClickMoreEvent(link.text, column.remark, link.type, link.link)
} else {
LogUtils.logServerTestClickAllEvent(link.text, column.remark)
}
DirectUtils.directToLinkPage(mContext, link, "(游戏-专题:" + column.name + "-全部)", "")
} else {
SubjectActivity.startSubjectActivity(mContext, column.id, column.getFilterName(), column.isOrder, "(游戏-专题:" + column.name + "-全部)")
}
@ -614,6 +630,10 @@ class LegacyHomeFragmentAdapterAssistant(private var mContext: Context,
}
}
private fun setPageSwitchData() {
PageSwitchDataHelper.pushCurrentPageData(hashMapOf(Pair(PageSwitchDataHelper.PAGE_BUSINESS_TYPE, "首页-内容列表")))
}
override fun getOffset(position: Int) = mOffsetMap[position] ?: 0
override fun updateOffset(position: Int, offset: Int) {

View File

@ -6,7 +6,6 @@ import android.os.Bundle
import com.gh.common.util.EntranceUtils
import com.gh.gamecenter.NormalActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.catalog.CatalogActivity
class GameServerTestActivity : NormalActivity() {
@ -18,7 +17,7 @@ class GameServerTestActivity : NormalActivity() {
override fun showDownloadMenu() = true
override fun provideNormalIntent(): Intent {
return getTargetIntent(this, CatalogActivity::class.java, GameServersTestFragment::class.java)
return getTargetIntent(this, GameServerTestActivity::class.java, GameServersTestFragment::class.java)
}
companion object {
@ -27,7 +26,7 @@ class GameServerTestActivity : NormalActivity() {
bundle.putString(GameServersTestFragment.TEST_COLUMN_ID, id)
bundle.putString(GameServersTestFragment.TEST_TITLE, title)
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance)
return getTargetIntent(context, CatalogActivity::class.java, GameServersTestFragment::class.java, bundle)
return getTargetIntent(context, GameServerTestActivity::class.java, GameServersTestFragment::class.java, bundle)
}
}

View File

@ -76,11 +76,12 @@ class GameServersTestFragment : NormalFragment() {
super.onCreate(savedInstanceState)
mServerViewModel = viewModelProviderFromParent()
mViewModel = viewModelProvider(GameServersTestViewModel.Factory(HaloApp.getInstance(), mTestColumnId))
mTestColumnId = arguments?.getString(TEST_COLUMN_ID, DEFAULT_TEST_COLUMN_ID)
?: DEFAULT_TEST_COLUMN_ID
mViewModel = viewModelProvider(GameServersTestViewModel.Factory(HaloApp.getInstance(), mTestColumnId))
val title = arguments?.getString(TEST_TITLE)
setNavigationTitle(title)
@ -124,6 +125,8 @@ class GameServersTestFragment : NormalFragment() {
{ mSubBinding?.recyclerView?.scrollToPosition(0) },
mEntrance)
logEntranceIfNeeded()
mExposureListener = ExposureListener(this, mAdapter!!)
(mSubBinding?.recyclerView?.itemAnimator as DefaultItemAnimator?)?.supportsChangeAnimations = false
@ -158,11 +161,13 @@ class GameServersTestFragment : NormalFragment() {
{ day ->
mDay = day
scrollToDay(mDay ?: mViewModel!!.dayList.first())
logTimeFilterSelectedEvent(mDay ?: mViewModel!!.dayList.first())
},
{ name ->
mBinding?.serverStatus?.text = if (name == GameServersTestViewModel.ALL) "测试状态" else name
mType = name
logTypeFilterSelectedEvent(name)
mViewModel?.updateTypeFilter(name)
})
@ -341,6 +346,26 @@ class GameServersTestFragment : NormalFragment() {
mSubBinding?.loadingContainer?.root?.visibility = View.GONE
}
private fun logEntranceIfNeeded() {
val lastPageData = PageSwitchDataHelper.popLastPageData()
if (lastPageData != null) {
LogUtils.logServerTestAccessEvent(
lastPageData[PageSwitchDataHelper.PAGE_BUSINESS_TYPE],
lastPageData[PageSwitchDataHelper.PAGE_BUSINESS_NAME],
mViewModel!!.testTitle,
mTestColumnId
)
}
}
private fun logTimeFilterSelectedEvent(time: String) {
LogUtils.logServerTestSelectTimeEvent(time, mViewModel!!.testTitle, mTestColumnId)
}
private fun logTypeFilterSelectedEvent(type: String) {
LogUtils.logServerTestSelectTypeEvent(type, mViewModel!!.testTitle, mTestColumnId)
}
companion object {
const val TEST_COLUMN_ID = "test_column_id"
const val TEST_TITLE = "title"

View File

@ -273,6 +273,9 @@ class SubjectAdapter(context: Context,
linkEntity.name = gameEntity.name
linkEntity.display = gameEntity.display
linkEntity.community = gameEntity.community
PageSwitchDataHelper.pushCurrentPageData(hashMapOf(
Pair(PageSwitchDataHelper.PAGE_BUSINESS_TYPE, "游戏专题-头图"),
Pair(PageSwitchDataHelper.PAGE_BUSINESS_NAME, subjectData.subjectName ?: "")))
DirectUtils.directToLinkPage(mContext, linkEntity,
mEntrance + "(" + subjectData.subjectName + ":头图)", "游戏专题", mExposureEventSparseArray.get(position))
}