Skip to content

Commit 2534264

Browse files
author
彭远洋
committed
Release 0.0.3
1 parent c771bdc commit 2534264

File tree

7 files changed

+479
-7
lines changed

7 files changed

+479
-7
lines changed

android/SensorsdataUniPlugin/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ dependencies {
3333
compileOnly 'com.android.support:appcompat-v7:28.0.0'
3434
compileOnly 'com.alibaba:fastjson:1.1.46.android'
3535

36-
compileOnly fileTree(dir: 'libs', include: ['uniapp-release.aar'])
37-
compileOnly 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:5.0.0'
36+
compileOnly fileTree(dir: 'libs', include: ['uniapp-v8-release.aar'])
37+
compileOnly 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:5.4.5'
3838
compileOnly 'com.alibaba:fastjson:1.1.46.android'
3939

4040
}

android/SensorsdataUniPlugin/src/main/java/com/sensorsdata/uniapp/UniSensorsAnalyticsModule.java

Lines changed: 227 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
public class UniSensorsAnalyticsModule extends UniDestroyableModule {
3434

35-
public static final String VERSION = "0.0.2";
35+
public static final String VERSION = "0.0.3";
3636

3737
private static final String MODULE_NAME = "UniSensorsAnalyticsModule";
3838
private static final String LOG_TAG = "SA.UniModule";
@@ -52,6 +52,21 @@ public void track(String eventName, JSONObject properties) {
5252
}
5353
}
5454

