Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
touchx
uni-app
提交
f44f3140
U
uni-app
项目概览
touchx
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f44f3140
编写于
10月 17, 2022
作者:
M
mehaotian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(stat): 新增 odid 属性,uuid 替换为新api获取的 deciceid
上级
79b231d5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
322 addition
and
176 deletion
+322
-176
packages/uni-stat/dist/uni-cloud-stat.cjs.js
packages/uni-stat/dist/uni-cloud-stat.cjs.js
+83
-39
packages/uni-stat/dist/uni-cloud-stat.es.js
packages/uni-stat/dist/uni-cloud-stat.es.js
+83
-39
packages/uni-stat/dist/uni-stat.cjs.js
packages/uni-stat/dist/uni-stat.cjs.js
+69
-41
packages/uni-stat/dist/uni-stat.es.js
packages/uni-stat/dist/uni-stat.es.js
+69
-41
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+18
-16
未找到文件。
packages/uni-stat/dist/uni-cloud-stat.cjs.js
浏览文件 @
f44f3140
...
...
@@ -14,6 +14,46 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
const
OPERATING_TIME
=
10
;
// 数据上报时间 单位s
const
DIFF_TIME
=
60
*
1000
*
60
*
24
;
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
const
dbSet
=
(
name
,
value
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
)
{
data
=
{};
}
data
[
name
]
=
value
;
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
};
const
dbGet
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
[
name
])
{
let
dbdata
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
!
dbdata
)
{
dbdata
=
{};
}
if
(
!
dbdata
[
name
])
{
return
undefined
}
data
[
name
]
=
dbdata
[
name
];
}
return
data
[
name
]
};
const
dbRemove
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
else
{
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
}
};
// 获取 manifest.json 中统计配置
const
uniStatisticsConfig
=
process
.
env
.
UNI_STATISTICS_CONFIG
;
let
statConfig
=
{
...
...
@@ -82,6 +122,24 @@ const get_uuid = (statData) => {
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取老版的 deviceid ,兼容以前的错误 deviceid
* @param {*} statData
* @returns
*/
const
get_odid
=
(
statData
)
=>
{
let
odid
=
''
;
if
(
get_platform_name
()
===
'
n
'
)
{
try
{
odid
=
plus
.
device
.
uuid
;
}
catch
(
e
)
{
odid
=
''
;
}
return
odid
}
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取配置信息 如 appid
*/
...
...
@@ -542,46 +600,17 @@ const is_push_clientid = () => {
return
typeof
ClientID
===
'
boolean
'
?
ClientID
:
false
}
return
false
};
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
const
dbSet
=
(
name
,
value
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
)
{
data
=
{};
}
data
[
name
]
=
value
;
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
};
const
dbGet
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
[
name
])
{
let
dbdata
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
!
dbdata
)
{
dbdata
=
{};
}
if
(
!
dbdata
[
name
])
{
return
undefined
}
data
[
name
]
=
dbdata
[
name
];
}
return
data
[
name
]
};
const
dbRemove
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
else
{
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
}
/**
* 是否已处理设备 DeviceId
* 如果值为 1 则表示已处理
*/
const
IS_HANDLE_DEVECE_ID
=
'
is_handle_device_id
'
;
const
is_handle_device
=
()
=>
{
let
isHandleDevice
=
dbGet
(
IS_HANDLE_DEVECE_ID
)
||
''
;
dbSet
(
IS_HANDLE_DEVECE_ID
,
'
1
'
);
return
isHandleDevice
===
'
1
'
};
// 首次访问时间
...
...
@@ -968,13 +997,28 @@ class Report {
this
.
_navigationBarTitle
.
config
=
get_page_name
(
options
.
path
);
let
is_opt
=
options
.
query
&&
JSON
.
stringify
(
options
.
query
)
!==
'
{}
'
;
let
query
=
is_opt
?
'
?
'
+
JSON
.
stringify
(
options
.
query
)
:
''
;
const
last_time
=
get_last_visit_time
();
// 非老用户
if
(
last_time
!==
0
||
!
last_time
){
const
odid
=
get_odid
();
// 2.0 处理规则
{
const
have_device
=
is_handle_device
();
// 如果没有上报过设备信息 ,则需要上报设备信息
if
(
!
have_device
)
{
this
.
statData
.
odid
=
odid
;
}
}
}
Object
.
assign
(
this
.
statData
,
{
lt
:
'
1
'
,
url
:
options
.
path
+
query
||
''
,
t
:
get_time
(),
sc
:
get_scene
(
options
.
scene
),
fvts
:
get_first_visit_time
(),
lvts
:
get_last_visit_time
()
,
lvts
:
last_time
,
tvc
:
get_total_visit_count
(),
// create session type 上报类型 ,1 应用进入 2.后台30min进入 3.页面30min进入
cst
:
options
.
cst
||
1
,
...
...
packages/uni-stat/dist/uni-cloud-stat.es.js
浏览文件 @
f44f3140
...
...
@@ -12,6 +12,46 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
const
OPERATING_TIME
=
10
;
// 数据上报时间 单位s
const
DIFF_TIME
=
60
*
1000
*
60
*
24
;
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
const
dbSet
=
(
name
,
value
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
)
{
data
=
{};
}
data
[
name
]
=
value
;
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
};
const
dbGet
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
[
name
])
{
let
dbdata
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
!
dbdata
)
{
dbdata
=
{};
}
if
(
!
dbdata
[
name
])
{
return
undefined
}
data
[
name
]
=
dbdata
[
name
];
}
return
data
[
name
]
};
const
dbRemove
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
else
{
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
}
};
// 获取 manifest.json 中统计配置
const
uniStatisticsConfig
=
process
.
env
.
UNI_STATISTICS_CONFIG
;
let
statConfig
=
{
...
...
@@ -80,6 +120,24 @@ const get_uuid = (statData) => {
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取老版的 deviceid ,兼容以前的错误 deviceid
* @param {*} statData
* @returns
*/
const
get_odid
=
(
statData
)
=>
{
let
odid
=
''
;
if
(
get_platform_name
()
===
'
n
'
)
{
try
{
odid
=
plus
.
device
.
uuid
;
}
catch
(
e
)
{
odid
=
''
;
}
return
odid
}
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取配置信息 如 appid
*/
...
...
@@ -540,46 +598,17 @@ const is_push_clientid = () => {
return
typeof
ClientID
===
'
boolean
'
?
ClientID
:
false
}
return
false
};
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
const
dbSet
=
(
name
,
value
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
)
{
data
=
{};
}
data
[
name
]
=
value
;
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
};
const
dbGet
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
[
name
])
{
let
dbdata
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
!
dbdata
)
{
dbdata
=
{};
}
if
(
!
dbdata
[
name
])
{
return
undefined
}
data
[
name
]
=
dbdata
[
name
];
}
return
data
[
name
]
};
const
dbRemove
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
else
{
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
}
/**
* 是否已处理设备 DeviceId
* 如果值为 1 则表示已处理
*/
const
IS_HANDLE_DEVECE_ID
=
'
is_handle_device_id
'
;
const
is_handle_device
=
()
=>
{
let
isHandleDevice
=
dbGet
(
IS_HANDLE_DEVECE_ID
)
||
''
;
dbSet
(
IS_HANDLE_DEVECE_ID
,
'
1
'
);
return
isHandleDevice
===
'
1
'
};
// 首次访问时间
...
...
@@ -966,13 +995,28 @@ class Report {
this
.
_navigationBarTitle
.
config
=
get_page_name
(
options
.
path
);
let
is_opt
=
options
.
query
&&
JSON
.
stringify
(
options
.
query
)
!==
'
{}
'
;
let
query
=
is_opt
?
'
?
'
+
JSON
.
stringify
(
options
.
query
)
:
''
;
const
last_time
=
get_last_visit_time
();
// 非老用户
if
(
last_time
!==
0
||
!
last_time
){
const
odid
=
get_odid
();
// 2.0 处理规则
{
const
have_device
=
is_handle_device
();
// 如果没有上报过设备信息 ,则需要上报设备信息
if
(
!
have_device
)
{
this
.
statData
.
odid
=
odid
;
}
}
}
Object
.
assign
(
this
.
statData
,
{
lt
:
'
1
'
,
url
:
options
.
path
+
query
||
''
,
t
:
get_time
(),
sc
:
get_scene
(
options
.
scene
),
fvts
:
get_first_visit_time
(),
lvts
:
get_last_visit_time
()
,
lvts
:
last_time
,
tvc
:
get_total_visit_count
(),
// create session type 上报类型 ,1 应用进入 2.后台30min进入 3.页面30min进入
cst
:
options
.
cst
||
1
,
...
...
packages/uni-stat/dist/uni-stat.cjs.js
浏览文件 @
f44f3140
...
...
@@ -14,6 +14,46 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
const
OPERATING_TIME
=
10
;
// 数据上报时间 单位s
const
DIFF_TIME
=
60
*
1000
*
60
*
24
;
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
const
dbSet
=
(
name
,
value
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
)
{
data
=
{};
}
data
[
name
]
=
value
;
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
};
const
dbGet
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
[
name
])
{
let
dbdata
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
!
dbdata
)
{
dbdata
=
{};
}
if
(
!
dbdata
[
name
])
{
return
undefined
}
data
[
name
]
=
dbdata
[
name
];
}
return
data
[
name
]
};
const
dbRemove
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
else
{
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
}
};
// 获取 manifest.json 中统计配置
const
uniStatisticsConfig
=
process
.
env
.
UNI_STATISTICS_CONFIG
;
let
statConfig
=
{
...
...
@@ -82,6 +122,24 @@ const get_uuid = (statData) => {
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取老版的 deviceid ,兼容以前的错误 deviceid
* @param {*} statData
* @returns
*/
const
get_odid
=
(
statData
)
=>
{
let
odid
=
''
;
if
(
get_platform_name
()
===
'
n
'
)
{
try
{
odid
=
plus
.
device
.
uuid
;
}
catch
(
e
)
{
odid
=
''
;
}
return
odid
}
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取配置信息 如 appid
*/
...
...
@@ -523,46 +581,6 @@ const is_push_clientid = () => {
return
false
};
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
const
dbSet
=
(
name
,
value
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
)
{
data
=
{};
}
data
[
name
]
=
value
;
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
};
const
dbGet
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
[
name
])
{
let
dbdata
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
!
dbdata
)
{
dbdata
=
{};
}
if
(
!
dbdata
[
name
])
{
return
undefined
}
data
[
name
]
=
dbdata
[
name
];
}
return
data
[
name
]
};
const
dbRemove
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
else
{
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
}
};
// 首次访问时间
const
FIRST_VISIT_TIME_KEY
=
'
__first__visit__time
'
;
// 最后访问时间
...
...
@@ -947,13 +965,23 @@ class Report {
this
.
_navigationBarTitle
.
config
=
get_page_name
(
options
.
path
);
let
is_opt
=
options
.
query
&&
JSON
.
stringify
(
options
.
query
)
!==
'
{}
'
;
let
query
=
is_opt
?
'
?
'
+
JSON
.
stringify
(
options
.
query
)
:
''
;
const
last_time
=
get_last_visit_time
();
// 非老用户
if
(
last_time
!==
0
||
!
last_time
){
const
odid
=
get_odid
();
// 1.0 处理规则
{
this
.
statData
.
odid
=
odid
;
}
}
Object
.
assign
(
this
.
statData
,
{
lt
:
'
1
'
,
url
:
options
.
path
+
query
||
''
,
t
:
get_time
(),
sc
:
get_scene
(
options
.
scene
),
fvts
:
get_first_visit_time
(),
lvts
:
get_last_visit_time
()
,
lvts
:
last_time
,
tvc
:
get_total_visit_count
(),
// create session type 上报类型 ,1 应用进入 2.后台30min进入 3.页面30min进入
cst
:
options
.
cst
||
1
,
...
...
packages/uni-stat/dist/uni-stat.es.js
浏览文件 @
f44f3140
...
...
@@ -12,6 +12,46 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
const
OPERATING_TIME
=
10
;
// 数据上报时间 单位s
const
DIFF_TIME
=
60
*
1000
*
60
*
24
;
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
const
dbSet
=
(
name
,
value
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
)
{
data
=
{};
}
data
[
name
]
=
value
;
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
};
const
dbGet
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
[
name
])
{
let
dbdata
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
!
dbdata
)
{
dbdata
=
{};
}
if
(
!
dbdata
[
name
])
{
return
undefined
}
data
[
name
]
=
dbdata
[
name
];
}
return
data
[
name
]
};
const
dbRemove
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
else
{
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
}
};
// 获取 manifest.json 中统计配置
const
uniStatisticsConfig
=
process
.
env
.
UNI_STATISTICS_CONFIG
;
let
statConfig
=
{
...
...
@@ -80,6 +120,24 @@ const get_uuid = (statData) => {
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取老版的 deviceid ,兼容以前的错误 deviceid
* @param {*} statData
* @returns
*/
const
get_odid
=
(
statData
)
=>
{
let
odid
=
''
;
if
(
get_platform_name
()
===
'
n
'
)
{
try
{
odid
=
plus
.
device
.
uuid
;
}
catch
(
e
)
{
odid
=
''
;
}
return
odid
}
return
sys
.
deviceId
||
getUuid
()
};
/**
* 获取配置信息 如 appid
*/
...
...
@@ -521,46 +579,6 @@ const is_push_clientid = () => {
return
false
};
const
appid
=
process
.
env
.
UNI_APP_ID
;
// 做应用隔离
const
dbSet
=
(
name
,
value
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
)
{
data
=
{};
}
data
[
name
]
=
value
;
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
};
const
dbGet
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
!
data
[
name
])
{
let
dbdata
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
!
dbdata
)
{
dbdata
=
{};
}
if
(
!
dbdata
[
name
])
{
return
undefined
}
data
[
name
]
=
dbdata
[
name
];
}
return
data
[
name
]
};
const
dbRemove
=
(
name
)
=>
{
let
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
)
||
{};
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
else
{
data
=
uni
.
getStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
);
if
(
data
[
name
])
{
delete
data
[
name
];
uni
.
setStorageSync
(
'
$$STAT__DBDATA:
'
+
appid
,
data
);
}
}
};
// 首次访问时间
const
FIRST_VISIT_TIME_KEY
=
'
__first__visit__time
'
;
// 最后访问时间
...
...
@@ -945,13 +963,23 @@ class Report {
this
.
_navigationBarTitle
.
config
=
get_page_name
(
options
.
path
);
let
is_opt
=
options
.
query
&&
JSON
.
stringify
(
options
.
query
)
!==
'
{}
'
;
let
query
=
is_opt
?
'
?
'
+
JSON
.
stringify
(
options
.
query
)
:
''
;
const
last_time
=
get_last_visit_time
();
// 非老用户
if
(
last_time
!==
0
||
!
last_time
){
const
odid
=
get_odid
();
// 1.0 处理规则
{
this
.
statData
.
odid
=
odid
;
}
}
Object
.
assign
(
this
.
statData
,
{
lt
:
'
1
'
,
url
:
options
.
path
+
query
||
''
,
t
:
get_time
(),
sc
:
get_scene
(
options
.
scene
),
fvts
:
get_first_visit_time
(),
lvts
:
get_last_visit_time
()
,
lvts
:
last_time
,
tvc
:
get_total_visit_count
(),
// create session type 上报类型 ,1 应用进入 2.后台30min进入 3.页面30min进入
cst
:
options
.
cst
||
1
,
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
f44f3140
...
...
@@ -341,7 +341,13 @@ if (
)
if
(
uniStatistics
.
enable
===
true
)
{
process
.
env
.
UNI_USING_STAT
=
Number
(
uniStatistics
.
version
)
===
2
?
'
2
'
:
'
1
'
const
uniStatLog
=
(
text
)
=>
{
console
.
log
()
console
.
warn
(
text
)
console
.
log
()
}
const
version
=
Number
(
uniStatistics
.
version
)
===
2
?
'
2
'
:
'
1
'
process
.
env
.
UNI_USING_STAT
=
version
// 获取服务空间配置信息
const
uniCloudConfig
=
uniStatistics
.
uniCloud
||
{}
process
.
env
.
UNI_STATISTICS_CONFIG
=
JSON
.
stringify
(
uniStatistics
)
...
...
@@ -350,35 +356,31 @@ if (
if
(
process
.
env
.
NODE_ENV
===
'
production
'
)
{
if
(
!
process
.
UNI_STAT_CONFIG
.
appid
)
{
console
.
log
()
console
.
warn
(
uniI18n
.
__
(
'
pluginUni.uniStatisticsNoAppid
'
,
{
uniStatLog
(
uniI18n
.
__
(
'
pluginUni.uniStatisticsNoAppid
'
,
{
0
:
'
https://ask.dcloud.net.cn/article/36303
'
}))
console
.
log
()
}
else
{
if
(
!
uniStatistics
.
version
)
{
console
.
log
()
console
.
warn
(
uniI18n
.
__
(
'
pluginUni.uniStatisticsNoVersion
'
,
{
uniStatLog
(
uniI18n
.
__
(
'
pluginUni.uniStatisticsNoVersion
'
,
{
0
:
'
https://uniapp.dcloud.io/uni-stat-v2.html
'
}))
console
.
log
()
}
else
{
console
.
log
()
console
.
warn
(
`已开启 uni统计
${
uniStatistics
.
version
}
.0 版本`
)
console
.
log
()
uniStatLog
(
`已开启 uni统计
${
uniStatistics
.
version
}
.0 版本`
)
if
(
version
===
'
2
'
)
{
uniStatLog
(
'
【重要】因 HBuilderX 3.4.9 版本起,uni统计2.0 调整了安卓端 deviceId 获取方式,导致 uni统计2.0 App-Android平台部分统计数据不准确。如使用了HBuilderX 3.4.9 - 3.6.4版本且开通了uni统计2.0的应用,需要使用HBuilderX3.6.7及以上版本重新发布应用并升级 uniAdmin 云函数解决,详见:https://ask.dcloud.net.cn/article/40097
'
)
}
}
}
}
else
{
if
(
!
uniStatistics
.
version
)
{
console
.
log
()
console
.
warn
(
uniI18n
.
__
(
'
pluginUni.uniStatisticsNoVersion
'
,
{
uniStatLog
(
uniI18n
.
__
(
'
pluginUni.uniStatisticsNoVersion
'
,
{
0
:
'
https://uniapp.dcloud.io/uni-stat-v2.html
'
}))
console
.
log
()
}
else
{
console
.
log
()
console
.
warn
(
`已开启 uni统计
${
uniStatistics
.
version
}
.0 版本`
)
console
.
log
()
uniStatLog
(
`已开启 uni统计
${
uniStatistics
.
version
}
.0 版本`
)
if
(
version
===
'
2
'
)
{
uniStatLog
(
'
【重要】因 HBuilderX 3.4.9 版本起,uni统计2.0 调整了安卓端 deviceId 获取方式,导致 uni统计2.0 App-Android平台部分统计数据不准确。如使用了HBuilderX 3.4.9 - 3.6.4版本且开通了uni统计2.0的应用,需要使用HBuilderX3.6.7及以上版本重新发布应用并升级 uniAdmin 云函数解决,详见:https://ask.dcloud.net.cn/article/40097
'
)
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录