miniprogram-logger
Version:
It is used to log and gather statistics of users' behavior.
69 lines • 1.74 kB
TypeScript
/**
* 序列化字符串
* @param data paramter
*/
export declare function stringify(data: any): string | number | undefined;
export interface Dictionary {
[key: string]: string | number | any;
}
export interface BasicLogObject extends Dictionary {
/**
* 记录ID
*/
id?: string;
/**
* 时间戳
*/
timestamp?: number;
}
/**
* 默认Log对象转换函数
* 自动添加蛇形命名
* 字段中注入`id`和`timestamp`
* @param data LogObject
*/
export declare function logTransformFunction<T extends Dictionary = Dictionary>(data: T): Dictionary;
/**
* 上报封装
*/
export declare class Reporter<TObject extends Dictionary, TValues extends TObject[keyof TObject][], TKeys extends (keyof TObject)[] = (keyof TObject)[]> {
/**
* 上报转换函数
*/
TransformFunction?: (data: TObject) => any;
/**
* 存储的表名
*/
readonly TableName: string;
/**
* 每次记录的上下文信息
*/
readonly Context: Partial<TObject>;
/**
* 字段参数映射关系
*/
protected readonly Fields: TKeys;
constructor(table: string, fields: TKeys, context?: Partial<TObject>);
/**
*
* @param args 上报的参数,各个参数分开,上报
*/
protected report(...args: TValues): void;
/**
* 上报 Object
* @param data
*/
protected report(data: TObject): void;
/**
* 设置上下文键值
* @param key - 键
* @param value - 值
*/
setContext<T extends keyof TObject = string>(key: T, value: TObject[T]): this;
/**
* 设置Context
* @param context
*/
setContext(context: Partial<TObject>): this;
}
//# sourceMappingURL=reporter.d.ts.map