@botim/mp-debug-sdk 0.3.0 → 0.3.1
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/index.cjs +9 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -107,8 +107,7 @@ var Transport = class {
|
|
|
107
107
|
Authorization: `Bearer ${this.opts.deviceToken}`
|
|
108
108
|
},
|
|
109
109
|
body: JSON.stringify(batch),
|
|
110
|
-
signal: this.inflightUpload.signal
|
|
111
|
-
keepalive: true
|
|
110
|
+
signal: this.inflightUpload.signal
|
|
112
111
|
});
|
|
113
112
|
if (!res.ok) {
|
|
114
113
|
throw new Error(`ingest http ${res.status}`);
|
|
@@ -200,6 +199,12 @@ var Transport = class {
|
|
|
200
199
|
}
|
|
201
200
|
if (this.opts.buffer.size() > 0) {
|
|
202
201
|
const events = this.opts.buffer.drain(this.opts.buffer.size());
|
|
202
|
+
const body = JSON.stringify({
|
|
203
|
+
sessionToken: this.opts.deviceToken,
|
|
204
|
+
events
|
|
205
|
+
});
|
|
206
|
+
const KEEPALIVE_BODY_LIMIT = 60 * 1024;
|
|
207
|
+
const useKeepalive = body.length <= KEEPALIVE_BODY_LIMIT;
|
|
203
208
|
try {
|
|
204
209
|
await this.internalFetch(this.opts.ingestUrl, {
|
|
205
210
|
method: "POST",
|
|
@@ -207,11 +212,8 @@ var Transport = class {
|
|
|
207
212
|
"Content-Type": "application/json",
|
|
208
213
|
Authorization: `Bearer ${this.opts.deviceToken}`
|
|
209
214
|
},
|
|
210
|
-
body
|
|
211
|
-
|
|
212
|
-
events
|
|
213
|
-
}),
|
|
214
|
-
keepalive: true
|
|
215
|
+
body,
|
|
216
|
+
...useKeepalive ? { keepalive: true } : {}
|
|
215
217
|
});
|
|
216
218
|
} catch (err) {
|
|
217
219
|
this.opts.onError?.(err);
|