From 42af0f5d8d2668de4b654999a6697a74109e7d3f Mon Sep 17 00:00:00 2001 From: wp Date: Thu, 16 Jul 2020 11:01:34 +0800 Subject: [PATCH] =?UTF-8?q?4.4.12=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ans-sdk/analysys_core/proguard-rules.pro | 3 ++ .../main/java/com/analysys/AnalysysAgent.java | 11 +++- .../java/com/analysys/ObserverListener.java | 18 +++++++ .../analysys/easytouch/EasytouchProcess.java | 51 +++++++++++++++++++ .../com/analysys/process/AgentProcess.java | 9 ++++ config.gradle | 2 +- 6 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 ans-sdk/analysys_core/src/main/java/com/analysys/ObserverListener.java create mode 100644 ans-sdk/analysys_core/src/main/java/com/analysys/easytouch/EasytouchProcess.java diff --git a/ans-sdk/analysys_core/proguard-rules.pro b/ans-sdk/analysys_core/proguard-rules.pro index 36ca64e..db5778b 100644 --- a/ans-sdk/analysys_core/proguard-rules.pro +++ b/ans-sdk/analysys_core/proguard-rules.pro @@ -21,6 +21,9 @@ -keep public interface com.analysys.AnalysysAgent$AnalysysNetworkType{ *; } +-keep public interface com.analysys.ObserverListener{ + *; +} -keep class com.analysys.ANSAutoPageTracker{ *; } diff --git a/ans-sdk/analysys_core/src/main/java/com/analysys/AnalysysAgent.java b/ans-sdk/analysys_core/src/main/java/com/analysys/AnalysysAgent.java index ea112a1..8efaa1e 100644 --- a/ans-sdk/analysys_core/src/main/java/com/analysys/AnalysysAgent.java +++ b/ans-sdk/analysys_core/src/main/java/com/analysys/AnalysysAgent.java @@ -145,6 +145,16 @@ public static void setUploadURL(Context context, String url) { AgentProcess.getInstance().setUploadURL(url); } + /** + * 设置时间和用户属性的监听 + * + * @param context + * @param listener + */ + public static void setObserverListener(Context context, ObserverListener listener) { + AgentProcess.getInstance().setObserverListener(listener); + } + /** * 设置上传间隔时间 * debug 设置为 0 时,数据上传时间间隔,单位:秒 @@ -686,4 +696,3 @@ public interface AnalysysNetworkType { int AnalysysNetworkALL = 0xFF; } } - diff --git a/ans-sdk/analysys_core/src/main/java/com/analysys/ObserverListener.java b/ans-sdk/analysys_core/src/main/java/com/analysys/ObserverListener.java new file mode 100644 index 0000000..9d8e11a --- /dev/null +++ b/ans-sdk/analysys_core/src/main/java/com/analysys/ObserverListener.java @@ -0,0 +1,18 @@ +package com.analysys; + +/** + * Create by Kevin on 2019-08-28 + * Describe: + */ +public interface ObserverListener { + /** + * @param key 用户属性的key值,是上传的时候key值,比如用户ID是xwho + * @param value 用户属性值 + */ + void onUserProfile(final String key, final String value); + + /** + * @param event 完整的用户上传的json数据 + */ + void onEventMessage(final String event); +} diff --git a/ans-sdk/analysys_core/src/main/java/com/analysys/easytouch/EasytouchProcess.java b/ans-sdk/analysys_core/src/main/java/com/analysys/easytouch/EasytouchProcess.java new file mode 100644 index 0000000..4c8dee5 --- /dev/null +++ b/ans-sdk/analysys_core/src/main/java/com/analysys/easytouch/EasytouchProcess.java @@ -0,0 +1,51 @@ +package com.analysys.easytouch; + +import com.analysys.ObserverListener; +import com.analysys.utils.AnalysysUtil; +import com.analysys.utils.CommonUtils; + +/** + * Create by Kevin on 2020/6/3 + * Describe: + */ +public class EasytouchProcess { + + private final static String OBSERVER_XWHO = "xwho"; + + private static EasytouchProcess sInstance; + + private ObserverListener listener; + + private EasytouchProcess() { + } + + public static EasytouchProcess getInstance() { + if (sInstance == null) { + synchronized (EasytouchProcess.class) { + if (sInstance == null) { + sInstance = new EasytouchProcess(); + } + } + } + return sInstance; + } + + public void setObserverListener(ObserverListener listener) { + this.listener = listener; + if (this.listener != null) { + this.listener.onUserProfile(OBSERVER_XWHO, CommonUtils.getUserId(AnalysysUtil.getContext())); + } + } + + public void setXwho(final String xwho) { + if (this.listener != null) { + this.listener.onUserProfile(OBSERVER_XWHO, xwho); + } + } + + public void setEventMessage(final String message) { + if (this.listener != null) { + this.listener.onEventMessage(message); + } + } +} diff --git a/ans-sdk/analysys_core/src/main/java/com/analysys/process/AgentProcess.java b/ans-sdk/analysys_core/src/main/java/com/analysys/process/AgentProcess.java index 232d5e6..ebd4bef 100644 --- a/ans-sdk/analysys_core/src/main/java/com/analysys/process/AgentProcess.java +++ b/ans-sdk/analysys_core/src/main/java/com/analysys/process/AgentProcess.java @@ -11,6 +11,8 @@ import com.analysys.AnsIDControl; import com.analysys.AnsRamControl; import com.analysys.AutomaticAcquisition; +import com.analysys.ObserverListener; +import com.analysys.easytouch.EasytouchProcess; import com.analysys.hybrid.HybridBridge; import com.analysys.network.UploadManager; import com.analysys.push.PushListener; @@ -166,6 +168,9 @@ public Object call() throws Exception { }); } + public void setObserverListener(ObserverListener listener) { + EasytouchProcess.getInstance().setObserverListener(listener); + } /** * debug 信息处理 */ @@ -408,6 +413,7 @@ public void run() { return; } // CommonUtils.setIdFile(context, Constants.SP_DISTINCT_ID, distinctId); + EasytouchProcess.getInstance().setXwho(distinctId); UserInfo.setDistinctID(distinctId); } @@ -458,6 +464,7 @@ public void run() { currentTime,Constants.API_ALIAS, Constants.ALIAS, aliasMap, null); if (!CommonUtils.isEmpty(eventData)) { + EasytouchProcess.getInstance().setXwho(aliasId); trackEvent(context, Constants.API_ALIAS, Constants.ALIAS, eventData); sendProfileSetOnce(context, 0,currentTime); } else { @@ -496,6 +503,7 @@ public void run() { currentTime,Constants.API_ALIAS, Constants.ALIAS, aliasMap, null); if (!CommonUtils.isEmpty(eventData)) { + EasytouchProcess.getInstance().setXwho(aliasId); trackEvent(context, Constants.API_ALIAS, Constants.ALIAS, eventData); sendProfileSetOnce(context, 0,currentTime); } else { @@ -1607,6 +1615,7 @@ private void trackEvent(Context context, String apiName, if (LogBean.getCode() == Constants.CODE_SUCCESS) { LogPrompt.showLog(apiName, true); } + EasytouchProcess.getInstance().setEventMessage(eventData.toString()); UploadManager.getInstance(context).sendManager(eventName, eventData); } } diff --git a/config.gradle b/config.gradle index 4da6a3f..c137b2e 100644 --- a/config.gradle +++ b/config.gradle @@ -1,6 +1,6 @@ ext { - version = '4.4.11' + version = '4.4.12'