Skip to content

Commit f17e384

Browse files
author
shengyonggen
committed
增加mphide时候的停留时长
1 parent d2db47b commit f17e384

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

sensorsdata.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ var mp_scene = {
8383

8484
var sa_referrer = '直接打开';
8585

86+
var mpshow_time = null;
87+
8688
sa.lib_version = LIB_VERSION;
8789

8890
var logger = typeof logger === 'object' ? logger : {};
@@ -944,6 +946,8 @@ function appShow(para) {
944946
// console.log('app_show', JSON.stringify(arguments));
945947
var prop = {};
946948

949+
mpshow_time = (new Date()).getTime();
950+
947951
if (para && para.path) {
948952
prop.$url_path = para.path;
949953
}
@@ -958,8 +962,14 @@ function appShow(para) {
958962
};
959963

960964
function appHide() {
965+
var current_time = (new Date()).getTime();
966+
var prop = {};
967+
if (mpshow_time && (current_time - mpshow_time > 0) && ((current_time - mpshow_time)/3600000 < 24) ) {
968+
prop.event_duration = (current_time - mpshow_time)/1000;
969+
}
961970
if (sa.para.autoTrack && sa.para.autoTrack.appHide === true) {
962-
sa.autoTrackCustom('appHide', {}, '$MPHide');
971+
972+
sa.autoTrackCustom('appHide', prop, '$MPHide');
963973
}
964974
// console.log('app_hide', JSON.stringify(arguments));
965975
// sa.track('app_hide', { detail: JSON.stringify(arguments) });

0 commit comments

Comments
 (0)