Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
20岁爱吃必胜客
uni-app
提交
70eeb8fb
U
uni-app
项目概览
20岁爱吃必胜客
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
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,发现更多精彩内容 >>
提交
70eeb8fb
编写于
7月 29, 2022
作者:
M
mehaotian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(stat): reportInterval
上级
d9fc5510
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
177 addition
and
40 deletion
+177
-40
packages/uni-stat/dist/uni-cloud-stat.cjs.js
packages/uni-stat/dist/uni-cloud-stat.cjs.js
+45
-9
packages/uni-stat/dist/uni-cloud-stat.es.js
packages/uni-stat/dist/uni-cloud-stat.es.js
+45
-9
packages/uni-stat/dist/uni-stat.cjs.js
packages/uni-stat/dist/uni-stat.cjs.js
+38
-8
packages/uni-stat/dist/uni-stat.es.js
packages/uni-stat/dist/uni-stat.es.js
+38
-8
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
+3
-1
packages/vue-cli-plugin-uni/lib/chain-webpack.js
packages/vue-cli-plugin-uni/lib/chain-webpack.js
+3
-2
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+5
-3
未找到文件。
packages/uni-stat/dist/uni-cloud-stat.cjs.js
浏览文件 @
70eeb8fb
...
...
@@ -14,6 +14,8 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
const
OPERATING_TIME
=
10
;
// 数据上报时间 单位s
const
DIFF_TIME
=
60
*
1000
*
60
*
24
;
// 获取 manifest.json 中统计配置
const
uniStatisticsConfig
=
process
.
env
.
UNI_STATISTICS_CONFIG
;
let
statConfig
=
{
appid
:
process
.
env
.
UNI_APP_ID
,
};
...
...
@@ -471,7 +473,8 @@ const is_debug = debug;
* 日志输出
* @param {*} data
*/
const
log
=
(
data
)
=>
{
const
log
=
(
data
,
type
)
=>
{
let
msg_type
=
''
;
switch
(
data
.
lt
)
{
case
'
1
'
:
...
...
@@ -494,11 +497,41 @@ const log = (data) => {
msg_type
=
'
PUSH
'
;
break
}
// #ifdef APP
// 在 app 中,日志转为 字符串
if
(
typeof
data
===
'
object
'
)
{
data
=
JSON
.
stringify
(
data
);
}
// #endif
if
(
type
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
data
);
console
.
log
(
`=== 上报结束 ===`
);
return
}
if
(
msg_type
)
{
console
.
log
(
`=== 统计数据采集:
${
msg_type
}
===`
);
console
.
log
(
data
);
console
.
log
(
`=== 采集结束 ===`
);
}
};
/**
* 获取上报时间间隔
* @param {*} defaultTime 默认上报间隔时间 单位s
*/
const
get_report_Interval
=
(
defaultTime
)
=>
{
let
time
=
uniStatisticsConfig
.
reportInterval
;
// 如果上报时间配置为0 相当于立即上报
if
(
Number
(
time
)
===
0
)
return
0
time
=
time
||
defaultTime
;
let
reg
=
/
(
^
[
1-9
]\d
*$
)
/
;
// 如果不是整数,则默认为上报间隔时间
if
(
!
reg
.
test
(
time
))
return
defaultTime
return
Number
(
time
)
};
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
...
...
@@ -672,6 +705,7 @@ const get_residence_time = (type) => {
}
};
const
eport_Interval
=
get_report_Interval
(
OPERATING_TIME
);
// 统计数据默认值
let
statData
=
{
uuid
:
get_uuid
(),
// 设备标识
...
...
@@ -1131,7 +1165,7 @@ class Report {
log
(
data
);
}
// 判断时候到达上报时间 ,默认 10 秒上报
if
(
page_residence_time
<
OPERATING_TIME
&&
!
type
)
return
if
(
page_residence_time
<
eport_Interval
&&
!
type
)
return
// 时间超过,重新获取时间戳
set_page_residence_time
();
...
...
@@ -1167,7 +1201,9 @@ class Report {
sendRequest
(
optionsData
)
{
{
if
(
!
uni
.
__stat_uniCloud_space
)
{
console
.
error
(
'
应用未关联服务空间,统计上报失败,请在uniCloud目录右键关联服务空间.
'
);
console
.
error
(
'
应用未关联服务空间,统计上报失败,请在uniCloud目录右键关联服务空间.
'
);
return
}
...
...
@@ -1181,9 +1217,7 @@ class Report {
.
report
(
optionsData
)
.
then
(()
=>
{
if
(
is_debug
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
optionsData
);
console
.
log
(
`=== 上报结束 ===`
);
log
(
optionsData
,
true
);
}
})
.
catch
((
err
)
=>
{
...
...
@@ -1204,9 +1238,7 @@ class Report {
let
options
=
get_sgin
(
get_encodeURIComponent_options
(
data
)).
options
;
image
.
src
=
STAT_H5_URL
+
'
?
'
+
options
;
if
(
is_debug
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
data
);
console
.
log
(
`=== 上报结束 ===`
);
log
(
data
,
true
);
}
});
}
...
...
@@ -1254,6 +1286,10 @@ class Stat extends Report {
// '=== 当前绑定的统计服务空间spaceId:' +
// uni.__stat_uniCloud_space.config.spaceId
// )
}
else
{
console
.
error
(
'
应用未关联服务空间,请在uniCloud目录右键关联服务空间
'
);
}
}
}
...
...
packages/uni-stat/dist/uni-cloud-stat.es.js
浏览文件 @
70eeb8fb
...
...
@@ -12,6 +12,8 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
const
OPERATING_TIME
=
10
;
// 数据上报时间 单位s
const
DIFF_TIME
=
60
*
1000
*
60
*
24
;
// 获取 manifest.json 中统计配置
const
uniStatisticsConfig
=
process
.
env
.
UNI_STATISTICS_CONFIG
;
let
statConfig
=
{
appid
:
process
.
env
.
UNI_APP_ID
,
};
...
...
@@ -469,7 +471,8 @@ const is_debug = debug;
* 日志输出
* @param {*} data
*/
const
log
=
(
data
)
=>
{
const
log
=
(
data
,
type
)
=>
{
let
msg_type
=
''
;
switch
(
data
.
lt
)
{
case
'
1
'
:
...
...
@@ -492,11 +495,41 @@ const log = (data) => {
msg_type
=
'
PUSH
'
;
break
}
// #ifdef APP
// 在 app 中,日志转为 字符串
if
(
typeof
data
===
'
object
'
)
{
data
=
JSON
.
stringify
(
data
);
}
// #endif
if
(
type
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
data
);
console
.
log
(
`=== 上报结束 ===`
);
return
}
if
(
msg_type
)
{
console
.
log
(
`=== 统计数据采集:
${
msg_type
}
===`
);
console
.
log
(
data
);
console
.
log
(
`=== 采集结束 ===`
);
}
};
/**
* 获取上报时间间隔
* @param {*} defaultTime 默认上报间隔时间 单位s
*/
const
get_report_Interval
=
(
defaultTime
)
=>
{
let
time
=
uniStatisticsConfig
.
reportInterval
;
// 如果上报时间配置为0 相当于立即上报
if
(
Number
(
time
)
===
0
)
return
0
time
=
time
||
defaultTime
;
let
reg
=
/
(
^
[
1-9
]\d
*$
)
/
;
// 如果不是整数,则默认为上报间隔时间
if
(
!
reg
.
test
(
time
))
return
defaultTime
return
Number
(
time
)
};
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
...
...
@@ -670,6 +703,7 @@ const get_residence_time = (type) => {
}
};
const
eport_Interval
=
get_report_Interval
(
OPERATING_TIME
);
// 统计数据默认值
let
statData
=
{
uuid
:
get_uuid
(),
// 设备标识
...
...
@@ -1129,7 +1163,7 @@ class Report {
log
(
data
);
}
// 判断时候到达上报时间 ,默认 10 秒上报
if
(
page_residence_time
<
OPERATING_TIME
&&
!
type
)
return
if
(
page_residence_time
<
eport_Interval
&&
!
type
)
return
// 时间超过,重新获取时间戳
set_page_residence_time
();
...
...
@@ -1165,7 +1199,9 @@ class Report {
sendRequest
(
optionsData
)
{
{
if
(
!
uni
.
__stat_uniCloud_space
)
{
console
.
error
(
'
应用未关联服务空间,统计上报失败,请在uniCloud目录右键关联服务空间.
'
);
console
.
error
(
'
应用未关联服务空间,统计上报失败,请在uniCloud目录右键关联服务空间.
'
);
return
}
...
...
@@ -1179,9 +1215,7 @@ class Report {
.
report
(
optionsData
)
.
then
(()
=>
{
if
(
is_debug
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
optionsData
);
console
.
log
(
`=== 上报结束 ===`
);
log
(
optionsData
,
true
);
}
})
.
catch
((
err
)
=>
{
...
...
@@ -1202,9 +1236,7 @@ class Report {
let
options
=
get_sgin
(
get_encodeURIComponent_options
(
data
)).
options
;
image
.
src
=
STAT_H5_URL
+
'
?
'
+
options
;
if
(
is_debug
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
data
);
console
.
log
(
`=== 上报结束 ===`
);
log
(
data
,
true
);
}
});
}
...
...
@@ -1252,6 +1284,10 @@ class Stat extends Report {
// '=== 当前绑定的统计服务空间spaceId:' +
// uni.__stat_uniCloud_space.config.spaceId
// )
}
else
{
console
.
error
(
'
应用未关联服务空间,请在uniCloud目录右键关联服务空间
'
);
}
}
}
...
...
packages/uni-stat/dist/uni-stat.cjs.js
浏览文件 @
70eeb8fb
...
...
@@ -14,6 +14,8 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
const
OPERATING_TIME
=
10
;
// 数据上报时间 单位s
const
DIFF_TIME
=
60
*
1000
*
60
*
24
;
// 获取 manifest.json 中统计配置
const
uniStatisticsConfig
=
process
.
env
.
UNI_STATISTICS_CONFIG
;
let
statConfig
=
{
appid
:
process
.
env
.
UNI_APP_ID
,
};
...
...
@@ -450,7 +452,8 @@ const is_debug = debug;
* 日志输出
* @param {*} data
*/
const
log
=
(
data
)
=>
{
const
log
=
(
data
,
type
)
=>
{
let
msg_type
=
''
;
switch
(
data
.
lt
)
{
case
'
1
'
:
...
...
@@ -473,11 +476,41 @@ const log = (data) => {
msg_type
=
'
PUSH
'
;
break
}
// #ifdef APP
// 在 app 中,日志转为 字符串
if
(
typeof
data
===
'
object
'
)
{
data
=
JSON
.
stringify
(
data
);
}
// #endif
if
(
type
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
data
);
console
.
log
(
`=== 上报结束 ===`
);
return
}
if
(
msg_type
)
{
console
.
log
(
`=== 统计数据采集:
${
msg_type
}
===`
);
console
.
log
(
data
);
console
.
log
(
`=== 采集结束 ===`
);
}
};
/**
* 获取上报时间间隔
* @param {*} defaultTime 默认上报间隔时间 单位s
*/
const
get_report_Interval
=
(
defaultTime
)
=>
{
let
time
=
uniStatisticsConfig
.
reportInterval
;
// 如果上报时间配置为0 相当于立即上报
if
(
Number
(
time
)
===
0
)
return
0
time
=
time
||
defaultTime
;
let
reg
=
/
(
^
[
1-9
]\d
*$
)
/
;
// 如果不是整数,则默认为上报间隔时间
if
(
!
reg
.
test
(
time
))
return
defaultTime
return
Number
(
time
)
};
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
...
...
@@ -651,6 +684,7 @@ const get_residence_time = (type) => {
}
};
const
eport_Interval
=
get_report_Interval
(
OPERATING_TIME
);
// 统计数据默认值
let
statData
=
{
uuid
:
get_uuid
(),
// 设备标识
...
...
@@ -1117,7 +1151,7 @@ class Report {
log
(
data
);
}
// 判断时候到达上报时间 ,默认 10 秒上报
if
(
page_residence_time
<
OPERATING_TIME
&&
!
type
)
return
if
(
page_residence_time
<
eport_Interval
&&
!
type
)
return
// 时间超过,重新获取时间戳
set_page_residence_time
();
...
...
@@ -1167,9 +1201,7 @@ class Report {
data
:
optionsData
,
success
:
()
=>
{
if
(
is_debug
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
optionsData
);
console
.
log
(
`=== 上报结束 ===`
);
log
(
optionsData
,
true
);
}
},
fail
:
(
e
)
=>
{
...
...
@@ -1197,9 +1229,7 @@ class Report {
let
options
=
get_sgin
(
get_encodeURIComponent_options
(
data
)).
options
;
image
.
src
=
STAT_H5_URL
+
'
?
'
+
options
;
if
(
is_debug
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
data
);
console
.
log
(
`=== 上报结束 ===`
);
log
(
data
,
true
);
}
});
}
...
...
packages/uni-stat/dist/uni-stat.es.js
浏览文件 @
70eeb8fb
...
...
@@ -12,6 +12,8 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
const
OPERATING_TIME
=
10
;
// 数据上报时间 单位s
const
DIFF_TIME
=
60
*
1000
*
60
*
24
;
// 获取 manifest.json 中统计配置
const
uniStatisticsConfig
=
process
.
env
.
UNI_STATISTICS_CONFIG
;
let
statConfig
=
{
appid
:
process
.
env
.
UNI_APP_ID
,
};
...
...
@@ -448,7 +450,8 @@ const is_debug = debug;
* 日志输出
* @param {*} data
*/
const
log
=
(
data
)
=>
{
const
log
=
(
data
,
type
)
=>
{
let
msg_type
=
''
;
switch
(
data
.
lt
)
{
case
'
1
'
:
...
...
@@ -471,11 +474,41 @@ const log = (data) => {
msg_type
=
'
PUSH
'
;
break
}
// #ifdef APP
// 在 app 中,日志转为 字符串
if
(
typeof
data
===
'
object
'
)
{
data
=
JSON
.
stringify
(
data
);
}
// #endif
if
(
type
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
data
);
console
.
log
(
`=== 上报结束 ===`
);
return
}
if
(
msg_type
)
{
console
.
log
(
`=== 统计数据采集:
${
msg_type
}
===`
);
console
.
log
(
data
);
console
.
log
(
`=== 采集结束 ===`
);
}
};
/**
* 获取上报时间间隔
* @param {*} defaultTime 默认上报间隔时间 单位s
*/
const
get_report_Interval
=
(
defaultTime
)
=>
{
let
time
=
uniStatisticsConfig
.
reportInterval
;
// 如果上报时间配置为0 相当于立即上报
if
(
Number
(
time
)
===
0
)
return
0
time
=
time
||
defaultTime
;
let
reg
=
/
(
^
[
1-9
]\d
*$
)
/
;
// 如果不是整数,则默认为上报间隔时间
if
(
!
reg
.
test
(
time
))
return
defaultTime
return
Number
(
time
)
};
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
...
...
@@ -649,6 +682,7 @@ const get_residence_time = (type) => {
}
};
const
eport_Interval
=
get_report_Interval
(
OPERATING_TIME
);
// 统计数据默认值
let
statData
=
{
uuid
:
get_uuid
(),
// 设备标识
...
...
@@ -1115,7 +1149,7 @@ class Report {
log
(
data
);
}
// 判断时候到达上报时间 ,默认 10 秒上报
if
(
page_residence_time
<
OPERATING_TIME
&&
!
type
)
return
if
(
page_residence_time
<
eport_Interval
&&
!
type
)
return
// 时间超过,重新获取时间戳
set_page_residence_time
();
...
...
@@ -1165,9 +1199,7 @@ class Report {
data
:
optionsData
,
success
:
()
=>
{
if
(
is_debug
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
optionsData
);
console
.
log
(
`=== 上报结束 ===`
);
log
(
optionsData
,
true
);
}
},
fail
:
(
e
)
=>
{
...
...
@@ -1195,9 +1227,7 @@ class Report {
let
options
=
get_sgin
(
get_encodeURIComponent_options
(
data
)).
options
;
image
.
src
=
STAT_H5_URL
+
'
?
'
+
options
;
if
(
is_debug
)
{
console
.
log
(
`=== 统计队列数据上报 ===`
);
console
.
log
(
data
);
console
.
log
(
`=== 上报结束 ===`
);
log
(
data
,
true
);
}
});
}
...
...
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
浏览文件 @
70eeb8fb
...
...
@@ -88,7 +88,9 @@ const plugins = [
RUN_BY_HBUILDERX
:
process
.
env
.
RUN_BY_HBUILDERX
,
UNI_AUTOMATOR_WS_ENDPOINT
:
JSON
.
stringify
(
process
.
env
.
UNI_AUTOMATOR_WS_ENDPOINT
),
UNI_STAT_UNI_CLOUD
:
process
.
env
.
UNI_STAT_UNI_CLOUD
||
'
""
'
,
UNI_STAT_DEBUG
:
process
.
env
.
UNI_STAT_DEBUG
||
'
""
'
UNI_STATISTICS_CONFIG
:
process
.
env
.
UNI_STATISTICS_CONFIG
||
'
""
'
,
UNI_STAT_DEBUG
:
process
.
env
.
UNI_STAT_DEBUG
||
'
""
'
,
UNI_COMPILER_VERSION
:
JSON
.
stringify
(
process
.
env
.
UNI_COMPILER_VERSION
)
}
}),
new
webpack
.
BannerPlugin
({
...
...
packages/vue-cli-plugin-uni/lib/chain-webpack.js
浏览文件 @
70eeb8fb
...
...
@@ -104,8 +104,9 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
'
process.env.UNICLOUD_DEBUG
'
:
process
.
env
.
UNICLOUD_DEBUG
,
'
process.env.RUN_BY_HBUILDERX
'
:
process
.
env
.
RUN_BY_HBUILDERX
,
'
process.env.UNI_AUTOMATOR_WS_ENDPOINT
'
:
JSON
.
stringify
(
process
.
env
.
UNI_AUTOMATOR_WS_ENDPOINT
),
'
process.env.UNI_STAT_UNI_CLOUD
'
:
process
.
env
.
UNI_STAT_UNI_CLOUD
||
'
""
'
,
'
process.env.UNI_STAT_DEBUG
'
:
process
.
env
.
UNI_STAT_DEBUG
||
'
""
'
,
'
process.env.UNI_STATISTICS_CONFIG
'
:
process
.
env
.
UNI_STATISTICS_CONFIG
,
'
process.env.UNI_STAT_UNI_CLOUD
'
:
process
.
env
.
UNI_STAT_UNI_CLOUD
,
'
process.env.UNI_STAT_DEBUG
'
:
process
.
env
.
UNI_STAT_DEBUG
,
'
process.env.UNI_COMPILER_VERSION
'
:
JSON
.
stringify
(
process
.
env
.
UNI_COMPILER_VERSION
),
'
process.env.UNI_APP_VERSION_NAME
'
:
JSON
.
stringify
(
process
.
env
.
UNI_APP_VERSION_NAME
),
'
process.env.UNI_APP_VERSION_CODE
'
:
JSON
.
stringify
(
process
.
env
.
UNI_APP_VERSION_CODE
)
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
70eeb8fb
...
...
@@ -324,8 +324,9 @@ if ((process.env.UNI_PLATFORM === 'mp-kuaishou' || process.env.UNI_PLATFORM ===
process
.
env
.
MERGE_VIRTUAL_HOST_ATTRIBUTES
=
(
!!
platformOptions
.
mergeVirtualHostAttributes
).
toString
()
process
.
env
.
UNI_STAT_UNI_CLOUD
=
''
process
.
env
.
UNI_STAT_DEBUG
=
''
process
.
env
.
UNI_STATISTICS_CONFIG
=
'
""
'
process
.
env
.
UNI_STAT_UNI_CLOUD
=
'
""
'
process
.
env
.
UNI_STAT_DEBUG
=
'
""
'
if
(
process
.
env
.
UNI_USING_COMPONENTS
||
process
.
env
.
UNI_PLATFORM
===
'
h5
'
...
...
@@ -336,9 +337,10 @@ if (
)
if
(
uniStatistics
.
enable
===
true
)
{
process
.
env
.
UNI_USING_STAT
=
uniStatistics
.
version
===
'
2
'
?
'
2
'
:
'
1
'
process
.
env
.
UNI_USING_STAT
=
Number
(
uniStatistics
.
version
)
===
2
?
'
2
'
:
'
1
'
// 获取服务空间配置信息
const
uniCloudConfig
=
uniStatistics
.
uniCloud
||
{}
process
.
env
.
UNI_STATISTICS_CONFIG
=
JSON
.
stringify
(
uniStatistics
)
process
.
env
.
UNI_STAT_UNI_CLOUD
=
JSON
.
stringify
(
uniCloudConfig
)
process
.
env
.
UNI_STAT_DEBUG
=
uniStatistics
.
debug
===
true
?
'
true
'
:
'
false
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录