Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wulaladx
uni-app
提交
ef6c3f24
U
uni-app
项目概览
wulaladx
/
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,发现更多精彩内容 >>
提交
ef6c3f24
编写于
10月 17, 2022
作者:
M
mehaotian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(stat): 新增 odid 属性,uuid 替换为新api获取的 deciceid
上级
83c55249
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
382 addition
and
162 deletion
+382
-162
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/uni-stat/lib/uni.plugin.js
packages/uni-stat/lib/uni.plugin.js
+11
-0
packages/uni-stat/src/core/report.js
packages/uni-stat/src/core/report.js
+22
-1
packages/uni-stat/src/plugin/index.ts
packages/uni-stat/src/plugin/index.ts
+12
-0
packages/uni-stat/src/utils/pageInfo.js
packages/uni-stat/src/utils/pageInfo.js
+33
-1
未找到文件。
packages/uni-stat/dist/uni-cloud-stat.cjs.js
浏览文件 @
ef6c3f24
...
...
@@ -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
*/
...
...
@@ -544,44 +602,15 @@ 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
);
}
}
/**
* 是否已处理设备 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
浏览文件 @
ef6c3f24
...
...
@@ -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
*/
...
...
@@ -542,44 +600,15 @@ 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
);
}
}
/**
* 是否已处理设备 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
浏览文件 @
ef6c3f24
...
...
@@ -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
浏览文件 @
ef6c3f24
...
...
@@ -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/uni-stat/lib/uni.plugin.js
浏览文件 @
ef6c3f24
...
...
@@ -23,6 +23,11 @@ const uniStatLog = once((text) => {
console
.
warn
(
text
);
console
.
log
();
});
const
uniStatDeviceLog
=
once
((
text
)
=>
{
console
.
log
();
console
.
warn
(
text
);
console
.
log
();
});
var
index
=
()
=>
[
uniCliShared
.
defineUniMainJsPlugin
((
opts
)
=>
{
let
statVersion
=
'
1
'
;
...
...
@@ -75,6 +80,9 @@ var index = () => [
}
else
{
uniStatLog
(
`已开启 uni统计
${
statVersion
}
.0 版本`
);
if
(
statVersion
===
'
2
'
)
{
uniStatDeviceLog
(
'
1【重要】因 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
'
);
}
}
}
}
...
...
@@ -84,6 +92,9 @@ var index = () => [
}
else
{
uniStatLog
(
uniCliShared
.
M
[
'
stat.warn.tip
'
].
replace
(
'
{version}
'
,
`
${
statVersion
}
.0`
));
if
(
statVersion
===
'
2
'
)
{
uniStatDeviceLog
(
'
【重要】因 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
'
);
}
}
}
}
...
...
packages/uni-stat/src/core/report.js
浏览文件 @
ef6c3f24
...
...
@@ -12,6 +12,7 @@ import {
import
{
stat_config
,
get_uuid
,
get_odid
,
get_platform_name
,
get_pack_name
,
get_scene
,
...
...
@@ -30,6 +31,7 @@ import {
is_debug
,
log
,
get_report_Interval
,
is_handle_device
}
from
'
../utils/pageInfo.js
'
import
{
sys
}
from
'
../utils/util.js
'
...
...
@@ -295,13 +297,32 @@ export default 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 处理规则
if
(
__STAT_VERSION__
===
'
1
'
)
{
this
.
statData
.
odid
=
odid
}
// 2.0 处理规则
if
(
__STAT_VERSION__
===
'
2
'
)
{
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/src/plugin/index.ts
浏览文件 @
ef6c3f24
...
...
@@ -17,6 +17,12 @@ const uniStatLog = once((text: string) => {
console
.
log
()
})
const
uniStatDeviceLog
=
once
((
text
:
string
)
=>
{
console
.
log
()
console
.
warn
(
text
)
console
.
log
()
})
export
default
()
=>
[
defineUniMainJsPlugin
((
opts
)
=>
{
let
statVersion
:
'
1
'
|
'
2
'
=
'
1
'
...
...
@@ -71,6 +77,9 @@ export default () => [
uniStatLog
(
M
[
'
stat.warn.version
'
])
}
else
{
uniStatLog
(
`已开启 uni统计
${
statVersion
}
.0 版本`
)
if
(
statVersion
===
'
2
'
)
{
uniStatDeviceLog
(
'
【重要】因 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
{
...
...
@@ -80,6 +89,9 @@ export default () => [
uniStatLog
(
M
[
'
stat.warn.tip
'
].
replace
(
'
{version}
'
,
`
${
statVersion
}
.0`
)
)
if
(
statVersion
===
'
2
'
)
{
uniStatDeviceLog
(
'
【重要】因 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
'
)
}
}
}
}
...
...
packages/uni-stat/src/utils/pageInfo.js
浏览文件 @
ef6c3f24
import
{
sys
}
from
'
./util.js
'
import
{
STAT_URL
,
STAT_VERSION
,
DIFF_TIME
}
from
'
../config.ts
'
import
{
dbGet
,
dbSet
,
}
from
'
./db.js
'
// 获取 manifest.json 中统计配置
const
uniStatisticsConfig
=
process
.
env
.
UNI_STATISTICS_CONFIG
let
statConfig
=
{
...
...
@@ -70,6 +73,24 @@ export const get_uuid = (statData) => {
return
sys
.
deviceId
||
getUuid
()
}
/**
* 获取老版的 deviceid ,兼容以前的错误 deviceid
* @param {*} statData
* @returns
*/
export
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
*/
...
...
@@ -550,3 +571,14 @@ export const is_push_clientid = () => {
}
return
false
}
/**
* 是否已处理设备 DeviceId
* 如果值为 1 则表示已处理
*/
const
IS_HANDLE_DEVECE_ID
=
'
is_handle_device_id
'
export
const
is_handle_device
=
()
=>
{
let
isHandleDevice
=
dbGet
(
IS_HANDLE_DEVECE_ID
)
||
''
dbSet
(
IS_HANDLE_DEVECE_ID
,
'
1
'
)
return
isHandleDevice
===
'
1
'
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录