send-sls-logger 0.0.38 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +2 -5
- package/lib/init.js +6 -1
- package/lib/mini.d.ts +3 -5
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -4,19 +4,16 @@ interface StringObject {
|
|
|
4
4
|
[name: string]: string | Function;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
interface Options extends WebTrackerBrowserOptions {
|
|
8
|
-
isMiniApp?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
7
|
/** 对最终发送的日志进行兜底处理,只能在init中使用 */
|
|
12
8
|
type FormatResult = (result: any) => any;
|
|
13
9
|
|
|
14
10
|
interface initConfig {
|
|
11
|
+
debug?: boolean;
|
|
15
12
|
/** 日志默认值,可以配置字符串或者function,如果是function,每次发送日志都会执行,通常用于获取当前页面的url等 */
|
|
16
13
|
defaultData?: StringObject;
|
|
17
14
|
/** 设置关键字列表,用于排除一些日志,如果日志中包含配置的这些关键字,则不发送日志 */
|
|
18
15
|
defaultExclude?: string[];
|
|
19
|
-
options?:
|
|
16
|
+
options?: WebTrackerBrowserOptions;
|
|
20
17
|
/** 最大字符长度,如果关键字里包含token,则不进行截断 */
|
|
21
18
|
strMaxLength?: number;
|
|
22
19
|
/** 对最终发送的日志进行兜底处理,只能在init中使用 */
|
package/lib/init.js
CHANGED
|
@@ -9,6 +9,7 @@ const defaultLogData = {};
|
|
|
9
9
|
const exclude = [];
|
|
10
10
|
let tracker;
|
|
11
11
|
let userFormatResult;
|
|
12
|
+
let debug;
|
|
12
13
|
|
|
13
14
|
const getType = (val) => {
|
|
14
15
|
return Object.prototype.toString.call(val).toLocaleLowerCase().slice(8, -1);
|
|
@@ -84,7 +85,7 @@ const send = (type) => {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
if (isExcludeMsg) {
|
|
87
|
-
console.log(`logger ${type}`, formatResultObj);
|
|
88
|
+
debug && console.log(`logger ${type}`, formatResultObj);
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
91
|
tracker.send(formatResultObj);
|
|
@@ -103,9 +104,13 @@ const logInit = (Tracker) => {
|
|
|
103
104
|
defaultExclude = [],
|
|
104
105
|
options = {},
|
|
105
106
|
strMaxLength = 200,
|
|
107
|
+
debug: defaultDebug,
|
|
106
108
|
userFormatResult: defaultUserFormatResult,
|
|
107
109
|
} = config;
|
|
108
110
|
|
|
111
|
+
if (defaultDebug !== undefined) {
|
|
112
|
+
debug = defaultDebug;
|
|
113
|
+
}
|
|
109
114
|
userFormatResult = defaultUserFormatResult;
|
|
110
115
|
Object.assign(defaultLogData, defaultData);
|
|
111
116
|
Object.assign(opts, options);
|
package/lib/mini.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WebTrackerMiniOptions } from "@aliyun-sls/web-track-mini";
|
|
2
2
|
interface StringObject {
|
|
3
3
|
[name: string]: string | Function;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
interface Options extends WebTrackerBrowserOptions {
|
|
7
|
-
isMiniApp?: boolean;
|
|
8
|
-
}
|
|
9
6
|
/** 对最终发送的日志进行兜底处理,只能在init中使用 */
|
|
10
7
|
type FormatResult = (result: any) => any;
|
|
11
8
|
|
|
12
9
|
interface initConfig {
|
|
10
|
+
debug?: boolean;
|
|
13
11
|
/** 日志默认值,可以配置字符串或者function,如果是function,每次发送日志都会执行,通常用于获取当前页面的url等 */
|
|
14
12
|
defaultData?: StringObject;
|
|
15
13
|
/** 设置关键字列表,用于排除一些日志,如果日志中包含配置的这些关键字,则不发送日志 */
|
|
16
14
|
defaultExclude?: string[];
|
|
17
|
-
options?:
|
|
15
|
+
options?: WebTrackerMiniOptions;
|
|
18
16
|
/** 最大字符长度,如果关键字里包含token,则不进行截断 */
|
|
19
17
|
strMaxLength?: number;
|
|
20
18
|
/** 对最终发送的日志进行兜底处理,只能在init中使用 */
|