|
|
@@ -0,0 +1,126 @@
|
|
|
+/*
|
|
|
+ * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
|
|
|
+ */
|
|
|
+package kr.co.zumo.app.lifeplus.helper;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.content.Context;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.annotation.NonNull;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.support.annotation.StringRes;
|
|
|
+import android.util.Log;
|
|
|
+
|
|
|
+import com.google.android.gms.analytics.GoogleAnalytics;
|
|
|
+import com.google.android.gms.analytics.HitBuilders;
|
|
|
+import com.google.android.gms.analytics.Tracker;
|
|
|
+import com.google.firebase.analytics.FirebaseAnalytics;
|
|
|
+
|
|
|
+import kr.co.zumo.app.BuildConfig;
|
|
|
+import kr.co.zumo.app.R;
|
|
|
+import kr.co.zumo.app.lifeplus.util.StringUtil;
|
|
|
+
|
|
|
+/**
|
|
|
+ * GoogleAnalyticsHelper
|
|
|
+ * <pre>
|
|
|
+ * </pre>
|
|
|
+ *
|
|
|
+ * @author 이영윤
|
|
|
+ * @version 1.0
|
|
|
+ * @history 이영윤 [2019. 4. 8.] [최초 작성]
|
|
|
+ * @since 2019. 4. 8.
|
|
|
+ */
|
|
|
+public class GoogleAnalyticsHelper extends Helper {
|
|
|
+
|
|
|
+ public static class ZUMO_SCREEN {
|
|
|
+ public static final String CONTENTS_DETAIL = "컨텐츠 상세";
|
|
|
+ public static final String CONTENTS_CLOSE = "컨텐츠 종료";
|
|
|
+ public static final String CONTENTS_DETAIL_HTML = "컨텐츠 상세 (html)";
|
|
|
+ public static final String LIKE = "좋아요";
|
|
|
+ public static final String SHARE = "공유하기";
|
|
|
+ public static final String BOOKMARK = "북마크";
|
|
|
+ public static final String SHOW_ALL = "전체보기";
|
|
|
+ public static final String MORE_INFO = "more info";
|
|
|
+ public static final String MORE_INFO_DETAIL = "more info 상세버튼";
|
|
|
+ public static final String CATEGORY_MAIN = "카테고리 메인";
|
|
|
+ public static final String EVENT_DETAIL = "이벤트 상세";
|
|
|
+ public static final String EVENT_DETAIL_APPLY = "이벤트 상세 - 응모하기";
|
|
|
+ public static final String EVENT_APPLIED = "이벤트 참여완료";
|
|
|
+ public static final String SEARCH = "검색";
|
|
|
+ public static final String BUCKET_WRITE = "버킷리스트 작성";
|
|
|
+ public static final String LIST_COMMON = "리스트 공통";
|
|
|
+ public static final String SIGN_UP = "회원 가입";
|
|
|
+ public static final String POP_UP = "팝업";
|
|
|
+ public static final String SERIES = "시리즈";
|
|
|
+ public static final String WITH_CONTENTS = "함께보면 좋은 컨텐츠";
|
|
|
+ public static final String ORDER = "정렬";
|
|
|
+ public static final String BANNER = "배너";
|
|
|
+ public static final String FILTER = "필터";
|
|
|
+ public static final String MENU = "햄버거메뉴";
|
|
|
+
|
|
|
+
|
|
|
+ protected ZUMO_SCREEN() {}
|
|
|
+ }
|
|
|
+
|
|
|
+ public static class ZUMO_TYPE {
|
|
|
+ static final String EXPOSURE = "노출";
|
|
|
+ static final String CLICK = "클릭";
|
|
|
+
|
|
|
+ protected ZUMO_TYPE() {}
|
|
|
+ }
|
|
|
+
|
|
|
+ public static class ZUMO_PARAM {
|
|
|
+ static final String TITLE = "title";
|
|
|
+ static final String INDEX = "index";
|
|
|
+ static final String FROM = "from";
|
|
|
+ static final String BUTTON = "button";
|
|
|
+ static final String USERID = "userid";
|
|
|
+ public static final String MAIN = "메인";
|
|
|
+ public static final String SEARCH = "검색";
|
|
|
+ public static final String CATEGORY = "카테고리";
|
|
|
+
|
|
|
+ protected ZUMO_PARAM() {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private GoogleAnalytics googleAnalytics;
|
|
|
+ private Tracker sTracker;
|
|
|
+
|
|
|
+ @SuppressLint("StaticFieldLeak")
|
|
|
+ private Context context;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCleared() {
|
|
|
+ googleAnalytics = null;
|
|
|
+ sTracker = null;
|
|
|
+ context = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * init
|
|
|
+ *
|
|
|
+ * @param context
|
|
|
+ */
|
|
|
+ public void init(Context context) {
|
|
|
+ this.context = context;
|
|
|
+
|
|
|
+ googleAnalytics = GoogleAnalytics.getInstance(context);
|
|
|
+ }
|
|
|
+
|
|
|
+ synchronized public Tracker getDefaultTracker() {
|
|
|
+ if (sTracker == null) {
|
|
|
+ sTracker = googleAnalytics.newTracker(R.xml.app_tracker);
|
|
|
+ }
|
|
|
+ return sTracker;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void sendGA(@NonNull String screen) {
|
|
|
+ getDefaultTracker().setScreenName(screen);
|
|
|
+ getDefaultTracker().send(new HitBuilders.ScreenViewBuilder().build());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void sendGA(@NonNull String category, @Nullable String action, @Nullable String label) {
|
|
|
+ getDefaultTracker().send(new HitBuilders.EventBuilder().setCategory(category).setAction(action).setLabel(label).build());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|