Переглянути джерело

[주모] Google Analytics 추가

yeongyun 6 роки тому
батько
коміт
1ebeebb2c4

+ 1 - 0
app/build.gradle

@@ -183,6 +183,7 @@ dependencies {
 
     // ZUMO
     implementation 'com.google.android.gms:play-services-auth:16.0.0'
+    implementation 'com.google.android.gms:play-services-analytics:16.0.8'
     implementation 'com.kakao.sdk:usermgmt:1.14.0'
     implementation 'com.kakao.sdk:kakaotalk:1.14.0'
 

+ 2 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/activity/ActivityBase.java

@@ -30,6 +30,7 @@ import kr.co.zumo.app.lifeplus.helper.AllMenuHelper;
 import kr.co.zumo.app.lifeplus.helper.DeliveryResultHelper;
 import kr.co.zumo.app.lifeplus.helper.FacebookHelper;
 import kr.co.zumo.app.lifeplus.helper.FirebaseAnalyticsHelper;
+import kr.co.zumo.app.lifeplus.helper.GoogleAnalyticsHelper;
 import kr.co.zumo.app.lifeplus.helper.Helper;
 import kr.co.zumo.app.lifeplus.helper.IHelperProvider;
 import kr.co.zumo.app.lifeplus.helper.ScreenChangerHelper;
@@ -141,6 +142,7 @@ public abstract class ActivityBase extends AppCompatActivity implements IHelperP
 
       // firebase analytics
       getHelper(FirebaseAnalyticsHelper.class).init(App.getInstance().getContext());
+      getHelper(GoogleAnalyticsHelper.class).init(App.getInstance().getContext());
 
       /**
        * drawer setting

+ 0 - 13
app/src/main/java/kr/co/zumo/app/lifeplus/helper/FirebaseAnalyticsHelper.java

@@ -62,19 +62,6 @@ public class FirebaseAnalyticsHelper extends Helper {
     }
   }
 
-  public static class ZUMO_SCREEN {
-    static final String CONTENTS_DETAIL = "컨텐츠 상세";
-
-    protected ZUMO_SCREEN() {}
-  }
-
-  public static class ZUMO_TYPE {
-    static final String EXPOSURE = "노출";
-    static final String CLICK = "클릭";
-
-    protected ZUMO_TYPE() {}
-  }
-
   private FirebaseAnalytics firebaseAnalytics;
 
   @SuppressLint("StaticFieldLeak")

+ 126 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/helper/GoogleAnalyticsHelper.java

@@ -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());
+  }
+
+}

+ 3 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/presenter/Presenter.java

@@ -27,6 +27,7 @@ import kr.co.zumo.app.lifeplus.bean.api.LinkBean;
 import kr.co.zumo.app.lifeplus.helper.ActionBarHelper;
 import kr.co.zumo.app.lifeplus.helper.AllMenuHelper;
 import kr.co.zumo.app.lifeplus.helper.FirebaseAnalyticsHelper;
+import kr.co.zumo.app.lifeplus.helper.GoogleAnalyticsHelper;
 import kr.co.zumo.app.lifeplus.helper.Helper;
 import kr.co.zumo.app.lifeplus.helper.IAllMenuEvent;
 import kr.co.zumo.app.lifeplus.helper.IHelperProvider;
@@ -76,6 +77,7 @@ public abstract class Presenter<M extends Model, V extends IView> implements ILi
   protected V view;
   protected Command command;
   protected FirebaseAnalyticsHelper firebaseAnalyticsHelper;
+  protected GoogleAnalyticsHelper googleAnalyticsHelper;
 
   private DialogBase dialogError;
   private DialogBase dialogNetwork;
@@ -102,6 +104,7 @@ public abstract class Presenter<M extends Model, V extends IView> implements ILi
     }
 
     firebaseAnalyticsHelper = getHelper(FirebaseAnalyticsHelper.class);
+    googleAnalyticsHelper = getHelper(GoogleAnalyticsHelper.class);
     allMenuHelper = getHelper(AllMenuHelper.class);
 
   }

+ 3 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/zumo/BasePresenter.java

@@ -6,6 +6,7 @@ import android.util.Log;
 
 import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.helper.FirebaseAnalyticsHelper;
+import kr.co.zumo.app.lifeplus.helper.GoogleAnalyticsHelper;
 import kr.co.zumo.app.lifeplus.helper.Helper;
 import kr.co.zumo.app.lifeplus.model.IModelResult;
 import kr.co.zumo.app.lifeplus.util.ResourceUtil;
@@ -33,6 +34,7 @@ public abstract class BasePresenter<M extends BaseModel, V extends BaseView> imp
     private DialogBase dialogError;
 
     protected FirebaseAnalyticsHelper firebaseAnalyticsHelper;
+    protected GoogleAnalyticsHelper googleAnalyticsHelper;
 
     public BasePresenter(M model, V view) {
         this.model = model;
@@ -41,6 +43,7 @@ public abstract class BasePresenter<M extends BaseModel, V extends BaseView> imp
         this.model.setWaiterCaller(this);
 
         firebaseAnalyticsHelper = getHelper(FirebaseAnalyticsHelper.class);
+        googleAnalyticsHelper = getHelper(GoogleAnalyticsHelper.class);
     }
 
     protected void showErrorDialog(String string) {

+ 17 - 0
app/src/main/res/xml/app_tracker.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <!--  The following value should be replaced with correct property id. -->
+    <string name="ga_trackingId">UA-67335814-2</string>
+
+    <!-- catch and report uncaught exceptions from the app -->
+    <bool name="ga_reportUncaughtExceptions">true</bool>
+
+    <integer name="ga_sessionTimeout">300</integer>
+
+    <!-- Enable automatic Activity measurement -->
+    <bool name="ga_autoActivityTracking">false</bool>
+
+    <!-- The screen names that will appear in reports -->
+    <screenName name="kr.co.zumo.app.lifeplus.activity.MainActivity">MainActivity</screenName>
+
+</resources>