55+
/**
56+
* 调用 trackViewScreen 接口,触发页面浏览事件
57+
*
58+
* @param url url
59+
* @param properties 事件的属性
60+
*/
61+
@UniJSMethod()
62+
public void trackViewScreen(String url, JSONObject properties) {
63+
try {
64+
SensorsDataAPI.sharedInstance().trackViewScreen(url, UniPropertyManager.mergeProperty(JSONUtils.convertToJSONObject(properties)));
65+
} catch (Exception e) {
66+
Log.i(LOG_TAG, e.getMessage());
67+
}
68+
}
69+
5570
/**
5671
* 设置当前 serverUrl
5772
*
@@ -494,6 +509,217 @@ public void profileDelete() {
494509
}
495510
}
496511

512+
/**
513+
* 保存用户推送 ID 到用户表
514+
*
515+
* @param pushTypeKey 属性名称(例如 jgId)
516+
* @param pushId 推送 ID
517+
* 使用 profilePushId("jgId",JPushInterface.getRegistrationID(this))
518+
*/
519+
@UniJSMethod
520+
public void profilePushId(String pushTypeKey, String pushId) {
521+
try {
522+
SensorsDataAPI.sharedInstance().profilePushId(pushTypeKey, pushId);
523+
} catch (Exception e) {
524+
Log.i(LOG_TAG, e.getMessage());
525+
}
526+
}
527+
528+
/**
529+
* 删除用户设置的 pushId
530+
*
531+
* @param pushTypeKey 属性名称(例如 jgId)
532+
*/
533+
@UniJSMethod
534+
public void profileUnsetPushId(String pushTypeKey) {
535+
try {
536+
SensorsDataAPI.sharedInstance().profileUnsetPushId(pushTypeKey);
537+
} catch (Exception e) {
538+
Log.i(LOG_TAG, e.getMessage());
539+
}
540+
}
541+
542+
/**
543+
* 初始化事件的计时器,计时单位为秒。
544+
*
545+
* @param eventName 事件的名称
546+
* @return 交叉计时的事件名称
547+
*/
548+
@UniJSMethod(uiThread = false)
549+
public String trackTimerStart(String eventName) {
550+
try {
551+
return SensorsDataAPI.sharedInstance().trackTimerStart(eventName);
552+
} catch (Exception e) {
553+
Log.i(LOG_TAG, e.getMessage());
554+
}
555+
return null;
556+
}
557+
558+
/**
559+
* 暂停事件计时器,计时单位为秒。
560+
*
561+
* @param eventName 事件的名称
562+
*/
563+
@UniJSMethod()
564+
public void trackTimerPause(String eventName) {
565+
try {
566+
SensorsDataAPI.sharedInstance().trackTimerPause(eventName);
567+
} catch (Exception e) {
568+
Log.i(LOG_TAG, e.getMessage());
569+
}
570+
}
571+
572+
/**
573+
* 恢复事件计时器,计时单位为秒。
574+
*
575+
* @param eventName 事件的名称
576+
*/
577+
@UniJSMethod()
578+
public void trackTimerResume(String eventName) {
579+
try {
580+
SensorsDataAPI.sharedInstance().trackTimerResume(eventName);
581+
} catch (Exception e) {
582+
Log.i(LOG_TAG, e.getMessage());
583+
}
584+
}
585+
586+
/**
587+
* 停止事件计时器
588+
*
589+
* @param eventName 事件的名称,或者交叉计算场景时 trackTimerStart 的返回值
590+
* @param properties 事件的属性
591+
*/
592+
@UniJSMethod()
593+
public void trackTimerEnd(String eventName, JSONObject properties) {
594+
try {
595+
SensorsDataAPI.sharedInstance().trackTimerEnd(eventName, UniPropertyManager.mergeProperty(JSONUtils.convertToJSONObject(properties)));
596+
} catch (Exception e) {
597+
Log.i(LOG_TAG, e.getMessage());
598+
}
599+
}
600+
601+
/**
602+
* 删除事件的计时器
603+
*
604+
* @param eventName 事件名称
605+
*/
606+
@UniJSMethod()
607+
public void removeTimer(String eventName) {
608+
try {
609+
SensorsDataAPI.sharedInstance().removeTimer(eventName);
610+
} catch (Exception e) {
611+
Log.i(LOG_TAG, e.getMessage());
612+
}
613+
}
614+
615+
/**
616+
* 清除所有事件计时器
617+
*/
618+
@UniJSMethod
619+
public void clearTrackTimer() {
620+
try {
621+
SensorsDataAPI.sharedInstance().clearTrackTimer();
622+
} catch (Exception e) {
623+
Log.i(LOG_TAG, e.getMessage());
624+
}
625+
}
626+
627+
/**
628+
* 获取事件公共属性
629+
*
630+
* @return 当前所有 Super 属性
631+
*/
632+
@UniJSMethod(uiThread = false)
633+
public JSONObject getSuperProperties() {
634+
try {
635+
return JSONUtils.convertToFastJson(SensorsDataAPI.sharedInstance().getSuperProperties());
636+
} catch (Exception e) {
637+
Log.i(LOG_TAG, e.getMessage());
638+
}
639+
return null;
640+
}
641+
642+
/**
643+
* DeepLink 是否采集设备信息
644+
*
645+
* @param enable 是否采集设备信息 true:是 false:否
646+
*/
647+
@UniJSMethod
648+
public void enableDeepLinkInstallSource(boolean enable) {
649+
try {
650+
SensorsDataAPI.sharedInstance().enableDeepLinkInstallSource(enable);
651+
} catch (Exception e) {
652+
Log.i(LOG_TAG, e.getMessage());
653+
}
654+
}
655+
656+
/**
657+
* 记录 $AppDeepLinkLaunch 事件
658+
*
659+
* @param deepLinkUrl 唤起应用的 DeepLink 链接
660+
* @param oaid oaid 非必填
661+
*/
662+
@UniJSMethod
663+
public void trackDeepLinkLaunch(String deepLinkUrl, String oaid) {
664+
try {
665+
SensorsDataAPI.sharedInstance().trackDeepLinkLaunch(deepLinkUrl, oaid);
666+
} catch (Exception e) {
667+
Log.i(LOG_TAG, e.getMessage());
668+
}
669+
}
670+
671+
/**
672+
* 开启/关闭采集屏幕方向
673+
*
674+
* @param enable true:开启 false:关闭
675+
*/
676+
@UniJSMethod
677+
public void enableTrackScreenOrientation(boolean enable) {
678+
try {
679+
SensorsDataAPI.sharedInstance().enableTrackScreenOrientation(enable);
680+
} catch (Exception e) {
681+
Log.i(LOG_TAG, e.getMessage());
682+
}
683+
}
684+
685+
/**
686+
* 恢复采集屏幕方向
687+
*/
688+
@UniJSMethod
689+
public void resumeTrackScreenOrientation() {
690+
try {
691+
SensorsDataAPI.sharedInstance().resumeTrackScreenOrientation();
692+
} catch (Exception e) {
693+
Log.i(LOG_TAG, e.getMessage());
694+
}
695+
}
696+
697+
/**
698+
* 停止采集屏幕方向
699+
*/
700+
@UniJSMethod
701+
public void stopTrackScreenOrientation() {
702+
try {
703+
SensorsDataAPI.sharedInstance().stopTrackScreenOrientation();
704+
} catch (Exception e) {
705+
Log.i(LOG_TAG, e.getMessage());
706+
}
707+
}
708+
709+
/**
710+
* 获取当前屏幕方向
711+
*
712+
* @return portrait:竖屏 landscape:横屏
713+
*/
714+
@UniJSMethod(uiThread = false)
715+
public String getScreenOrientation() {
716+
try {
717+
return SensorsDataAPI.sharedInstance().getScreenOrientation();
718+
} catch (Exception e) {
719+
Log.i(LOG_TAG, e.getMessage());
720+
}
721+
return "";
722+
}
497723

498724
@Override
499725
public void destroy() {

android/SensorsdataUniPlugin/src/main/java/com/sensorsdata/uniapp/UniSensorsAnalyticsProxy.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,22 @@ private void initSensorsDataAPI(Application application) {
131131
}
132132
} catch (Exception ignored) {
133133

134+
}
135+
//设置远程配置请求地址
136+
try {
137+
String remoteConfigUrl = appInfo.metaData.getString("com.sensorsdata.analytics.uni.RemoteConfigUrl");
138+
if (!TextUtils.isEmpty(remoteConfigUrl)) {
139+
configOptions.setRemoteConfigUrl(remoteConfigUrl);
140+
}
141+
} catch (Exception ignored) {
142+
143+
}
144+
// 是否在手动埋点事件中自动添加渠道匹配信息,默认 false
145+
try {
146+
boolean enableAutoAddChannelCallbackEvent = appInfo.metaData.getBoolean("com.sensorsdata.analytics.uni.EventAutoAddChannelCallbackEvent", false);
147+
configOptions.enableAutoAddChannelCallbackEvent(enableAutoAddChannelCallbackEvent);
148+
} catch (Exception ignored) {
149+
134150
}
135151
} catch (PackageManager.NameNotFoundException e) {
136152
Log.i(LOG_TAG, e.getMessage());

0 commit comments

Comments
 (0)