光环助手V3.2数据统计需求(MTA)(完成)

This commit is contained in:
kehaoyuan
2018-04-12 18:37:00 +08:00
parent 347a83cf0f
commit 2102dd729c
12 changed files with 97 additions and 19 deletions

View File

@ -3,6 +3,7 @@ package com.gh.common.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import com.gh.common.constant.Config;
import com.lightgame.config.CommonDebug;
@ -100,9 +101,29 @@ public class DataUtils {
}
// MTA ->【次数统计】Key-Value参数的事件
public static void onMtaEvent(Context context, String eventId, String... kv) {
if (CommonDebug.IS_DEBUG && (kv == null || kv.length % 2 != 0)) {
throw new IllegalStateException("onEvent kv 必须不为空且数量为偶数");
}
Properties prop = new Properties();
for (int i = 0; i < kv.length; i++) {
if (i % 2 != 0 || i != 0) {
String key = kv[i - 1];
String value = kv[i];
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
prop.setProperty(key, value);
}
}
}
StatService.trackCustomKVEvent(context, eventId, prop);
}
public static void onEvent(Context var0, String var1, String var2) {
TCAgent.onEvent(var0, var1, var2);
StatService.trackCustomEvent(var0, var1, var2);
Properties prop = new Properties();
prop.setProperty(var1, var2);
StatService.trackCustomKVEvent(var0, var1, prop);
}
public static void onPause(Activity var0) {

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.DataUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.gamedetail.GameDetailFragment;
@ -24,6 +25,7 @@ public class GameDetailActivity extends NormalActivity {
* 启动游戏详情页面
*/
public static void startGameDetailActivity(Context context, GameEntity gameEntity, String entrance) {
DataUtils.onMtaEvent(context, "详情页面", "游戏详情", gameEntity != null ? gameEntity.getName() : "");
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
bundle.putParcelable(GameEntity.TAG, gameEntity);

View File

@ -162,6 +162,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
* 启动新闻详情页面
*/
public static void startNewsDetailActivity(Context context, NewsEntity newsEntity, String entrance) {
DataUtils.onMtaEvent(context, "详情页面", "文章详情", newsEntity != null ? newsEntity.getTitle() : "");
if (!TextUtils.isEmpty(newsEntity.getLink())) {
context.startActivity(WebActivity.getIntentByNews(context, newsEntity, entrance));
} else {
@ -179,6 +180,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
* 在收藏启动新闻详情页面
*/
public static void startNewsDetailByCollection(Context context, NewsEntity newsEntity, String entrance) {
DataUtils.onMtaEvent(context, "详情页面", "文章详情", newsEntity != null ? newsEntity.getTitle() : "");
if (!TextUtils.isEmpty(newsEntity.getLink())) {
Intent intent = WebActivity.getIntentByNews(context, newsEntity, entrance);
context.startActivity(intent);
@ -280,10 +282,6 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
adapter.setTitle(mNewsEntity.getTitle());
adapter.getNewsDetail();
mNewsShare.setVisibility(View.VISIBLE);
if (mIsCollectionNews) {
getNewsDigest(mNewsEntity.getId());
}
}
} else {
getNewsDigest(newsId);
@ -444,17 +442,6 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
@Override
public void onResponse(NewsEntity response) {
if (mIsCollectionNews && mNewsEntity != null && response != null) { // 对比查看收藏文章是否修改
// Gson gson = new Gson();
// String newEntity = gson.toJson(response.getThumbnail());
// String entity = gson.toJson(mNewsEntity.getThumbnail());
// if (!newEntity.equals(entity) || !response.getType().equals(mNewsEntity.getType())
// || !response.getTitle().equals(mNewsEntity.getTitle())) {
// CollectionUtils.INSTANCE.patchCollection(NewsDetailActivity.this, response.getId(), CollectionUtils.CollectionType.article);
// } else {
// Utils.log("========相同");
// }
return;
}
@ -469,6 +456,8 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
adapter.getNewsDetail();
mNewsShare.setVisibility(View.VISIBLE);
DataUtils.onMtaEvent(NewsDetailActivity.this, "详情页面", "文章详情", response.getTitle());
}
@Override

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.DataUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.subject.SubjectWrapperFragment;
@ -22,6 +23,7 @@ public class SubjectActivity extends NormalActivity {
* 启动专题页面
*/
public static void startSubjectActivity(Context context, String id, String name, boolean isOrder, String entrance) {
DataUtils.onMtaEvent(context, "详情页面", "专题详情", name);
Bundle args = new Bundle();
args.putString(EntranceUtils.KEY_ID, id);
args.putString(EntranceUtils.KEY_NAME, name);

View File

@ -29,6 +29,7 @@ import com.gh.base.fragment.BaseDialogWrapperFragment;
import com.gh.common.util.AskUtils;
import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.CollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.ImageUtils;
@ -404,6 +405,14 @@ public class AnswerDetailFragment extends NormalFragment {
});
break;
case R.id.answer_detail_comment_count_container:
String uploadCount;
String content = mDetailEntity != null ? mDetailEntity.getContent() : "";
if (content.length() > 30) {
uploadCount = content.substring(0, 30);
} else {
uploadCount = content;
}
DataUtils.onMtaEvent(getContext(), "详情页面", "答案评论详情", uploadCount);
showCommentDialog(false);
break;
case R.id.answer_detail_title_status_tv:

View File

@ -15,6 +15,7 @@ import android.widget.TextView;
import com.gh.base.adapter.FragmentAdapter;
import com.gh.base.fragment.BaseFragment;
import com.gh.common.constant.Config;
import com.gh.common.util.DataUtils;
import com.gh.gamecenter.AskSearchActivity;
import com.gh.gamecenter.CommunitiesSelectActivity;
import com.gh.gamecenter.R;
@ -101,9 +102,11 @@ public class AskFragment extends BaseFragment {
break;
case R.id.ask_hot:
setTabbarPosition(INDEX_HOT);
DataUtils.onMtaEvent(getContext(), "问答页面", UserManager.getInstance().getCommunityName(getContext()), "精选Tab");
break;
case R.id.ask_questions:
setTabbarPosition(INDEX_QUESTIONS);
DataUtils.onMtaEvent(getContext(), "问答页面", UserManager.getInstance().getCommunityName(getContext()), "问题Tab");
break;
case R.id.reuse_no_connection:
mNoConn.setVisibility(View.GONE);

View File

@ -8,18 +8,21 @@ import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.base.fragment.BaseFragment;
import com.gh.common.util.DataUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.view.TabIndicatorView;
import com.gh.gamecenter.AskTabOrderActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.ask.entity.AskTagGroupsEntity;
import com.gh.gamecenter.ask.viewmodel.AskQuestionsNewViewModel;
import com.gh.gamecenter.manager.UserManager;
import com.halo.assistant.HaloApp;
import com.lightgame.view.NoScrollableViewPager;
@ -79,6 +82,25 @@ public class AskQuestionsNewFragment extends BaseFragment {
if (savedInstanceState != null) {
mModel.repty();
}
mViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if (mTagGroupsList != null && mTagGroupsList.size() > position) {
DataUtils.onMtaEvent(getContext(), "问答页面",
UserManager.getInstance().getCommunityName(getContext()), "问题-" + mTagGroupsList.get(position).getName());
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
private void subscribeUi(AskQuestionsNewViewModel viewModel) {

View File

@ -10,7 +10,7 @@ import com.google.gson.annotations.SerializedName
*/
class AnswerDetailEntity() : Parcelable {
var content: String? = null
var content: String = ""
var time: Long = 0
@ -29,7 +29,7 @@ class AnswerDetailEntity() : Parcelable {
var vote: Int = 0
@SerializedName("comment_count")
var commentCount:Int = 0
var commentCount: Int = 0
constructor(parcel: Parcel) : this() {
content = parcel.readString()

View File

@ -22,6 +22,7 @@ import android.widget.TextView;
import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.ShareUtils;
@ -359,6 +360,8 @@ public class QuestionsDetailFragment extends ListFragment<AnswerEntity, NormalLi
mQuestionsDetailEntity = response;
mAdapter.setQuestionsEntity(response);
mListViewModel.load(LoadType.REFRESH);
DataUtils.onMtaEvent(getContext(), "详情页面", "问题详情", response.getTitle());
}
@Override

View File

@ -7,6 +7,7 @@ import android.arch.lifecycle.MutableLiveData;
import android.support.annotation.NonNull;
import com.gh.common.util.AskLogUtils;
import com.gh.common.util.DataUtils;
import com.gh.gamecenter.ask.entity.AnswerDetailEntity;
import com.gh.gamecenter.login.ApiResponse;
import com.gh.gamecenter.retrofit.Response;
@ -38,6 +39,15 @@ public class AnswerDetailViewModel extends AndroidViewModel {
mAnswerLiveData.postValue(apiResponse);
AskLogUtils.uploadAnswers(getApplication(), entrance, response.getQuestion(), answerId);
String uploadCount;
String content = response.getContent();
if (content.length() > 30) {
uploadCount = content.substring(0, 30);
} else {
uploadCount = content;
}
DataUtils.onMtaEvent(getApplication(), "详情页面", "答案详情", uploadCount);
}
@Override
@ -48,7 +58,7 @@ public class AnswerDetailViewModel extends AndroidViewModel {
}
});
}
public void postVote(String answerId) {
RetrofitManager.getInstance(getApplication()).getApi()
.postAnswerVote(answerId)

View File

@ -9,6 +9,7 @@ import android.view.View;
import com.gh.base.fragment.BaseFragment_ViewPager_Checkable;
import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.DataUtils;
import com.gh.gamecenter.CommunitiesSelectActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.ask.AskFragment;
@ -127,6 +128,21 @@ public class MainWrapperFragment extends BaseFragment_ViewPager_Checkable {
mIsEnterSelectCommunities = false;
startActivityForResult(CommunitiesSelectActivity.getIntent(getContext()), COMMUNITIES_SELECT_REQUEST);
}
switch (index) {
case INDEX_GAME:
DataUtils.onMtaEvent(getContext(), "顶级页面", "BottomBar", "游戏");
break;
case INDEX_ASK:
DataUtils.onMtaEvent(getContext(), "顶级页面", "BottomBar", "问答");
break;
case INDEX_DISCOVER:
DataUtils.onMtaEvent(getContext(), "顶级页面", "BottomBar", "发现");
break;
case INDEX_PERSONAL:
DataUtils.onMtaEvent(getContext(), "顶级页面", "BottomBar", "我的光环");
break;
}
}
@Subscribe(threadMode = ThreadMode.MAIN)

View File

@ -341,6 +341,7 @@ public class GameDetailFragment extends NormalFragment {
.subscribe(new Response<GameEntity>() {
@Override
public void onResponse(GameEntity response) {
DataUtils.onMtaEvent(getContext(), "详情页面", "游戏详情", response != null ? response.getName() : "");
ApkActiveUtils.filterHideApk(response);
mGameEntity = response;