Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
a9ad3ff8
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a9ad3ff8
编写于
5月 06, 2022
作者:
M
mehaotian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(stat): 统计1.0 缺失 ak uuid p 等字段
上级
18d6b554
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
284 addition
and
276 deletion
+284
-276
packages/uni-stat/dist/uni-cloud-stat.cjs.js
packages/uni-stat/dist/uni-cloud-stat.cjs.js
+71
-69
packages/uni-stat/dist/uni-cloud-stat.es.js
packages/uni-stat/dist/uni-cloud-stat.es.js
+71
-69
packages/uni-stat/dist/uni-stat.cjs.js
packages/uni-stat/dist/uni-stat.cjs.js
+71
-69
packages/uni-stat/dist/uni-stat.es.js
packages/uni-stat/dist/uni-stat.es.js
+71
-69
未找到文件。
packages/uni-stat/dist/uni-cloud-stat.cjs.js
浏览文件 @
a9ad3ff8
...
...
@@ -21,9 +21,10 @@ let titleJsons = {};
let
debug
=
!!
process
.
env
.
UNI_STAT_DEBUG
||
false
;
// #ifdef VUE3
titleJsons
=
process
.
env
.
UNI_STAT_TITLE_JSON
;
// #endif
// #ifndef VUE3
// eslint-disable-next-line no-restricted-globals
const
pagesTitle
=
require
(
'
uni-pages?{"type":"style"}
'
).
default
;
let
pagesData
=
pagesTitle
.
pages
;
...
...
@@ -44,39 +45,40 @@ for (let i in pagesData) {
// #endif
// TODO 在云函数中获取,暂时注释
// const UUID_KEY = '__DC_STAT_UUID'
// const UUID_VALUE = '__DC_UUID_VALUE'
// function getUuid() {
// let uuid = ''
// if (get_platform_name() === 'n') {
// try {
// uuid = plus.runtime.getDCloudId()
// } catch (e) {
// uuid = ''
// }
// return uuid
// }
// try {
// uuid = uni.getStorageSync(UUID_KEY)
// } catch (e) {
// uuid = UUID_VALUE
// }
// if (!uuid) {
// uuid = Date.now() + '' + Math.floor(Math.random() * 1e7)
// try {
// uni.setStorageSync(UUID_KEY, uuid)
// } catch (e) {
// uni.setStorageSync(UUID_KEY, UUID_VALUE)
// }
// }
// return uuid
// }
// export const get_uuid = (statData) => {
// // 有可能不存在 deviceId(一般不存在就是出bug了),就自己生成一个
// return sys.deviceId || getUuid()
// }
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
const
UUID_VALUE
=
'
__DC_UUID_VALUE
'
;
function
getUuid
()
{
let
uuid
=
''
;
if
(
get_platform_name
()
===
'
n
'
)
{
try
{
uuid
=
plus
.
runtime
.
getDCloudId
();
}
catch
(
e
)
{
uuid
=
''
;
}
return
uuid
}
try
{
uuid
=
uni
.
getStorageSync
(
UUID_KEY
);
}
catch
(
e
)
{
uuid
=
UUID_VALUE
;
}
if
(
!
uuid
)
{
uuid
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
try
{
uni
.
setStorageSync
(
UUID_KEY
,
uuid
);
}
catch
(
e
)
{
uni
.
setStorageSync
(
UUID_KEY
,
UUID_VALUE
);
}
}
return
uuid
}
const
get_uuid
=
(
statData
)
=>
{
// 有可能不存在 deviceId(一般不存在就是出bug了),就自己生成一个
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取配置信息 如 appid
...
...
@@ -561,15 +563,15 @@ const get_first_visit_time = () => {
time
=
timeStorge
;
}
else
{
time
=
get_time
();
dbSet
(
FIRST_VISIT_TIME_KEY
,
time
);
dbSet
(
FIRST_VISIT_TIME_KEY
,
time
);
// 首次访问需要 将最后访问时间置 0
dbRemove
(
LAST_VISIT_TIME_KEY
);
}
return
time
};
/**
* 最后访问时间
/**
* 最后访问时间
*/
const
get_last_visit_time
=
()
=>
{
const
timeStorge
=
dbGet
(
LAST_VISIT_TIME_KEY
);
...
...
@@ -600,20 +602,20 @@ const set_page_residence_time = () => {
*/
const
get_page_residence_time
=
()
=>
{
Last_Page_Residence_Time
=
get_time
();
First_Page_Residence_Time
=
dbGet
(
PAGE_RESIDENCE_TIME
);
First_Page_Residence_Time
=
dbGet
(
PAGE_RESIDENCE_TIME
);
return
Last_Page_Residence_Time
-
First_Page_Residence_Time
};
/**
* 获取总访问次数
/**
* 获取总访问次数
*/
const
TOTAL_VISIT_COUNT
=
'
__total__visit__count
'
;
const
TOTAL_VISIT_COUNT
=
'
__total__visit__count
'
;
const
get_total_visit_count
=
()
=>
{
const
timeStorge
=
dbGet
(
TOTAL_VISIT_COUNT
);
let
count
=
1
;
let
count
=
1
;
if
(
timeStorge
)
{
count
=
timeStorge
;
count
++
;
count
++
;
}
dbSet
(
TOTAL_VISIT_COUNT
,
count
);
return
count
...
...
@@ -621,9 +623,9 @@ const get_total_visit_count = () => {
let
Set__First__Time
=
0
;
let
Set__Last__Time
=
0
;
/**
* 获取第一次时间
/**
* 获取第一次时间
*/
const
get_first_time
=
()
=>
{
let
time
=
new
Date
().
getTime
();
...
...
@@ -632,8 +634,8 @@ const get_first_time = () => {
return
time
};
/**
* 获取最后一次时间
/**
* 获取最后一次时间
*/
const
get_last_time
=
()
=>
{
let
time
=
new
Date
().
getTime
();
...
...
@@ -641,16 +643,16 @@ const get_last_time = () => {
return
time
};
/**
* 获取页面 \ 应用停留时间
/**
* 获取页面 \ 应用停留时间
*/
const
get_residence_time
=
(
type
)
=>
{
let
residenceTime
=
0
;
let
residenceTime
=
0
;
if
(
Set__First__Time
!==
0
)
{
residenceTime
=
Set__Last__Time
-
Set__First__Time
;
}
residenceTime
=
parseInt
(
residenceTime
/
1000
);
residenceTime
=
parseInt
(
residenceTime
/
1000
);
residenceTime
=
residenceTime
<
1
?
1
:
residenceTime
;
if
(
type
===
'
app
'
)
{
let
overtime
=
residenceTime
>
APP_PVER_TIME
?
true
:
false
;
...
...
@@ -673,9 +675,9 @@ const get_residence_time = (type) => {
// 统计数据默认值
let
statData
=
{
//
uuid: get_uuid(), // 设备标识
//
ak: stat_config.appid, // uni-app 应用 Appid
//
p: sys.platform === 'android' ? 'a' : 'i', // 手机系统
uuid
:
get_uuid
(),
// 设备标识
ak
:
stat_config
.
appid
,
// uni-app 应用 Appid
p
:
sys
.
platform
===
'
android
'
?
'
a
'
:
'
i
'
,
// 手机系统
ut
:
get_platform_name
(),
// 平台类型
mpn
:
get_pack_name
(),
// 原生平台包名、小程序 appid
usv
:
STAT_VERSION
,
// 统计 sdk 版本
...
...
@@ -948,9 +950,9 @@ class Report {
let
{
url
,
urlref
,
urlref_ts
}
=
opt
;
this
.
_navigationBarTitle
.
lt
=
'
11
'
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
11
'
,
ut
:
this
.
statData
.
ut
,
url
,
...
...
@@ -972,9 +974,9 @@ class Report {
sendHideRequest
(
opt
,
type
)
{
let
{
urlref
,
urlref_ts
}
=
opt
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
3
'
,
ut
:
this
.
statData
.
ut
,
urlref
,
...
...
@@ -995,9 +997,9 @@ class Report {
this
.
_navigationBarTitle
.
config
=
get_page_name
(
routepath
);
this
.
_navigationBarTitle
.
lt
=
'
21
'
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
21
'
,
ut
:
this
.
statData
.
ut
,
url
:
routepath
,
...
...
@@ -1297,9 +1299,9 @@ class Stat extends Report {
emVal
=
em
.
stack
;
}
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
31
'
,
ut
:
this
.
statData
.
ut
,
ch
:
this
.
statData
.
ch
,
...
...
packages/uni-stat/dist/uni-cloud-stat.es.js
浏览文件 @
a9ad3ff8
...
...
@@ -19,9 +19,10 @@ let titleJsons = {};
let
debug
=
!!
process
.
env
.
UNI_STAT_DEBUG
||
false
;
// #ifdef VUE3
titleJsons
=
process
.
env
.
UNI_STAT_TITLE_JSON
;
// #endif
// #ifndef VUE3
// eslint-disable-next-line no-restricted-globals
const
pagesTitle
=
require
(
'
uni-pages?{"type":"style"}
'
).
default
;
let
pagesData
=
pagesTitle
.
pages
;
...
...
@@ -42,39 +43,40 @@ for (let i in pagesData) {
// #endif
// TODO 在云函数中获取,暂时注释
// const UUID_KEY = '__DC_STAT_UUID'
// const UUID_VALUE = '__DC_UUID_VALUE'
// function getUuid() {
// let uuid = ''
// if (get_platform_name() === 'n') {
// try {
// uuid = plus.runtime.getDCloudId()
// } catch (e) {
// uuid = ''
// }
// return uuid
// }
// try {
// uuid = uni.getStorageSync(UUID_KEY)
// } catch (e) {
// uuid = UUID_VALUE
// }
// if (!uuid) {
// uuid = Date.now() + '' + Math.floor(Math.random() * 1e7)
// try {
// uni.setStorageSync(UUID_KEY, uuid)
// } catch (e) {
// uni.setStorageSync(UUID_KEY, UUID_VALUE)
// }
// }
// return uuid
// }
// export const get_uuid = (statData) => {
// // 有可能不存在 deviceId(一般不存在就是出bug了),就自己生成一个
// return sys.deviceId || getUuid()
// }
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
const
UUID_VALUE
=
'
__DC_UUID_VALUE
'
;
function
getUuid
()
{
let
uuid
=
''
;
if
(
get_platform_name
()
===
'
n
'
)
{
try
{
uuid
=
plus
.
runtime
.
getDCloudId
();
}
catch
(
e
)
{
uuid
=
''
;
}
return
uuid
}
try
{
uuid
=
uni
.
getStorageSync
(
UUID_KEY
);
}
catch
(
e
)
{
uuid
=
UUID_VALUE
;
}
if
(
!
uuid
)
{
uuid
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
try
{
uni
.
setStorageSync
(
UUID_KEY
,
uuid
);
}
catch
(
e
)
{
uni
.
setStorageSync
(
UUID_KEY
,
UUID_VALUE
);
}
}
return
uuid
}
const
get_uuid
=
(
statData
)
=>
{
// 有可能不存在 deviceId(一般不存在就是出bug了),就自己生成一个
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取配置信息 如 appid
...
...
@@ -559,15 +561,15 @@ const get_first_visit_time = () => {
time
=
timeStorge
;
}
else
{
time
=
get_time
();
dbSet
(
FIRST_VISIT_TIME_KEY
,
time
);
dbSet
(
FIRST_VISIT_TIME_KEY
,
time
);
// 首次访问需要 将最后访问时间置 0
dbRemove
(
LAST_VISIT_TIME_KEY
);
}
return
time
};
/**
* 最后访问时间
/**
* 最后访问时间
*/
const
get_last_visit_time
=
()
=>
{
const
timeStorge
=
dbGet
(
LAST_VISIT_TIME_KEY
);
...
...
@@ -598,20 +600,20 @@ const set_page_residence_time = () => {
*/
const
get_page_residence_time
=
()
=>
{
Last_Page_Residence_Time
=
get_time
();
First_Page_Residence_Time
=
dbGet
(
PAGE_RESIDENCE_TIME
);
First_Page_Residence_Time
=
dbGet
(
PAGE_RESIDENCE_TIME
);
return
Last_Page_Residence_Time
-
First_Page_Residence_Time
};
/**
* 获取总访问次数
/**
* 获取总访问次数
*/
const
TOTAL_VISIT_COUNT
=
'
__total__visit__count
'
;
const
TOTAL_VISIT_COUNT
=
'
__total__visit__count
'
;
const
get_total_visit_count
=
()
=>
{
const
timeStorge
=
dbGet
(
TOTAL_VISIT_COUNT
);
let
count
=
1
;
let
count
=
1
;
if
(
timeStorge
)
{
count
=
timeStorge
;
count
++
;
count
++
;
}
dbSet
(
TOTAL_VISIT_COUNT
,
count
);
return
count
...
...
@@ -619,9 +621,9 @@ const get_total_visit_count = () => {
let
Set__First__Time
=
0
;
let
Set__Last__Time
=
0
;
/**
* 获取第一次时间
/**
* 获取第一次时间
*/
const
get_first_time
=
()
=>
{
let
time
=
new
Date
().
getTime
();
...
...
@@ -630,8 +632,8 @@ const get_first_time = () => {
return
time
};
/**
* 获取最后一次时间
/**
* 获取最后一次时间
*/
const
get_last_time
=
()
=>
{
let
time
=
new
Date
().
getTime
();
...
...
@@ -639,16 +641,16 @@ const get_last_time = () => {
return
time
};
/**
* 获取页面 \ 应用停留时间
/**
* 获取页面 \ 应用停留时间
*/
const
get_residence_time
=
(
type
)
=>
{
let
residenceTime
=
0
;
let
residenceTime
=
0
;
if
(
Set__First__Time
!==
0
)
{
residenceTime
=
Set__Last__Time
-
Set__First__Time
;
}
residenceTime
=
parseInt
(
residenceTime
/
1000
);
residenceTime
=
parseInt
(
residenceTime
/
1000
);
residenceTime
=
residenceTime
<
1
?
1
:
residenceTime
;
if
(
type
===
'
app
'
)
{
let
overtime
=
residenceTime
>
APP_PVER_TIME
?
true
:
false
;
...
...
@@ -671,9 +673,9 @@ const get_residence_time = (type) => {
// 统计数据默认值
let
statData
=
{
//
uuid: get_uuid(), // 设备标识
//
ak: stat_config.appid, // uni-app 应用 Appid
//
p: sys.platform === 'android' ? 'a' : 'i', // 手机系统
uuid
:
get_uuid
(),
// 设备标识
ak
:
stat_config
.
appid
,
// uni-app 应用 Appid
p
:
sys
.
platform
===
'
android
'
?
'
a
'
:
'
i
'
,
// 手机系统
ut
:
get_platform_name
(),
// 平台类型
mpn
:
get_pack_name
(),
// 原生平台包名、小程序 appid
usv
:
STAT_VERSION
,
// 统计 sdk 版本
...
...
@@ -946,9 +948,9 @@ class Report {
let
{
url
,
urlref
,
urlref_ts
}
=
opt
;
this
.
_navigationBarTitle
.
lt
=
'
11
'
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
11
'
,
ut
:
this
.
statData
.
ut
,
url
,
...
...
@@ -970,9 +972,9 @@ class Report {
sendHideRequest
(
opt
,
type
)
{
let
{
urlref
,
urlref_ts
}
=
opt
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
3
'
,
ut
:
this
.
statData
.
ut
,
urlref
,
...
...
@@ -993,9 +995,9 @@ class Report {
this
.
_navigationBarTitle
.
config
=
get_page_name
(
routepath
);
this
.
_navigationBarTitle
.
lt
=
'
21
'
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
21
'
,
ut
:
this
.
statData
.
ut
,
url
:
routepath
,
...
...
@@ -1295,9 +1297,9 @@ class Stat extends Report {
emVal
=
em
.
stack
;
}
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
31
'
,
ut
:
this
.
statData
.
ut
,
ch
:
this
.
statData
.
ch
,
...
...
packages/uni-stat/dist/uni-stat.cjs.js
浏览文件 @
a9ad3ff8
...
...
@@ -21,9 +21,10 @@ let titleJsons = {};
let
debug
=
!!
process
.
env
.
UNI_STAT_DEBUG
||
false
;
// #ifdef VUE3
titleJsons
=
process
.
env
.
UNI_STAT_TITLE_JSON
;
// #endif
// #ifndef VUE3
// eslint-disable-next-line no-restricted-globals
const
pagesTitle
=
require
(
'
uni-pages?{"type":"style"}
'
).
default
;
let
pagesData
=
pagesTitle
.
pages
;
...
...
@@ -44,39 +45,40 @@ for (let i in pagesData) {
// #endif
// TODO 在云函数中获取,暂时注释
// const UUID_KEY = '__DC_STAT_UUID'
// const UUID_VALUE = '__DC_UUID_VALUE'
// function getUuid() {
// let uuid = ''
// if (get_platform_name() === 'n') {
// try {
// uuid = plus.runtime.getDCloudId()
// } catch (e) {
// uuid = ''
// }
// return uuid
// }
// try {
// uuid = uni.getStorageSync(UUID_KEY)
// } catch (e) {
// uuid = UUID_VALUE
// }
// if (!uuid) {
// uuid = Date.now() + '' + Math.floor(Math.random() * 1e7)
// try {
// uni.setStorageSync(UUID_KEY, uuid)
// } catch (e) {
// uni.setStorageSync(UUID_KEY, UUID_VALUE)
// }
// }
// return uuid
// }
// export const get_uuid = (statData) => {
// // 有可能不存在 deviceId(一般不存在就是出bug了),就自己生成一个
// return sys.deviceId || getUuid()
// }
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
const
UUID_VALUE
=
'
__DC_UUID_VALUE
'
;
function
getUuid
()
{
let
uuid
=
''
;
if
(
get_platform_name
()
===
'
n
'
)
{
try
{
uuid
=
plus
.
runtime
.
getDCloudId
();
}
catch
(
e
)
{
uuid
=
''
;
}
return
uuid
}
try
{
uuid
=
uni
.
getStorageSync
(
UUID_KEY
);
}
catch
(
e
)
{
uuid
=
UUID_VALUE
;
}
if
(
!
uuid
)
{
uuid
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
try
{
uni
.
setStorageSync
(
UUID_KEY
,
uuid
);
}
catch
(
e
)
{
uni
.
setStorageSync
(
UUID_KEY
,
UUID_VALUE
);
}
}
return
uuid
}
const
get_uuid
=
(
statData
)
=>
{
// 有可能不存在 deviceId(一般不存在就是出bug了),就自己生成一个
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取配置信息 如 appid
...
...
@@ -529,15 +531,15 @@ const get_first_visit_time = () => {
time
=
timeStorge
;
}
else
{
time
=
get_time
();
dbSet
(
FIRST_VISIT_TIME_KEY
,
time
);
dbSet
(
FIRST_VISIT_TIME_KEY
,
time
);
// 首次访问需要 将最后访问时间置 0
dbRemove
(
LAST_VISIT_TIME_KEY
);
}
return
time
};
/**
* 最后访问时间
/**
* 最后访问时间
*/
const
get_last_visit_time
=
()
=>
{
const
timeStorge
=
dbGet
(
LAST_VISIT_TIME_KEY
);
...
...
@@ -568,20 +570,20 @@ const set_page_residence_time = () => {
*/
const
get_page_residence_time
=
()
=>
{
Last_Page_Residence_Time
=
get_time
();
First_Page_Residence_Time
=
dbGet
(
PAGE_RESIDENCE_TIME
);
First_Page_Residence_Time
=
dbGet
(
PAGE_RESIDENCE_TIME
);
return
Last_Page_Residence_Time
-
First_Page_Residence_Time
};
/**
* 获取总访问次数
/**
* 获取总访问次数
*/
const
TOTAL_VISIT_COUNT
=
'
__total__visit__count
'
;
const
TOTAL_VISIT_COUNT
=
'
__total__visit__count
'
;
const
get_total_visit_count
=
()
=>
{
const
timeStorge
=
dbGet
(
TOTAL_VISIT_COUNT
);
let
count
=
1
;
let
count
=
1
;
if
(
timeStorge
)
{
count
=
timeStorge
;
count
++
;
count
++
;
}
dbSet
(
TOTAL_VISIT_COUNT
,
count
);
return
count
...
...
@@ -589,9 +591,9 @@ const get_total_visit_count = () => {
let
Set__First__Time
=
0
;
let
Set__Last__Time
=
0
;
/**
* 获取第一次时间
/**
* 获取第一次时间
*/
const
get_first_time
=
()
=>
{
let
time
=
new
Date
().
getTime
();
...
...
@@ -600,8 +602,8 @@ const get_first_time = () => {
return
time
};
/**
* 获取最后一次时间
/**
* 获取最后一次时间
*/
const
get_last_time
=
()
=>
{
let
time
=
new
Date
().
getTime
();
...
...
@@ -609,16 +611,16 @@ const get_last_time = () => {
return
time
};
/**
* 获取页面 \ 应用停留时间
/**
* 获取页面 \ 应用停留时间
*/
const
get_residence_time
=
(
type
)
=>
{
let
residenceTime
=
0
;
let
residenceTime
=
0
;
if
(
Set__First__Time
!==
0
)
{
residenceTime
=
Set__Last__Time
-
Set__First__Time
;
}
residenceTime
=
parseInt
(
residenceTime
/
1000
);
residenceTime
=
parseInt
(
residenceTime
/
1000
);
residenceTime
=
residenceTime
<
1
?
1
:
residenceTime
;
if
(
type
===
'
app
'
)
{
let
overtime
=
residenceTime
>
APP_PVER_TIME
?
true
:
false
;
...
...
@@ -641,9 +643,9 @@ const get_residence_time = (type) => {
// 统计数据默认值
let
statData
=
{
//
uuid: get_uuid(), // 设备标识
//
ak: stat_config.appid, // uni-app 应用 Appid
//
p: sys.platform === 'android' ? 'a' : 'i', // 手机系统
uuid
:
get_uuid
(),
// 设备标识
ak
:
stat_config
.
appid
,
// uni-app 应用 Appid
p
:
sys
.
platform
===
'
android
'
?
'
a
'
:
'
i
'
,
// 手机系统
ut
:
get_platform_name
(),
// 平台类型
mpn
:
get_pack_name
(),
// 原生平台包名、小程序 appid
usv
:
STAT_VERSION
,
// 统计 sdk 版本
...
...
@@ -916,9 +918,9 @@ class Report {
let
{
url
,
urlref
,
urlref_ts
}
=
opt
;
this
.
_navigationBarTitle
.
lt
=
'
11
'
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
11
'
,
ut
:
this
.
statData
.
ut
,
url
,
...
...
@@ -940,9 +942,9 @@ class Report {
sendHideRequest
(
opt
,
type
)
{
let
{
urlref
,
urlref_ts
}
=
opt
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
3
'
,
ut
:
this
.
statData
.
ut
,
urlref
,
...
...
@@ -963,9 +965,9 @@ class Report {
this
.
_navigationBarTitle
.
config
=
get_page_name
(
routepath
);
this
.
_navigationBarTitle
.
lt
=
'
21
'
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
21
'
,
ut
:
this
.
statData
.
ut
,
url
:
routepath
,
...
...
@@ -1253,9 +1255,9 @@ class Stat extends Report {
emVal
=
em
.
stack
;
}
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
31
'
,
ut
:
this
.
statData
.
ut
,
ch
:
this
.
statData
.
ch
,
...
...
packages/uni-stat/dist/uni-stat.es.js
浏览文件 @
a9ad3ff8
...
...
@@ -19,9 +19,10 @@ let titleJsons = {};
let
debug
=
!!
process
.
env
.
UNI_STAT_DEBUG
||
false
;
// #ifdef VUE3
titleJsons
=
process
.
env
.
UNI_STAT_TITLE_JSON
;
// #endif
// #ifndef VUE3
// eslint-disable-next-line no-restricted-globals
const
pagesTitle
=
require
(
'
uni-pages?{"type":"style"}
'
).
default
;
let
pagesData
=
pagesTitle
.
pages
;
...
...
@@ -42,39 +43,40 @@ for (let i in pagesData) {
// #endif
// TODO 在云函数中获取,暂时注释
// const UUID_KEY = '__DC_STAT_UUID'
// const UUID_VALUE = '__DC_UUID_VALUE'
// function getUuid() {
// let uuid = ''
// if (get_platform_name() === 'n') {
// try {
// uuid = plus.runtime.getDCloudId()
// } catch (e) {
// uuid = ''
// }
// return uuid
// }
// try {
// uuid = uni.getStorageSync(UUID_KEY)
// } catch (e) {
// uuid = UUID_VALUE
// }
// if (!uuid) {
// uuid = Date.now() + '' + Math.floor(Math.random() * 1e7)
// try {
// uni.setStorageSync(UUID_KEY, uuid)
// } catch (e) {
// uni.setStorageSync(UUID_KEY, UUID_VALUE)
// }
// }
// return uuid
// }
// export const get_uuid = (statData) => {
// // 有可能不存在 deviceId(一般不存在就是出bug了),就自己生成一个
// return sys.deviceId || getUuid()
// }
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
const
UUID_VALUE
=
'
__DC_UUID_VALUE
'
;
function
getUuid
()
{
let
uuid
=
''
;
if
(
get_platform_name
()
===
'
n
'
)
{
try
{
uuid
=
plus
.
runtime
.
getDCloudId
();
}
catch
(
e
)
{
uuid
=
''
;
}
return
uuid
}
try
{
uuid
=
uni
.
getStorageSync
(
UUID_KEY
);
}
catch
(
e
)
{
uuid
=
UUID_VALUE
;
}
if
(
!
uuid
)
{
uuid
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
try
{
uni
.
setStorageSync
(
UUID_KEY
,
uuid
);
}
catch
(
e
)
{
uni
.
setStorageSync
(
UUID_KEY
,
UUID_VALUE
);
}
}
return
uuid
}
const
get_uuid
=
(
statData
)
=>
{
// 有可能不存在 deviceId(一般不存在就是出bug了),就自己生成一个
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取配置信息 如 appid
...
...
@@ -527,15 +529,15 @@ const get_first_visit_time = () => {
time
=
timeStorge
;
}
else
{
time
=
get_time
();
dbSet
(
FIRST_VISIT_TIME_KEY
,
time
);
dbSet
(
FIRST_VISIT_TIME_KEY
,
time
);
// 首次访问需要 将最后访问时间置 0
dbRemove
(
LAST_VISIT_TIME_KEY
);
}
return
time
};
/**
* 最后访问时间
/**
* 最后访问时间
*/
const
get_last_visit_time
=
()
=>
{
const
timeStorge
=
dbGet
(
LAST_VISIT_TIME_KEY
);
...
...
@@ -566,20 +568,20 @@ const set_page_residence_time = () => {
*/
const
get_page_residence_time
=
()
=>
{
Last_Page_Residence_Time
=
get_time
();
First_Page_Residence_Time
=
dbGet
(
PAGE_RESIDENCE_TIME
);
First_Page_Residence_Time
=
dbGet
(
PAGE_RESIDENCE_TIME
);
return
Last_Page_Residence_Time
-
First_Page_Residence_Time
};
/**
* 获取总访问次数
/**
* 获取总访问次数
*/
const
TOTAL_VISIT_COUNT
=
'
__total__visit__count
'
;
const
TOTAL_VISIT_COUNT
=
'
__total__visit__count
'
;
const
get_total_visit_count
=
()
=>
{
const
timeStorge
=
dbGet
(
TOTAL_VISIT_COUNT
);
let
count
=
1
;
let
count
=
1
;
if
(
timeStorge
)
{
count
=
timeStorge
;
count
++
;
count
++
;
}
dbSet
(
TOTAL_VISIT_COUNT
,
count
);
return
count
...
...
@@ -587,9 +589,9 @@ const get_total_visit_count = () => {
let
Set__First__Time
=
0
;
let
Set__Last__Time
=
0
;
/**
* 获取第一次时间
/**
* 获取第一次时间
*/
const
get_first_time
=
()
=>
{
let
time
=
new
Date
().
getTime
();
...
...
@@ -598,8 +600,8 @@ const get_first_time = () => {
return
time
};
/**
* 获取最后一次时间
/**
* 获取最后一次时间
*/
const
get_last_time
=
()
=>
{
let
time
=
new
Date
().
getTime
();
...
...
@@ -607,16 +609,16 @@ const get_last_time = () => {
return
time
};
/**
* 获取页面 \ 应用停留时间
/**
* 获取页面 \ 应用停留时间
*/
const
get_residence_time
=
(
type
)
=>
{
let
residenceTime
=
0
;
let
residenceTime
=
0
;
if
(
Set__First__Time
!==
0
)
{
residenceTime
=
Set__Last__Time
-
Set__First__Time
;
}
residenceTime
=
parseInt
(
residenceTime
/
1000
);
residenceTime
=
parseInt
(
residenceTime
/
1000
);
residenceTime
=
residenceTime
<
1
?
1
:
residenceTime
;
if
(
type
===
'
app
'
)
{
let
overtime
=
residenceTime
>
APP_PVER_TIME
?
true
:
false
;
...
...
@@ -639,9 +641,9 @@ const get_residence_time = (type) => {
// 统计数据默认值
let
statData
=
{
//
uuid: get_uuid(), // 设备标识
//
ak: stat_config.appid, // uni-app 应用 Appid
//
p: sys.platform === 'android' ? 'a' : 'i', // 手机系统
uuid
:
get_uuid
(),
// 设备标识
ak
:
stat_config
.
appid
,
// uni-app 应用 Appid
p
:
sys
.
platform
===
'
android
'
?
'
a
'
:
'
i
'
,
// 手机系统
ut
:
get_platform_name
(),
// 平台类型
mpn
:
get_pack_name
(),
// 原生平台包名、小程序 appid
usv
:
STAT_VERSION
,
// 统计 sdk 版本
...
...
@@ -914,9 +916,9 @@ class Report {
let
{
url
,
urlref
,
urlref_ts
}
=
opt
;
this
.
_navigationBarTitle
.
lt
=
'
11
'
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
11
'
,
ut
:
this
.
statData
.
ut
,
url
,
...
...
@@ -938,9 +940,9 @@ class Report {
sendHideRequest
(
opt
,
type
)
{
let
{
urlref
,
urlref_ts
}
=
opt
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
3
'
,
ut
:
this
.
statData
.
ut
,
urlref
,
...
...
@@ -961,9 +963,9 @@ class Report {
this
.
_navigationBarTitle
.
config
=
get_page_name
(
routepath
);
this
.
_navigationBarTitle
.
lt
=
'
21
'
;
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
21
'
,
ut
:
this
.
statData
.
ut
,
url
:
routepath
,
...
...
@@ -1251,9 +1253,9 @@ class Stat extends Report {
emVal
=
em
.
stack
;
}
let
options
=
{
//
ak: this.statData.ak,
//
uuid: this.statData.uuid,
//
p: this.statData.p,
ak
:
this
.
statData
.
ak
,
uuid
:
this
.
statData
.
uuid
,
p
:
this
.
statData
.
p
,
lt
:
'
31
'
,
ut
:
this
.
statData
.
ut
,
ch
:
this
.
statData
.
ch
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录