提交 1c0af7fb 编写于 作者: M mehaotian

fix: 修复 root 类型警告问题

上级 54fb48e1
## 1.0.8(2025-02-20)
- 修复 root 类型警告的问题
## 1.0.7(2025-02-18) ## 1.0.7(2025-02-18)
- 新增 崩溃日志统计(暂不支持查看详细崩溃信息) - 新增 崩溃日志统计(暂不支持查看详细崩溃信息)
## 1.0.6(2025-01-02) ## 1.0.6(2025-01-02)
......
{ {
"id": "uni-stat", "id": "uni-stat",
"displayName": "uni统计 for uni-app x", "displayName": "uni统计 for uni-app x",
"version": "1.0.7", "version": "1.0.8",
"description": "uni统计的uni-app x 版本", "description": "uni统计的uni-app x 版本",
"keywords": [ "keywords": [
"uni-stat", "uni-stat",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { UniStatOptions, UniStatCollectItemsOptions } from '../interface.uts' import { UniStatOptions, UniStatCollectItemsOptions } from '../interface.uts'
// 访问开始即启动小程序,访问结束结分为:进入后台超过5min、在前台无任何操作超过30min、在新的来源打开小程序; // 访问开始即启动小程序,访问结束结分为:进入后台超过5min、在前台无任何操作超过30min、在新的来源打开小程序;
export const sys = uni.getSystemInfoSync() export const sys = uni.getSystemInfoSync()
export const device = uni.getDeviceInfo() export const device = uni.getDeviceInfo()
export const sysAppBase = uni.getAppBaseInfo(); export const sysAppBase = uni.getAppBaseInfo();
export const STAT_VERSION = sys.uniCompilerVersion export const STAT_VERSION = sys.uniCompilerVersion
......
...@@ -357,7 +357,7 @@ export class Report { ...@@ -357,7 +357,7 @@ export class Report {
"sv": statdata.sv, // 系统版本名称 "sv": statdata.sv, // 系统版本名称
"brand":statdata.brand, // 手机品牌 "brand":statdata.brand, // 手机品牌
"md": statdata.md, // 手机型号 "md": statdata.md, // 手机型号
"root": statdata.root ? 0 : 1, // 是否root "root": statdata.root, // 是否root
// "batlevel": "", // 设备电池电量 // "batlevel": "", // 设备电池电量
// "battemp": "", // 电池温度 // "battemp": "", // 电池温度
// "memuse": "", // 系统已使用内存 // "memuse": "", // 系统已使用内存
......
...@@ -82,11 +82,10 @@ export class Stat { ...@@ -82,11 +82,10 @@ export class Stat {
const uniStatConfig = Config.getOptions() const uniStatConfig = Config.getOptions()
// 设置上报周期时间 // 设置上报周期时间
this.report.eportInterval = uniStatConfig.reportInterval ?? 10 this.report.eportInterval = uniStatConfig.reportInterval ?? 10
// #ifdef APP // #ifdef APP
// 获取崩溃日志 // 获取崩溃日志
get_crash_logs((logs)=>{ get_crash_logs((logs)=>{
console.log('----- logs',logs);
this.registerEvent(StatType.Crash, null, logs) this.registerEvent(StatType.Crash, null, logs)
}) })
// #endif // #endif
......
...@@ -171,6 +171,7 @@ function getEventData(lt : string, elm : StatDefault) : any { ...@@ -171,6 +171,7 @@ function getEventData(lt : string, elm : StatDefault) : any {
break break
case '31': // 应用错误 case '31': // 应用错误
data = FilterParam(ErrorParamsKeys, elm) data = FilterParam(ErrorParamsKeys, elm)
break
case '41': // 崩溃 case '41': // 崩溃
data = FilterParam(CrashParamsKeys, elm) data = FilterParam(CrashParamsKeys, elm)
break break
......
import { OnLaunchOptionsWithCst, RouteParams, StatDefault, ReportErrorCode } from '../../interface.uts' import { OnLaunchOptionsWithCst, RouteParams, StatDefault, ReportErrorCode } from '../../interface.uts'
import { STAT_VERSION, sys, device,sysAppBase, Config } from '../config.uts' import { STAT_VERSION, sys, device, sysAppBase, Config } from '../config.uts'
// import Config from '../config.uts' // import Config from '../config.uts'
import { get_time } from './pageTime.uts' import { get_time } from './pageTime.uts'
import { dbGet, dbSet } from './db.uts' import { dbGet, dbSet } from './db.uts'
...@@ -318,6 +318,12 @@ export const is_handle_device = () : boolean => { ...@@ -318,6 +318,12 @@ export const is_handle_device = () : boolean => {
* 获取上报数据默认值 * 获取上报数据默认值
*/ */
export const get_default_data = () : StatDefault => { export const get_default_data = () : StatDefault => {
let isRoot : number
if (device.isRoot == true) {
isRoot = 1
} else {
isRoot = 0
}
let statData : StatDefault = { let statData : StatDefault = {
uuid: get_uuid(), uuid: get_uuid(),
...@@ -348,9 +354,9 @@ export const get_default_data = () : StatDefault => { ...@@ -348,9 +354,9 @@ export const get_default_data = () : StatDefault => {
lat: '', lat: '',
lng: '', lng: '',
net: '', net: '',
odid: '', odid: '',
pv: sysAppBase.appVersion, pv: sysAppBase.appVersion,
root: device.isRoot root: isRoot
} }
return statData return statData
} }
...@@ -442,48 +448,46 @@ export const is_push_clientid = () : boolean => { ...@@ -442,48 +448,46 @@ export const is_push_clientid = () : boolean => {
/** /**
* 获取崩溃日志文件地址 * 获取崩溃日志文件地址
*/ */
export const get_crash_logs = (fn:(value:string[])=>void) => { export const get_crash_logs = (fn : (value : string[]) => void) => {
const crash_data = uni.__getAppCrashInfo() const crash_data = uni.__getAppCrashInfo()
console.log('101 ------',crash_data); if (crash_data != null && crash_data.length > 0) {
if (crash_data != null && crash_data.length > 0) { const sysManager = uni.getFileSystemManager();
const sysManager = uni.getFileSystemManager(); const reportLogs : Promise<string>[] = []
const reportLogs : Promise<string>[] = [] for (let i = 0; i < crash_data.length; i++) {
for (let i = 0; i < crash_data.length; i++) { const item = crash_data[i];
const item = crash_data[i]; let file_text:string;
console.log('-----',item); // #ifdef APP-ANDROID
let file_text = ''; file_text = item.get('file') as string
// #ifdef APP-ANDROID // #endif
file_text = item.get('file') as string // #ifdef APP-IOS
// #endif file_text = item.file as string
// #ifdef APP-IOS // #endif
file_text = item.file as string
// #endif const logPromise = new Promise<string>((resolve, reject) => {
sysManager.readFile({
const logPromise = new Promise<string>((resolve, reject) => { filePath: file_text,
sysManager.readFile({ encoding: 'utf-8',
filePath: file_text, success: (res) => {
encoding: 'utf-8', const crash_text = res.data as string
success: (res) => { resolve(crash_text); // 成功上报后 resolve
const crash_text = res.data as string },
resolve(crash_text); // 成功上报后 resolve fail: (err : any) => {
}, reject(err); // 读取文件失败时 reject
fail: (err : any) => { }
reject(err); // 读取文件失败时 reject });
} });
});
}); reportLogs.push(logPromise);
}
reportLogs.push(logPromise);
} Promise.all(reportLogs)
.then((res) => {
Promise.all(reportLogs) fn(res)
.then((res) => { })
fn(res) .catch((err) => {
}) console.log('Errorlogs:', err);
.catch((err) => { });
console.log('Errorlogs:', err); }
});
}
} }
...@@ -530,4 +534,4 @@ export const calibration = (eventName : string, options : any | null) : ReportEr ...@@ -530,4 +534,4 @@ export const calibration = (eventName : string, options : any | null) : ReportEr
return 61008 return 61008
} }
return null return null
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册