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