UNPKG

@ezuikit/utils-collect

Version:

collect utils

94 lines (93 loc) 2.14 kB
export interface ReportParam { /** 协议 必填 */ protocol?: 'flv' | 'hls' | 'mp4' | 'ezopen' | 'openlive' | 'webrtc' | string; /** 播放地址 可选 */ url?: string; /** 时间(时间戳)可选 */ st?: number; /** 版本号 可选 */ v?: string; /** 设备序列号 可选 */ serial?: string; /** 设备通道号 可选 */ no?: string; /** 行为 可选 */ action?: number | string; /** 日志信息 */ logInfo?: object; /** 环境 (ezopen) */ env?: string; /** 播放类型 */ type?: 'rec' | 'live' | string; /** 扩展字段 不一定会入库 */ [key: string]: any; } export interface CollectOptions { /** 上报地址 */ url: string; /** 统一扩展信息 */ extendsInfo?: ReportParam; /** 是否禁用 */ forbidden?: boolean; } /** * 上报类 * @param options {CollectOptions} * @example * ```ts * const collect = new Collect({ * url: 'https://log.ys7.com/statistics.do/opensdk_ezuikit', * forbidden: true, * extendsInfo: { * v: '1.0.1', * protocol: 'ezopen', * env: 'httttttt env', * }, * }) * * collect.send({ * url: 'url', * serial: 'obj.serial', * no: 'obj.no', * action: '1000', * }); * * ``` */ declare class Collect { extendsInfo: ReportParam; clientInfo: string; options: CollectOptions; constructor(options: CollectOptions); /** * 修改上报地址 * @param url 上报地址 */ changeUrl(url: string): void; /** * 记录信息 * @param params {ReportParam} 上报参数 */ send(params: ReportParam): this; /** * 禁用上报 * @param forbidden {boolean} 是否禁用 */ setForbidden(forbidden: boolean): void; /** * 更新扩展信息 * @param params {object} 扩展信息 */ updateExtendsInfo(params?: ReportParam): void; private _handleRecordError; private _handleErrorInfo; /** * 获取扩展信息 */ private _getExtendsInfo; /** * 获取设备信息 */ private _getDeviceInfo; } export default Collect;