@replayio-app-building/netlify-recorder 0.52.0 → 0.54.0
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.d.ts +2 -0
- package/dist/index.js +18 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -105,6 +105,8 @@ interface BlobData {
|
|
|
105
105
|
* network calls).
|
|
106
106
|
*/
|
|
107
107
|
originalRequestId?: string;
|
|
108
|
+
/** The version of @replayio-app-building/netlify-recorder that generated this blob. */
|
|
109
|
+
packageVersion: string;
|
|
108
110
|
}
|
|
109
111
|
interface FinishRequestCallbacks {
|
|
110
112
|
/**
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ function incrementCallIndex() {
|
|
|
34
34
|
// src/interceptors/network.ts
|
|
35
35
|
import http from "http";
|
|
36
36
|
import https from "https";
|
|
37
|
+
import zlib from "zlib";
|
|
37
38
|
import { Readable, Writable } from "stream";
|
|
38
39
|
function isNeonQuery(obj) {
|
|
39
40
|
return typeof obj === "object" && obj !== null && "query" in obj && "params" in obj;
|
|
@@ -138,7 +139,21 @@ function patchHttpModules(mode, calls, consumed, silent) {
|
|
|
138
139
|
entry.requestBody = bodyChunks.length > 0 ? Buffer.concat(bodyChunks).toString("utf-8") : void 0;
|
|
139
140
|
entry.responseStatus = res.statusCode ?? 0;
|
|
140
141
|
entry.responseHeaders = responseHeaders;
|
|
141
|
-
|
|
142
|
+
const raw = Buffer.concat(resChunks);
|
|
143
|
+
const encoding = (res.headers["content-encoding"] || "").toLowerCase();
|
|
144
|
+
try {
|
|
145
|
+
if (encoding === "gzip" || encoding === "x-gzip") {
|
|
146
|
+
entry.responseBody = zlib.gunzipSync(raw).toString("utf-8");
|
|
147
|
+
} else if (encoding === "deflate") {
|
|
148
|
+
entry.responseBody = zlib.inflateSync(raw).toString("utf-8");
|
|
149
|
+
} else if (encoding === "br") {
|
|
150
|
+
entry.responseBody = zlib.brotliDecompressSync(raw).toString("utf-8");
|
|
151
|
+
} else {
|
|
152
|
+
entry.responseBody = raw.toString("utf-8");
|
|
153
|
+
}
|
|
154
|
+
} catch {
|
|
155
|
+
entry.responseBody = raw.toString("utf-8");
|
|
156
|
+
}
|
|
142
157
|
entry.timestamp = endTime;
|
|
143
158
|
entry.endTime = endTime;
|
|
144
159
|
entry.pending = false;
|
|
@@ -968,7 +983,8 @@ async function finishRequest(requestContext, callbacks, response, options) {
|
|
|
968
983
|
statusCode: response.statusCode ?? response.status ?? 0,
|
|
969
984
|
body: typeof response.body === "string" ? response.body : void 0
|
|
970
985
|
},
|
|
971
|
-
originalRequestId: options?.originalRequestId
|
|
986
|
+
originalRequestId: options?.originalRequestId,
|
|
987
|
+
packageVersion: "0.54.0"
|
|
972
988
|
};
|
|
973
989
|
const blobData = redactBlobData(rawBlobData);
|
|
974
990
|
const blobContent = JSON.stringify(blobData);
|