@wutiange/log-listener-plugin 2.0.1-alpha.2 → 2.0.1-alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/Server.js +6 -1
- package/dist/src/Server.js.map +1 -1
- package/package.json +1 -1
- package/src/Server.ts +4 -1
package/dist/src/Server.js
CHANGED
@@ -26,6 +26,7 @@ class Server {
|
|
26
26
|
this.urlsListener = onNewUrlCallback;
|
27
27
|
};
|
28
28
|
this.requestJoin = (url, token) => __awaiter(this, void 0, void 0, function* () {
|
29
|
+
var _a;
|
29
30
|
const response = yield fetch(url, {
|
30
31
|
method: "POST",
|
31
32
|
headers: {
|
@@ -33,7 +34,7 @@ class Server {
|
|
33
34
|
},
|
34
35
|
body: JSON.stringify({
|
35
36
|
token,
|
36
|
-
model: this.innerBaseData.Model
|
37
|
+
model: (_a = this.innerBaseData.Model) !== null && _a !== void 0 ? _a : `${this.innerBaseData.systemName}v${this.innerBaseData.osVersion}`,
|
37
38
|
id: (0, md5_1.default)(JSON.stringify(this.innerBaseData)).toString(),
|
38
39
|
}),
|
39
40
|
});
|
@@ -47,6 +48,7 @@ class Server {
|
|
47
48
|
return true;
|
48
49
|
});
|
49
50
|
this.send = (path, data) => __awaiter(this, void 0, void 0, function* () {
|
51
|
+
var _a;
|
50
52
|
const request = (url, _data) => __awaiter(this, void 0, void 0, function* () {
|
51
53
|
yield Promise.race([
|
52
54
|
fetch(`${url}/${path}`, {
|
@@ -71,6 +73,9 @@ class Server {
|
|
71
73
|
yield Promise.all(this.getUrls().map((e) => __awaiter(this, void 0, void 0, function* () { return request(e, data); })));
|
72
74
|
}
|
73
75
|
catch (error) {
|
76
|
+
if ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes("Network request failed")) {
|
77
|
+
return;
|
78
|
+
}
|
74
79
|
logger_1.default.warn(common_1.LOG_KEY, "上报日志失败", error);
|
75
80
|
}
|
76
81
|
});
|
package/dist/src/Server.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Server.js","sourceRoot":"","sources":["../../src/Server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mCAAyC;AAEzC,qCAA2D;AAC3D,sDAA8B;AAC9B,wDAAgC;AAGhC,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,MAAM;IAUV,YAAY,GAAqC,EAAE,UAAkB,KAAK;QATlE,eAAU,GAA2B,EAAE,CAAC;QAExC,aAAQ,GAAwB,EAAE,CAAC;QAKnC,kBAAa,GAA2B,EAAE,CAAC;QAanD,oBAAe,GAAG,CAChB,gBAA2E,EAC3E,EAAE;YACF,IAAI,CAAC,YAAY,GAAG,gBAAgB,CAAC;QACvC,CAAC,CAAC;QAEM,gBAAW,GAAG,CAAO,GAAW,EAAE,KAAa,EAAE,EAAE
|
1
|
+
{"version":3,"file":"Server.js","sourceRoot":"","sources":["../../src/Server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mCAAyC;AAEzC,qCAA2D;AAC3D,sDAA8B;AAC9B,wDAAgC;AAGhC,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,MAAM;IAUV,YAAY,GAAqC,EAAE,UAAkB,KAAK;QATlE,eAAU,GAA2B,EAAE,CAAC;QAExC,aAAQ,GAAwB,EAAE,CAAC;QAKnC,kBAAa,GAA2B,EAAE,CAAC;QAanD,oBAAe,GAAG,CAChB,gBAA2E,EAC3E,EAAE;YACF,IAAI,CAAC,YAAY,GAAG,gBAAgB,CAAC;QACvC,CAAC,CAAC;QAEM,gBAAW,GAAG,CAAO,GAAW,EAAE,KAAa,EAAE,EAAE;;YACzD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,gCAAgC;iBACjD;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,KAAK;oBACL,KAAK,EAAE,MAAA,IAAI,CAAC,aAAa,CAAC,K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B,gBAAM,CAAC,IAAI,CAAC,gBAAO,EAAE,2EAA2E,EAAE,KAAK,CAAC,CAAC;YAC3G,CAAC;QACH,CAAC;KAAA;IAED,aAAa,CAAC,OAAO,GAAG,IAAI;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,OAAO;QACL,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YAC9C,IAAI,IAAA,eAAO,EAAC,CAAC,CAAC,EAAE,CAAC;gBACf,OAAO,CAAC,CAAC;YACX,CAAC;YACD,OAAO,GAAG,CAAC,IAAI,YAAY,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;IAuCD,SAAS,CAAC,GAAW;QACnB,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,EAAE,CAAC;QAC7D,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;QACvC,CAAC;IACH,CAAC;IAED,aAAa,CAAC,MAA8B;QAC1C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;IAC3B,CAAC;IAED,cAAc,CAAC,IAAyB;QACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CASF;AAED,kBAAe,MAAM,CAAC"}
|
package/package.json
CHANGED
package/src/Server.ts
CHANGED
@@ -41,7 +41,7 @@ class Server {
|
|
41
41
|
},
|
42
42
|
body: JSON.stringify({
|
43
43
|
token,
|
44
|
-
model: this.innerBaseData.Model
|
44
|
+
model: this.innerBaseData.Model ?? `${this.innerBaseData.systemName}v${this.innerBaseData.osVersion}`,
|
45
45
|
id: md5(JSON.stringify(this.innerBaseData)).toString(),
|
46
46
|
}),
|
47
47
|
});
|
@@ -131,6 +131,9 @@ class Server {
|
|
131
131
|
}
|
132
132
|
await Promise.all(this.getUrls().map(async (e) => request(e, data)));
|
133
133
|
} catch (error: any) {
|
134
|
+
if (error?.message?.includes("Network request failed")) {
|
135
|
+
return
|
136
|
+
}
|
134
137
|
logger.warn(LOG_KEY, "上报日志失败", error)
|
135
138
|
}
|
136
139
|
};
|