zh-report
v1.0.14
Published
前端上报
Readme
zh-report
配置文件
type Options = {
// 项目名称
serviceName: string;
// 平台
platform: "WEB" | "MINI";
// 请求路径
url: string;
// 鉴权token
authToken: string;
};
type HttpInfo = {
// 请求路径
url: string;
// 返回对象
response: {
// 返回data
data: Object;
};
// 请求对象
request: {
// 请求data
data: Object;
// 请求 param
param: Object;
};
// 请求 token
token: string;
};
type ReportOptions = {
/**
* 上报类型
* httpRequest http请求
* jsError js错误
* point 自定义埋点
*/
type: "httpRequest" | "jsError" | "point";
// traceId
traceId: string;
/**
* http请求信息
*/
httpInfo?: HttpInfo;
// 页面路径
pagePath: string;
// 上报内容
reportData: Object;
// 上报状态吗 0 默认 1 成功 2失败
statusCode: 0 | 1 | 2;
};
export abstract class ReportMannerAbstract {
constructor(options: Options);
report(reportOptions: ReportOptions): void;
}
declare class ReportManner extends ReportMannerAbstract {}
export default ReportManner;
示例
import ReportManner from "zh-report";
const serviceName = 'XXX'
const reportManner = new ReportManner({
serviceName,
url: "/xxxx",
platform: "xxx",
authToken: "xxxxxxxxxxxxxxxxxxxx",
});
reportManner.report({
type: "httpRequest",
traceId: 'xxxxx',
httpInfo: {
url:'xxx',
token:"xxx",
response: {
data: {a:'',b:"",c:''},
},
request: {
data: {},
param: {},
},
},
statusCode: 1,
reportData: {a:1,b:2,c3}
});
