jason-trace-log 1.0.4 → 1.0.7
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/README.md +212 -7
- package/dist/jason-trace-log.esm.js +161 -243
- package/dist/jason-trace-log.esm.js.map +1 -1
- package/dist/jason-trace-log.umd.js +161 -242
- package/dist/jason-trace-log.umd.js.map +1 -1
- package/dist/lib/baseTrace.js +135 -97
- package/dist/lib/baseTrace.js.map +1 -1
- package/dist/lib/core/fetch.js +4 -17
- package/dist/lib/core/fetch.js.map +1 -1
- package/dist/lib/core/send.js +11 -8
- package/dist/lib/core/send.js.map +1 -1
- package/dist/lib/core/util.js +27 -27
- package/dist/lib/core/util.js.map +1 -1
- package/dist/lib/core/webvitals.js +3 -3
- package/dist/lib/core/webvitals.js.map +1 -1
- package/dist/lib/index.js +4 -4
- package/dist/lib/index.js.map +1 -1
- package/dist/types/baseTrace.d.ts +39 -26
- package/dist/types/core/fetch.d.ts +1 -1
- package/dist/types/core/util.d.ts +8 -8
- package/dist/types/core/webvitals.d.ts +1 -1
- package/dist/types/index.d.ts +4 -4
- package/package.json +3 -3
package/dist/lib/core/util.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isResourceTarget = exports.getFetchStatusLevel = exports.getTimestamp = void 0;
|
|
4
|
-
exports.hashCode = hashCode;
|
|
5
|
-
exports.dataTypes2BreadcrumbsType = dataTypes2BreadcrumbsType;
|
|
6
|
-
exports.dataCategory2BreadcrumbsCategory = dataCategory2BreadcrumbsCategory;
|
|
7
|
-
exports.getTraceDataLevel = getTraceDataLevel;
|
|
8
|
-
exports.getTraceDataType = getTraceDataType;
|
|
9
|
-
exports.getPerfLevel = getPerfLevel;
|
|
10
|
-
exports.uuid = uuid;
|
|
11
|
-
exports.safeStringify = safeStringify;
|
|
3
|
+
exports.safeStringify = exports.uuid = exports.getPerfLevel = exports.getTraceDataType = exports.getTraceDataLevel = exports.dataCategory2BreadcrumbsCategory = exports.dataTypes2BreadcrumbsType = exports.hashCode = exports.isResourceTarget = exports.getFetchStatusLevel = exports.getTimestamp = void 0;
|
|
12
4
|
var common_1 = require("../typings/common");
|
|
13
5
|
// 获取时间
|
|
14
6
|
var getTimestamp = function () { return Date.now(); };
|
|
@@ -40,12 +32,12 @@ var isResourceTarget = function (target) {
|
|
|
40
32
|
};
|
|
41
33
|
exports.isResourceTarget = isResourceTarget;
|
|
42
34
|
/**
|
|
43
|
-
* 根据字符串生成hashcode
|
|
44
|
-
*
|
|
45
|
-
* @export
|
|
46
|
-
* @param {string} str
|
|
47
|
-
* @return {*} {number} 可为正数和负数
|
|
48
|
-
*/
|
|
35
|
+
* 根据字符串生成hashcode
|
|
36
|
+
*
|
|
37
|
+
* @export
|
|
38
|
+
* @param {string} str
|
|
39
|
+
* @return {*} {number} 可为正数和负数
|
|
40
|
+
*/
|
|
49
41
|
function hashCode(str) {
|
|
50
42
|
var hash = 0;
|
|
51
43
|
if (str.length == 0)
|
|
@@ -57,6 +49,7 @@ function hashCode(str) {
|
|
|
57
49
|
}
|
|
58
50
|
return hash;
|
|
59
51
|
}
|
|
52
|
+
exports.hashCode = hashCode;
|
|
60
53
|
function dataTypes2BreadcrumbsType(data) {
|
|
61
54
|
switch (data) {
|
|
62
55
|
case common_1.TraceDataTypes.JAVASCRIPT:
|
|
@@ -80,6 +73,7 @@ function dataTypes2BreadcrumbsType(data) {
|
|
|
80
73
|
return common_1.BreadcrumbTypes.CUSTOMER;
|
|
81
74
|
}
|
|
82
75
|
}
|
|
76
|
+
exports.dataTypes2BreadcrumbsType = dataTypes2BreadcrumbsType;
|
|
83
77
|
function dataCategory2BreadcrumbsCategory(data) {
|
|
84
78
|
switch (data) {
|
|
85
79
|
case common_1.TraceDataTypes.JAVASCRIPT:
|
|
@@ -102,6 +96,7 @@ function dataCategory2BreadcrumbsCategory(data) {
|
|
|
102
96
|
return common_1.BreadcrumbsCategorys.Lifecycle;
|
|
103
97
|
}
|
|
104
98
|
}
|
|
99
|
+
exports.dataCategory2BreadcrumbsCategory = dataCategory2BreadcrumbsCategory;
|
|
105
100
|
function getTraceDataLevel(level) {
|
|
106
101
|
switch (level) {
|
|
107
102
|
case common_1.TraceDataSeverity.High:
|
|
@@ -117,6 +112,7 @@ function getTraceDataLevel(level) {
|
|
|
117
112
|
return common_1.TraceLevelType.Info;
|
|
118
113
|
}
|
|
119
114
|
}
|
|
115
|
+
exports.getTraceDataLevel = getTraceDataLevel;
|
|
120
116
|
function getTraceDataType(type) {
|
|
121
117
|
switch (type) {
|
|
122
118
|
case common_1.TraceDataTypes.PROMISE:
|
|
@@ -138,30 +134,32 @@ function getTraceDataType(type) {
|
|
|
138
134
|
return common_1.TraceTypes.CUSTOMER;
|
|
139
135
|
}
|
|
140
136
|
}
|
|
137
|
+
exports.getTraceDataType = getTraceDataType;
|
|
141
138
|
function getPerfLevel(data) {
|
|
142
139
|
var level = common_1.TraceLevelType.Info;
|
|
143
|
-
if (data.LCPRating === 'poor'
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
if (data.LCPRating === 'poor' ||
|
|
141
|
+
data.FIDRating === 'poor' ||
|
|
142
|
+
data.FCPRating === 'poor' ||
|
|
143
|
+
data.TTFBRating === 'poor' ||
|
|
144
|
+
data.CLSRating === 'poor' ||
|
|
145
|
+
data.INPRating === 'poor') {
|
|
149
146
|
// console.log('[getPerfLevel] error')
|
|
150
147
|
level = common_1.TraceLevelType.Error;
|
|
151
148
|
return;
|
|
152
149
|
}
|
|
153
|
-
if (data.LCPRating === 'needs improvement'
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
150
|
+
if (data.LCPRating === 'needs improvement' ||
|
|
151
|
+
data.CLSRating === 'needs improvement' ||
|
|
152
|
+
data.FCPRating === 'needs improvement' ||
|
|
153
|
+
data.FIDRating === 'needs improvement' ||
|
|
154
|
+
data.INPRating === 'needs improvement' ||
|
|
155
|
+
data.TTFBRating === 'needs improvement') {
|
|
159
156
|
// console.log('[getPerfLevel] warn')
|
|
160
157
|
level = common_1.TraceLevelType.Warn;
|
|
161
158
|
return;
|
|
162
159
|
}
|
|
163
160
|
return level;
|
|
164
161
|
}
|
|
162
|
+
exports.getPerfLevel = getPerfLevel;
|
|
165
163
|
function uuid() {
|
|
166
164
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
167
165
|
/* tslint:disable */
|
|
@@ -171,6 +169,7 @@ function uuid() {
|
|
|
171
169
|
return v.toString(16);
|
|
172
170
|
});
|
|
173
171
|
}
|
|
172
|
+
exports.uuid = uuid;
|
|
174
173
|
function safeStringify(obj) {
|
|
175
174
|
var set = new Set();
|
|
176
175
|
var str = JSON.stringify(obj, function (_key, value) {
|
|
@@ -183,4 +182,5 @@ function safeStringify(obj) {
|
|
|
183
182
|
set.clear();
|
|
184
183
|
return str;
|
|
185
184
|
}
|
|
185
|
+
exports.safeStringify = safeStringify;
|
|
186
186
|
//# sourceMappingURL=util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/core/util.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/core/util.ts"],"names":[],"mappings":";;;AAAA,4CAO0B;AAE1B,OAAO;AACA,IAAM,YAAY,GAAG,cAAc,OAAA,IAAI,CAAC,GAAG,EAAE,EAAV,CAAU,CAAA;AAAvC,QAAA,YAAY,gBAA2B;AAE7C,IAAM,mBAAmB,GAAG,UAAC,MAAc;IAChD,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;QAClB,OAAO,0BAAiB,CAAC,QAAQ,CAAA;IACnC,CAAC;SAAM,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;QACzB,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,CAAC;AATD,oBASC;AAED,SAAgB,aAAa,CAAC,GAAW;IACvC,IAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAA;IACrB,IAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,UAAS,IAAI,EAAE,KAAK;QAClD,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,EAAE,CAAA;QACX,CAAC;QACD,OAAO,KAAK,KAAK,QAAQ,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC3C,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CAAA;IACF,GAAG,CAAC,KAAK,EAAE,CAAA;IACX,OAAO,GAAG,CAAA;AACZ,CAAC;AAXD,sCAWC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.onVitals = void 0;
|
|
4
|
-
exports.generateUniqueId = generateUniqueId;
|
|
5
|
-
exports.mapMetric = mapMetric;
|
|
3
|
+
exports.onVitals = exports.mapMetric = exports.generateUniqueId = void 0;
|
|
6
4
|
var web_vitals_1 = require("web-vitals");
|
|
7
5
|
var web_vitals_reporter_1 = require("web-vitals-reporter");
|
|
8
6
|
var SCORE_RANGE_LCP = [2500, 4500];
|
|
@@ -17,6 +15,7 @@ var score = function (value, range) {
|
|
|
17
15
|
function generateUniqueId() {
|
|
18
16
|
return "v1-".concat(Date.now(), "-").concat(Math.floor(Math.random() * (9e12 - 1)) + 1e12);
|
|
19
17
|
}
|
|
18
|
+
exports.generateUniqueId = generateUniqueId;
|
|
20
19
|
function round(val, precision) {
|
|
21
20
|
if (precision === void 0) { precision = 0; }
|
|
22
21
|
// @ts-ignore
|
|
@@ -30,6 +29,7 @@ function mapMetric(metric) {
|
|
|
30
29
|
_a["".concat(metric.name, "Rating")] = metric.rating,
|
|
31
30
|
_a;
|
|
32
31
|
}
|
|
32
|
+
exports.mapMetric = mapMetric;
|
|
33
33
|
;
|
|
34
34
|
var sendToAnalytics = (0, web_vitals_reporter_1.createApiReporter)('/analytics', {
|
|
35
35
|
initial: (0, web_vitals_reporter_1.getDeviceInfo)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webvitals.js","sourceRoot":"","sources":["../../../src/core/webvitals.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"webvitals.js","sourceRoot":"","sources":["../../../src/core/webvitals.ts"],"names":[],"mappings":";;;AAAA,yCAA8E;AAC9E,2DAAsE;AAEtE,IAAM,eAAe,GAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACtD,IAAM,eAAe,GAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AACpD,IAAM,eAAe,GAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AACrD,IAAM,eAAe,GAAqB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;AAClD,IAAM,eAAe,GAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AACpD,IAAM,gBAAgB,GAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AAEtD,IAAM,KAAK,GAAG,UAAC,KAAa,EAAE,KAAuB;IACnD,OAAO,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAA;AACpF,CAAC,CAAA;AAED,SAAgB,gBAAgB;IAC9B,OAAO,aAAM,IAAI,CAAC,GAAG,EAAE,cAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAE,CAAA;AAC5E,CAAC;AAFD,4CAEC;AAED,SAAS,KAAK,CAAC,GAAG,EAA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AE,KAAK,CAAC,GAAG,EAAE,eAAe,CAAC;YACrC,2EAA2E;YAC3E,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,eAAe,CAAC;SACtC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAGK,IAAM,QAAQ,GAAG,UAAC,UAAU;IACjC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;IAC9B,IAAA,kBAAK,EAAC,UAAU,CAAC,CAAA;IACjB,IAAA,kBAAK,EAAC,UAAU,CAAC,CAAA;IACjB,IAAA,kBAAK,EAAC,UAAU,CAAC,CAAA;IACjB,qBAAqB;IACrB,oBAAoB;IACpB,oBAAoB;AACtB,CAAC,CAAA;AARY,QAAA,QAAQ,YAQpB;AAED,kBAAe,EAAE,CAAA"}
|
package/dist/lib/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SendMethod = exports.init = void 0;
|
|
3
|
+
exports.BaseTrace = exports.SendMethod = exports.init = void 0;
|
|
4
|
+
var baseTrace_1 = require("./baseTrace");
|
|
5
|
+
Object.defineProperty(exports, "BaseTrace", { enumerable: true, get: function () { return baseTrace_1.BaseTrace; } });
|
|
4
6
|
var trace_1 = require("./trace");
|
|
5
7
|
var common_1 = require("./typings/common");
|
|
6
8
|
Object.defineProperty(exports, "SendMethod", { enumerable: true, get: function () { return common_1.SendMethod; } });
|
|
@@ -10,10 +12,8 @@ var init = function (options) {
|
|
|
10
12
|
return instance;
|
|
11
13
|
}
|
|
12
14
|
instance = trace_1.default.init(options);
|
|
13
|
-
console.log('
|
|
15
|
+
console.log('instances: ', instance);
|
|
14
16
|
return instance;
|
|
15
17
|
};
|
|
16
18
|
exports.init = init;
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
window.traceSdkInit = exports.init;
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqD;AAehC,0FAfE,qBAAS,OAeF;AAd9B,iCAA8B;AAC9B,2CAA6C;AAapC,2FAbA,mBAAU,OAaA;AAXnB,IAAI,QAAmB,CAAA;AAEhB,IAAM,IAAI,GAAG,UAAC,OAAqB;IACxC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,QAAQ,GAAG,eAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACjC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;IACpC,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAPY,QAAA,IAAI,QAOhB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BaseTraceInterface } from './core/interface';
|
|
2
2
|
import { OnFetchError } from './core/fetch';
|
|
3
|
-
import { BrowserType } from './typings/common';
|
|
4
3
|
import { SendMethod } from './typings/common';
|
|
5
4
|
export interface LTSConfig {
|
|
6
5
|
region: string;
|
|
@@ -9,7 +8,7 @@ export interface LTSConfig {
|
|
|
9
8
|
streamId: string;
|
|
10
9
|
debug?: boolean;
|
|
11
10
|
}
|
|
12
|
-
export interface TraceOptions {
|
|
11
|
+
export interface TraceOptions<T extends Record<string, any> = Record<string, any>> {
|
|
13
12
|
perfOnSend?: () => void;
|
|
14
13
|
perfBeforeSend?: () => void;
|
|
15
14
|
dsn?: string;
|
|
@@ -17,35 +16,44 @@ export interface TraceOptions {
|
|
|
17
16
|
appId: string;
|
|
18
17
|
sendMethod?: SendMethod;
|
|
19
18
|
ltsConfig?: LTSConfig;
|
|
19
|
+
customGlobalFields?: T;
|
|
20
20
|
}
|
|
21
21
|
export declare class BaseTrace implements BaseTraceInterface {
|
|
22
|
-
dsn
|
|
23
|
-
pageId
|
|
24
|
-
userAgent
|
|
25
|
-
browserType
|
|
26
|
-
fpId
|
|
27
|
-
uid
|
|
28
|
-
appId
|
|
29
|
-
debug
|
|
30
|
-
sendMethod
|
|
31
|
-
ltsConfig
|
|
32
|
-
perfData
|
|
33
|
-
resources
|
|
34
|
-
result
|
|
35
|
-
breadcrumb
|
|
36
|
-
maxBreadcrumb
|
|
37
|
-
breadcrumbEnabled
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
private dsn;
|
|
23
|
+
private pageId;
|
|
24
|
+
private userAgent;
|
|
25
|
+
private browserType;
|
|
26
|
+
private fpId;
|
|
27
|
+
private uid;
|
|
28
|
+
private appId;
|
|
29
|
+
private debug;
|
|
30
|
+
private sendMethod;
|
|
31
|
+
private ltsConfig?;
|
|
32
|
+
private perfData;
|
|
33
|
+
private resources;
|
|
34
|
+
private result;
|
|
35
|
+
private breadcrumb;
|
|
36
|
+
private maxBreadcrumb;
|
|
37
|
+
private breadcrumbEnabled;
|
|
38
|
+
private queue;
|
|
39
|
+
private sendTimer;
|
|
40
|
+
private customGlobalFields;
|
|
41
41
|
constructor(options: TraceOptions);
|
|
42
|
-
log
|
|
43
|
-
info(message: string, tag?: string): void;
|
|
44
|
-
warn(message: string, tag?: string): void;
|
|
45
|
-
error(message: string, tag?: string): void;
|
|
42
|
+
private log;
|
|
43
|
+
info(message: string, tag?: string, extra?: Record<string, any>): void;
|
|
44
|
+
warn(message: string, tag?: string, extra?: Record<string, any>): void;
|
|
45
|
+
error(message: string, tag?: string, extra?: Record<string, any>): void;
|
|
46
46
|
setTraceData(data: TraceTypeData | TracePerf): TraceData;
|
|
47
47
|
send(data: TraceTypeData | TracePerf): void;
|
|
48
|
+
private enqueueOrSend;
|
|
48
49
|
createPerfReport(): (metric: any) => void;
|
|
50
|
+
/**
|
|
51
|
+
* 保存 Promise 异常
|
|
52
|
+
*/
|
|
53
|
+
savePromiseError(reason: any): void;
|
|
54
|
+
/**
|
|
55
|
+
* 保存 JavaScript 运行时错误和资源加载错误
|
|
56
|
+
*/
|
|
49
57
|
saveError(event: ErrorEvent): void;
|
|
50
58
|
handleObserverResource(entry: PerformanceResourceTiming): void;
|
|
51
59
|
onFetchError(message: OnFetchError): void;
|
|
@@ -54,5 +62,10 @@ export declare class BaseTrace implements BaseTraceInterface {
|
|
|
54
62
|
onObserverResource(): void;
|
|
55
63
|
saveBreadcrumb(data: TraceAction): void;
|
|
56
64
|
setUserId(userId: string): void;
|
|
57
|
-
|
|
65
|
+
/**
|
|
66
|
+
* 设置自定义全局字段
|
|
67
|
+
* @param fields 自定义全局字段
|
|
68
|
+
*/
|
|
69
|
+
setCustomGlobalFields(fields: Record<string, any>): void;
|
|
70
|
+
static init<T extends Record<string, any> = Record<string, any>>(options: TraceOptions<T>): BaseTrace;
|
|
58
71
|
}
|
|
@@ -17,5 +17,5 @@ export type InterceptFetchType = {
|
|
|
17
17
|
onBefore?: (props: OnBeforeProps) => void;
|
|
18
18
|
onAfter?: (result: any) => void;
|
|
19
19
|
};
|
|
20
|
-
declare const interceptFetch: ({
|
|
20
|
+
declare const interceptFetch: ({ onError, onBefore, onAfter }: InterceptFetchType) => (...args: any) => Promise<any>;
|
|
21
21
|
export default interceptFetch;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { BreadcrumbTypes, TraceDataSeverity, TraceDataTypes, BreadcrumbsCategorys, TraceLevelType, TraceTypes } from
|
|
1
|
+
import { BreadcrumbTypes, TraceDataSeverity, TraceDataTypes, BreadcrumbsCategorys, TraceLevelType, TraceTypes } from '../typings/common';
|
|
2
2
|
export declare const getTimestamp: () => number;
|
|
3
3
|
export declare const getFetchStatusLevel: (status: number) => TraceDataSeverity;
|
|
4
|
-
export declare const isResourceTarget: (target: HTMLElement) =>
|
|
4
|
+
export declare const isResourceTarget: (target: HTMLElement) => boolean;
|
|
5
5
|
/**
|
|
6
|
-
* 根据字符串生成hashcode
|
|
7
|
-
*
|
|
8
|
-
* @export
|
|
9
|
-
* @param {string} str
|
|
10
|
-
* @return {*} {number} 可为正数和负数
|
|
11
|
-
*/
|
|
6
|
+
* 根据字符串生成hashcode
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @param {string} str
|
|
10
|
+
* @return {*} {number} 可为正数和负数
|
|
11
|
+
*/
|
|
12
12
|
export declare function hashCode(str: string): number;
|
|
13
13
|
export declare function dataTypes2BreadcrumbsType(data: TraceDataTypes): BreadcrumbTypes.ROUTE | BreadcrumbTypes.CONSOLE | BreadcrumbTypes.FETCH | BreadcrumbTypes.UNHANDLEDREJECTION | BreadcrumbTypes.RESOURCE | BreadcrumbTypes.CODE_ERROR | BreadcrumbTypes.CUSTOMER;
|
|
14
14
|
export declare function dataCategory2BreadcrumbsCategory(data: TraceDataTypes): BreadcrumbsCategorys.Http | BreadcrumbsCategorys.Debug | BreadcrumbsCategorys.Exception | BreadcrumbsCategorys.Lifecycle;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TraceOptions } from
|
|
2
|
-
import { SendMethod } from
|
|
3
|
-
export declare const init: (options: TraceOptions) =>
|
|
4
|
-
export { SendMethod };
|
|
1
|
+
import { TraceOptions, BaseTrace } from './baseTrace';
|
|
2
|
+
import { SendMethod } from './typings/common';
|
|
3
|
+
export declare const init: (options: TraceOptions) => BaseTrace;
|
|
4
|
+
export { SendMethod, BaseTrace };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jason-trace-log",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
|
-
"main": "dist/trace-log.umd.js",
|
|
7
|
-
"module": "dist/trace-log.esm.js",
|
|
6
|
+
"main": "dist/jason-trace-log.umd.js",
|
|
7
|
+
"module": "dist/jason-trace-log.esm.js",
|
|
8
8
|
"types": "dist/types/index.d.ts",
|
|
9
9
|
"typings": "dist/types/index.d.ts",
|
|
10
10
|
"files": [
|