@pluve/logger-sdk 0.0.11 → 0.0.13
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/dist/esm/capture/jsError.js +3 -24
- package/dist/esm/capture/promiseError.js +3 -24
- package/dist/esm/capture/wechatError.js +9 -31
- package/dist/esm/compress/compression.js +47 -51
- package/dist/esm/core/httpClient.js +53 -76
- package/dist/esm/core/loggerSDK.js +202 -233
- package/dist/esm/core/queueManager.js +59 -99
- package/dist/esm/core/retryManager.js +44 -70
- package/dist/esm/stack/stacktrace.js +8 -31
- package/dist/esm/transport/beaconTransport.js +20 -61
- package/dist/esm/transport/pixelImageTransport.js +55 -79
- package/dist/esm/transport/transportAdapter.js +11 -13
- package/dist/esm/transport/wechatTransport.js +53 -94
- package/dist/esm/utils/tools.js +12 -35
- package/dist/types/compress/compression.d.ts +2 -0
- package/dist/types/transport/transportAdapter.d.ts +3 -5
- package/package.json +1 -2
- package/dist/cjs/capture/jsError.js +0 -48
- package/dist/cjs/capture/promiseError.js +0 -49
- package/dist/cjs/capture/resourceError.js +0 -48
- package/dist/cjs/capture/wechatError.js +0 -95
- package/dist/cjs/compress/compression.js +0 -84
- package/dist/cjs/config/index.js +0 -55
- package/dist/cjs/core/fingerprint.js +0 -36
- package/dist/cjs/core/httpClient.js +0 -96
- package/dist/cjs/core/loggerSDK.js +0 -641
- package/dist/cjs/core/queueManager.js +0 -249
- package/dist/cjs/core/retryManager.js +0 -127
- package/dist/cjs/index.js +0 -34
- package/dist/cjs/stack/stacktrace.js +0 -48
- package/dist/cjs/transport/beaconTransport.js +0 -64
- package/dist/cjs/transport/pixelImageTransport.js +0 -100
- package/dist/cjs/transport/transport.js +0 -17
- package/dist/cjs/transport/transportAdapter.js +0 -56
- package/dist/cjs/transport/wechatTransport.js +0 -103
- package/dist/cjs/types/api.js +0 -17
- package/dist/cjs/types/env.js +0 -17
- package/dist/cjs/types/external.d.ts +0 -21
- package/dist/cjs/types/logEvent.js +0 -17
- package/dist/cjs/types/logEventLevel.js +0 -17
- package/dist/cjs/types/sdkOptions.js +0 -17
- package/dist/cjs/types/trackOptions.js +0 -17
- package/dist/cjs/utils/environment.js +0 -183
- package/dist/cjs/utils/session.js +0 -31
- package/dist/cjs/utils/tools.js +0 -82
- package/dist/cjs/utils/uuid.js +0 -35
- package/dist/umd/logger-sdk.min.js +0 -1
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
1
|
// src/transport/wechatTransport.ts
|
|
42
2
|
import { gzipCompress } from "../compress/compression";
|
|
43
3
|
import { getReportApi } from "../config";
|
|
@@ -53,64 +13,63 @@ var WechatTransport = class {
|
|
|
53
13
|
isSupported() {
|
|
54
14
|
return isWeChatMiniProgram();
|
|
55
15
|
}
|
|
56
|
-
send(payload) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
16
|
+
async send(payload) {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
let body = typeof payload === "string" ? payload : safeStringify(payload);
|
|
19
|
+
const endpoint = getReportApi(((_a = this.opts) == null ? void 0 : _a.env) || "develop");
|
|
20
|
+
const timeout = 1e4;
|
|
21
|
+
let contentType = "application/json";
|
|
22
|
+
if (((_b = this.opts) == null ? void 0 : _b.enableGzip) && (!((_c = this.opts) == null ? void 0 : _c.gzipOnlyInBatchMode) || payload.items.length > 0)) {
|
|
23
|
+
const t = now();
|
|
24
|
+
logDebug(!!((_d = this.opts) == null ? void 0 : _d.debug), "WeChat request enable gzip compress: ", t);
|
|
25
|
+
const compressedItems = await gzipCompress(safeStringify(payload.items));
|
|
26
|
+
body = safeStringify({
|
|
27
|
+
...payload,
|
|
28
|
+
items: compressedItems
|
|
29
|
+
});
|
|
30
|
+
logDebug(!!((_e = this.opts) == null ? void 0 : _e.debug), "WeChat request gzip compress cost: ", now() - t);
|
|
31
|
+
contentType = "application/json; charset=utf-8";
|
|
32
|
+
}
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var _a2;
|
|
35
|
+
let timeoutId = null;
|
|
36
|
+
let settled = false;
|
|
37
|
+
timeoutId = setTimeout(() => {
|
|
38
|
+
if (!settled) {
|
|
39
|
+
settled = true;
|
|
40
|
+
reject(new Error(`WeChat request timeout after ${timeout}ms`));
|
|
41
|
+
}
|
|
42
|
+
}, timeout);
|
|
43
|
+
wx.request({
|
|
44
|
+
url: endpoint,
|
|
45
|
+
method: "POST",
|
|
46
|
+
data: body,
|
|
47
|
+
header: {
|
|
48
|
+
"Content-Type": contentType,
|
|
49
|
+
token: ((_a2 = this.opts) == null ? void 0 : _a2.token) || ""
|
|
50
|
+
},
|
|
51
|
+
success(res) {
|
|
52
|
+
if (timeoutId)
|
|
53
|
+
clearTimeout(timeoutId);
|
|
78
54
|
if (!settled) {
|
|
79
55
|
settled = true;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
url: endpoint,
|
|
85
|
-
method: "POST",
|
|
86
|
-
data: body,
|
|
87
|
-
header: {
|
|
88
|
-
"Content-Type": contentType,
|
|
89
|
-
token: ((_a2 = this.opts) == null ? void 0 : _a2.token) || ""
|
|
90
|
-
},
|
|
91
|
-
success(res) {
|
|
92
|
-
if (timeoutId)
|
|
93
|
-
clearTimeout(timeoutId);
|
|
94
|
-
if (!settled) {
|
|
95
|
-
settled = true;
|
|
96
|
-
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
97
|
-
resolve();
|
|
98
|
-
} else {
|
|
99
|
-
reject(new Error(`HTTP ${res.statusCode}`));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
fail(err) {
|
|
104
|
-
var _a3;
|
|
105
|
-
if (timeoutId)
|
|
106
|
-
clearTimeout(timeoutId);
|
|
107
|
-
if (!settled) {
|
|
108
|
-
settled = true;
|
|
109
|
-
logDebug(!!((_a3 = this.opts) == null ? void 0 : _a3.debug), "WeChat request failed", err);
|
|
110
|
-
reject(new Error(`WeChat request failed: ${err.errMsg || "unknown error"}`));
|
|
56
|
+
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
57
|
+
resolve();
|
|
58
|
+
} else {
|
|
59
|
+
reject(new Error(`HTTP ${res.statusCode}`));
|
|
111
60
|
}
|
|
112
61
|
}
|
|
113
|
-
}
|
|
62
|
+
},
|
|
63
|
+
fail(err) {
|
|
64
|
+
var _a3;
|
|
65
|
+
if (timeoutId)
|
|
66
|
+
clearTimeout(timeoutId);
|
|
67
|
+
if (!settled) {
|
|
68
|
+
settled = true;
|
|
69
|
+
logDebug(!!((_a3 = this.opts) == null ? void 0 : _a3.debug), "WeChat request failed", err);
|
|
70
|
+
reject(new Error(`WeChat request failed: ${err.errMsg || "unknown error"}`));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
114
73
|
});
|
|
115
74
|
});
|
|
116
75
|
}
|
package/dist/esm/utils/tools.js
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
1
|
// src/utils/tools.ts
|
|
23
2
|
import { parseStack } from "../stack/stacktrace";
|
|
24
3
|
var now = () => Date.now();
|
|
@@ -48,23 +27,21 @@ function hashToProb(s) {
|
|
|
48
27
|
}
|
|
49
28
|
return h % 1e4 / 1e4;
|
|
50
29
|
}
|
|
51
|
-
function flattenStack(error) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
location: "",
|
|
56
|
-
throwable: ""
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
const stackFrames = yield parseStack(error);
|
|
60
|
-
return stackFrames && stackFrames.length > 0 ? {
|
|
61
|
-
location: [stackFrames[0]].map((frame) => `${frame.file}:${frame.line}:${frame.column}`).join("\n "),
|
|
62
|
-
throwable: stackFrames.map((frame) => `${frame.file}:${frame.line}:${frame.column}`).join("\n ")
|
|
63
|
-
} : {
|
|
30
|
+
async function flattenStack(error) {
|
|
31
|
+
if (!error) {
|
|
32
|
+
return {
|
|
64
33
|
location: "",
|
|
65
34
|
throwable: ""
|
|
66
35
|
};
|
|
67
|
-
}
|
|
36
|
+
}
|
|
37
|
+
const stackFrames = await parseStack(error);
|
|
38
|
+
return stackFrames && stackFrames.length > 0 ? {
|
|
39
|
+
location: [stackFrames[0]].map((frame) => `${frame.file}:${frame.line}:${frame.column}`).join("\n "),
|
|
40
|
+
throwable: stackFrames.map((frame) => `${frame.file}:${frame.line}:${frame.column}`).join("\n ")
|
|
41
|
+
} : {
|
|
42
|
+
location: "",
|
|
43
|
+
throwable: ""
|
|
44
|
+
};
|
|
68
45
|
}
|
|
69
46
|
export {
|
|
70
47
|
flattenStack,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Transporter, TransportOptions } from './transport';
|
|
1
|
+
import type { Transporter, TransportOptions } from './transport';
|
|
2
2
|
export declare class TransportAdapter {
|
|
3
3
|
private static instance;
|
|
4
|
-
private
|
|
5
|
-
private pixelImageTransport;
|
|
6
|
-
private wechatTransport;
|
|
4
|
+
private opts;
|
|
7
5
|
private constructor();
|
|
8
6
|
static getInstance(opts: TransportOptions): TransportAdapter;
|
|
9
|
-
getTransporter(): Transporter
|
|
7
|
+
getTransporter(): Promise<Transporter>;
|
|
10
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluve/logger-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "logger sdk",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logger"
|
|
@@ -67,7 +67,6 @@
|
|
|
67
67
|
"stacktrace-js": "^2.0.2"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"js-base64": "^3.7.5",
|
|
71
70
|
"localforage": "^1.10.0"
|
|
72
71
|
}
|
|
73
72
|
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/capture/jsError.ts
|
|
20
|
-
var jsError_exports = {};
|
|
21
|
-
__export(jsError_exports, {
|
|
22
|
-
registerJsErrorCapture: () => registerJsErrorCapture
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(jsError_exports);
|
|
25
|
-
var import_stacktrace = require("../stack/stacktrace");
|
|
26
|
-
var import_tools = require("../utils/tools");
|
|
27
|
-
function registerJsErrorCapture(debug, callback) {
|
|
28
|
-
if (typeof window === "undefined")
|
|
29
|
-
return void 0;
|
|
30
|
-
const handler = async (e) => {
|
|
31
|
-
(0, import_tools.logDebug)(debug, "registerJsErrorCapture error", e);
|
|
32
|
-
if (!e.error)
|
|
33
|
-
return;
|
|
34
|
-
const stack = await (0, import_stacktrace.parseStack)(e.error);
|
|
35
|
-
callback({
|
|
36
|
-
type: "js",
|
|
37
|
-
message: e.error.message,
|
|
38
|
-
stack,
|
|
39
|
-
throwable: e.error.stack || ""
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
window.addEventListener("error", handler);
|
|
43
|
-
return () => window.removeEventListener("error", handler);
|
|
44
|
-
}
|
|
45
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
-
0 && (module.exports = {
|
|
47
|
-
registerJsErrorCapture
|
|
48
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/capture/promiseError.ts
|
|
20
|
-
var promiseError_exports = {};
|
|
21
|
-
__export(promiseError_exports, {
|
|
22
|
-
registerPromiseErrorCapture: () => registerPromiseErrorCapture
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(promiseError_exports);
|
|
25
|
-
var import_stacktrace = require("../stack/stacktrace");
|
|
26
|
-
var import_tools = require("../utils/tools");
|
|
27
|
-
function registerPromiseErrorCapture(debug, callback) {
|
|
28
|
-
if (typeof window === "undefined")
|
|
29
|
-
return void 0;
|
|
30
|
-
const handler = async (e) => {
|
|
31
|
-
(0, import_tools.logDebug)(debug, "registerPromiseErrorCapture unhandledrejection", e);
|
|
32
|
-
const { reason } = e;
|
|
33
|
-
if (reason instanceof Error) {
|
|
34
|
-
const stack = await (0, import_stacktrace.parseStack)(reason);
|
|
35
|
-
callback({
|
|
36
|
-
type: "promise",
|
|
37
|
-
message: reason.message,
|
|
38
|
-
stack,
|
|
39
|
-
throwable: reason.stack || ""
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
window.addEventListener("unhandledrejection", handler);
|
|
44
|
-
return () => window.removeEventListener("unhandledrejection", handler);
|
|
45
|
-
}
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
registerPromiseErrorCapture
|
|
49
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/capture/resourceError.ts
|
|
20
|
-
var resourceError_exports = {};
|
|
21
|
-
__export(resourceError_exports, {
|
|
22
|
-
registerResourceErrorCapture: () => registerResourceErrorCapture
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(resourceError_exports);
|
|
25
|
-
var import_tools = require("../utils/tools");
|
|
26
|
-
function registerResourceErrorCapture(debug, callback) {
|
|
27
|
-
if (typeof window === "undefined")
|
|
28
|
-
return void 0;
|
|
29
|
-
const handler = (e) => {
|
|
30
|
-
var _a;
|
|
31
|
-
(0, import_tools.logDebug)(debug, "registerResourceErrorCapture error", e);
|
|
32
|
-
const target = e.target;
|
|
33
|
-
if ((target == null ? void 0 : target.src) || (target == null ? void 0 : target.href)) {
|
|
34
|
-
callback({
|
|
35
|
-
type: "resource",
|
|
36
|
-
message: `Resource load failed: ${(target == null ? void 0 : target.src) || (target == null ? void 0 : target.href)}`,
|
|
37
|
-
stack: [],
|
|
38
|
-
throwable: ((_a = e == null ? void 0 : e.error) == null ? void 0 : _a.stack) || ""
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
window.addEventListener("error", handler, true);
|
|
43
|
-
return () => window.removeEventListener("error", handler, true);
|
|
44
|
-
}
|
|
45
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
-
0 && (module.exports = {
|
|
47
|
-
registerResourceErrorCapture
|
|
48
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/capture/wechatError.ts
|
|
20
|
-
var wechatError_exports = {};
|
|
21
|
-
__export(wechatError_exports, {
|
|
22
|
-
registerWechatErrorCapture: () => registerWechatErrorCapture,
|
|
23
|
-
registerWechatUnhandledCapture: () => registerWechatUnhandledCapture
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(wechatError_exports);
|
|
26
|
-
var import_stacktrace = require("../stack/stacktrace");
|
|
27
|
-
var import_environment = require("../utils/environment");
|
|
28
|
-
var import_tools = require("../utils/tools");
|
|
29
|
-
function registerWechatErrorCapture(debug, callback) {
|
|
30
|
-
if (!(0, import_environment.isWeChatMiniProgram)())
|
|
31
|
-
return void 0;
|
|
32
|
-
try {
|
|
33
|
-
const wxAny = globalThis.wx;
|
|
34
|
-
if (wxAny && typeof wxAny.onError === "function") {
|
|
35
|
-
const handler = async (error) => {
|
|
36
|
-
(0, import_tools.logDebug)(debug, "registerWechatErrorCapture onError", error);
|
|
37
|
-
const msg = String((error == null ? void 0 : error.message) ?? error);
|
|
38
|
-
const err = error instanceof Error ? error : new Error(msg);
|
|
39
|
-
const stack = await (0, import_stacktrace.parseStack)(err);
|
|
40
|
-
callback({
|
|
41
|
-
type: "js",
|
|
42
|
-
message: err.message,
|
|
43
|
-
stack,
|
|
44
|
-
throwable: err.stack || ""
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
wxAny.onError(handler);
|
|
48
|
-
return () => {
|
|
49
|
-
try {
|
|
50
|
-
wxAny.offError && wxAny.offError(handler);
|
|
51
|
-
} catch {
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
} catch (e) {
|
|
56
|
-
(0, import_tools.logDebug)(debug, "registerWechatErrorCapture attach failed", e);
|
|
57
|
-
}
|
|
58
|
-
return void 0;
|
|
59
|
-
}
|
|
60
|
-
function registerWechatUnhandledCapture(debug, callback) {
|
|
61
|
-
if (!(0, import_environment.isWeChatMiniProgram)())
|
|
62
|
-
return void 0;
|
|
63
|
-
try {
|
|
64
|
-
const wxAny = globalThis.wx;
|
|
65
|
-
if (wxAny && typeof wxAny.onUnhandledRejection === "function") {
|
|
66
|
-
const handler = async (res) => {
|
|
67
|
-
const reason = res == null ? void 0 : res.reason;
|
|
68
|
-
(0, import_tools.logDebug)(debug, "registerWechatUnhandledCapture onUnhandledRejection", reason);
|
|
69
|
-
const err = reason instanceof Error ? reason : new Error(String(reason));
|
|
70
|
-
const stack = await (0, import_stacktrace.parseStack)(err);
|
|
71
|
-
callback({
|
|
72
|
-
type: "promise",
|
|
73
|
-
message: err.message,
|
|
74
|
-
stack,
|
|
75
|
-
throwable: err.stack || ""
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
wxAny.onUnhandledRejection(handler);
|
|
79
|
-
return () => {
|
|
80
|
-
try {
|
|
81
|
-
wxAny.offUnhandledRejection && wxAny.offUnhandledRejection(handler);
|
|
82
|
-
} catch {
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
} catch (e) {
|
|
87
|
-
(0, import_tools.logDebug)(debug, "registerWechatUnhandledCapture attach failed", e);
|
|
88
|
-
}
|
|
89
|
-
return void 0;
|
|
90
|
-
}
|
|
91
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
-
0 && (module.exports = {
|
|
93
|
-
registerWechatErrorCapture,
|
|
94
|
-
registerWechatUnhandledCapture
|
|
95
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/compress/compression.ts
|
|
20
|
-
var compression_exports = {};
|
|
21
|
-
__export(compression_exports, {
|
|
22
|
-
gzipCompress: () => gzipCompress,
|
|
23
|
-
isGzipSupported: () => isGzipSupported
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(compression_exports);
|
|
26
|
-
var import_fflate = require("fflate");
|
|
27
|
-
var import_js_base64 = require("js-base64");
|
|
28
|
-
var import_environment = require("../utils/environment");
|
|
29
|
-
function toUtf8Bytes(s) {
|
|
30
|
-
if (typeof TextEncoder !== "undefined") {
|
|
31
|
-
return new TextEncoder().encode(s);
|
|
32
|
-
}
|
|
33
|
-
const enc = encodeURIComponent(s);
|
|
34
|
-
const out = [];
|
|
35
|
-
for (let i = 0; i < enc.length; i += 1) {
|
|
36
|
-
const c = enc[i];
|
|
37
|
-
if (c === "%") {
|
|
38
|
-
out.push(parseInt(enc.slice(i + 1, i + 3), 16));
|
|
39
|
-
i += 2;
|
|
40
|
-
} else {
|
|
41
|
-
out.push(c.charCodeAt(0));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return new Uint8Array(out);
|
|
45
|
-
}
|
|
46
|
-
async function gzipCompress(data) {
|
|
47
|
-
if ((0, import_environment.isBrowser)() && typeof CompressionStream !== "undefined") {
|
|
48
|
-
try {
|
|
49
|
-
const encoder = new TextEncoder();
|
|
50
|
-
const input = encoder.encode(data);
|
|
51
|
-
const gzip = new CompressionStream("gzip");
|
|
52
|
-
const readable = new Blob([input]).stream();
|
|
53
|
-
const compressedStream = readable.pipeThrough(gzip);
|
|
54
|
-
const compressedBuffer = await new Response(compressedStream).arrayBuffer();
|
|
55
|
-
const bytes = new Uint8Array(compressedBuffer);
|
|
56
|
-
let binary = "";
|
|
57
|
-
for (let i = 0; i < bytes.byteLength; i += 1) {
|
|
58
|
-
binary += String.fromCharCode(bytes[i]);
|
|
59
|
-
}
|
|
60
|
-
if (typeof btoa !== "undefined") {
|
|
61
|
-
return btoa(binary);
|
|
62
|
-
}
|
|
63
|
-
return Buffer.from(binary, "base64").toString("base64");
|
|
64
|
-
} catch (e) {
|
|
65
|
-
console.log("gzipCompress 压缩失败,尝试使用 fflate 库", e);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
const input = toUtf8Bytes(data);
|
|
70
|
-
const compressed = (0, import_fflate.gzipSync)(input);
|
|
71
|
-
return import_js_base64.Base64.fromUint8Array(compressed, false);
|
|
72
|
-
} catch (e) {
|
|
73
|
-
console.log("gzipCompress 压缩失败", e);
|
|
74
|
-
}
|
|
75
|
-
return import_js_base64.Base64.encode(data, false);
|
|
76
|
-
}
|
|
77
|
-
function isGzipSupported() {
|
|
78
|
-
return (0, import_environment.isBrowser)() && typeof CompressionStream !== "undefined";
|
|
79
|
-
}
|
|
80
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
-
0 && (module.exports = {
|
|
82
|
-
gzipCompress,
|
|
83
|
-
isGzipSupported
|
|
84
|
-
});
|
package/dist/cjs/config/index.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/config/index.ts
|
|
20
|
-
var config_exports = {};
|
|
21
|
-
__export(config_exports, {
|
|
22
|
-
getPixelBatchApi: () => getPixelBatchApi,
|
|
23
|
-
getRegisterApi: () => getRegisterApi,
|
|
24
|
-
getReportApi: () => getReportApi,
|
|
25
|
-
getSDKBaseApi: () => getSDKBaseApi
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(config_exports);
|
|
28
|
-
var getSDKBaseApi = (env) => {
|
|
29
|
-
switch (env) {
|
|
30
|
-
case "product":
|
|
31
|
-
return "https://apm.pharmacyyf.com";
|
|
32
|
-
case "testing":
|
|
33
|
-
return "https://apm-te.pharmacyyf.com";
|
|
34
|
-
case "develop":
|
|
35
|
-
return "https://chief-dev.yifengx.com";
|
|
36
|
-
default:
|
|
37
|
-
return "https://apm.pharmacyyf.com";
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var getRegisterApi = (env) => {
|
|
41
|
-
return `${getSDKBaseApi(env)}/yfcloud-apm/log/front/init`;
|
|
42
|
-
};
|
|
43
|
-
var getReportApi = (env) => {
|
|
44
|
-
return `${getSDKBaseApi(env)}/yfcloud-apm/log/front/batchSave`;
|
|
45
|
-
};
|
|
46
|
-
var getPixelBatchApi = (env) => {
|
|
47
|
-
return `${getSDKBaseApi(env)}/yfcloud-apm/log/front/pixelBatchSave`;
|
|
48
|
-
};
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
getPixelBatchApi,
|
|
52
|
-
getRegisterApi,
|
|
53
|
-
getReportApi,
|
|
54
|
-
getSDKBaseApi
|
|
55
|
-
});
|