@sailfish-ai/recorder 1.2.7 → 1.2.9
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.js +27 -9
- package/dist/sailfish-recorder.cjs.js +1 -1
- package/dist/sailfish-recorder.cjs.js.br +0 -0
- package/dist/sailfish-recorder.cjs.js.gz +0 -0
- package/dist/sailfish-recorder.es.js +1 -1
- package/dist/sailfish-recorder.es.js.br +0 -0
- package/dist/sailfish-recorder.es.js.gz +0 -0
- package/dist/sailfish-recorder.umd.js +1 -1
- package/dist/sailfish-recorder.umd.js.br +0 -0
- package/dist/sailfish-recorder.umd.js.gz +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,12 @@ import { initializeRecording } from "./recording";
|
|
|
7
7
|
// Default list of domains to ignore
|
|
8
8
|
const DOMAINS_TO_NOT_PROPAGATE_HEADER_TO_DEFAULT = [
|
|
9
9
|
"t.co",
|
|
10
|
+
"*.twitter.com",
|
|
11
|
+
"*.gravatar.com",
|
|
10
12
|
"identitytoolkit.googleapis.com",
|
|
13
|
+
"*.amazonaws.com", // Exclude AWS S3
|
|
14
|
+
"*.smooch.io", // Exclude smooch-related requests
|
|
15
|
+
"*.zendesk.com", // Exclude zendesk-related requests
|
|
11
16
|
];
|
|
12
17
|
const DOMAINS_TO_NOT_RECORD_NETWORK_REQUESTS_TO = [];
|
|
13
18
|
export const DEFAULT_CAPTURE_SETTINGS = {
|
|
@@ -157,7 +162,8 @@ export function matchUrlWithWildcard(url, patterns) {
|
|
|
157
162
|
return true;
|
|
158
163
|
});
|
|
159
164
|
}
|
|
160
|
-
// Updated XMLHttpRequest interceptor with
|
|
165
|
+
// Updated XMLHttpRequest interceptor with CORS protection
|
|
166
|
+
// Updated XMLHttpRequest interceptor with domain exclusion
|
|
161
167
|
function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo, domainsToPropagateHeadersTo = []) {
|
|
162
168
|
const originalOpen = XMLHttpRequest.prototype.open;
|
|
163
169
|
const originalSend = XMLHttpRequest.prototype.send;
|
|
@@ -167,31 +173,43 @@ function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo, domainsTo
|
|
|
167
173
|
...DOMAINS_TO_NOT_PROPAGATE_HEADER_TO_DEFAULT,
|
|
168
174
|
...domainsToNotPropagateHeaderTo,
|
|
169
175
|
];
|
|
170
|
-
//
|
|
176
|
+
// Intercept open()
|
|
171
177
|
XMLHttpRequest.prototype.open = function (method, url, ...args) {
|
|
172
|
-
console.log("Sailfish XMLHttpRequest.prototype.open");
|
|
178
|
+
console.log("Sailfish XMLHttpRequest.prototype.open", method, url);
|
|
173
179
|
this._requestUrl = typeof url === "string" && url.length > 0 ? url : null;
|
|
180
|
+
// Skip interception for excluded domains
|
|
181
|
+
if (matchUrlWithWildcard(url, combinedIgnoreDomains)) {
|
|
182
|
+
console.log(`[XML] Skipping request for excluded domain: ${url}`);
|
|
183
|
+
return originalOpen.apply(this, [method, url, ...args]);
|
|
184
|
+
}
|
|
174
185
|
return originalOpen.apply(this, [method, url, ...args]);
|
|
175
186
|
};
|
|
176
187
|
// Intercept send()
|
|
177
188
|
XMLHttpRequest.prototype.send = function (...args) {
|
|
178
|
-
console.log("Sailfish XMLHttpRequest.prototype.send");
|
|
189
|
+
console.log("Sailfish XMLHttpRequest.prototype.send", this._requestUrl);
|
|
179
190
|
const url = this._requestUrl;
|
|
180
191
|
if (!url)
|
|
181
192
|
return originalSend.apply(this, args);
|
|
182
|
-
//
|
|
193
|
+
// Skip domain check for excluded domains
|
|
183
194
|
if (matchUrlWithWildcard(url, combinedIgnoreDomains)) {
|
|
184
|
-
console.log(
|
|
195
|
+
console.log(`[XML] [ExcludedDomain] IGNORE --> ${url}`);
|
|
185
196
|
return originalSend.apply(this, args);
|
|
186
197
|
}
|
|
187
198
|
// Check if domain should propagate headers
|
|
188
199
|
const shouldPropagateHeader = domainsToPropagateHeadersTo.length === 0 ||
|
|
189
200
|
matchUrlWithWildcard(url, domainsToPropagateHeadersTo);
|
|
190
201
|
if (sessionId && shouldPropagateHeader) {
|
|
191
|
-
console.log(
|
|
192
|
-
|
|
202
|
+
console.log(`[XML] [InPropagateDomains] PROPAGATE FOR --> ${url}`);
|
|
203
|
+
try {
|
|
204
|
+
this.setRequestHeader("X-Sf3-Rid", sessionId);
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
console.warn(`Could not set X-Sf3-Rid header for ${url}`, e);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
console.log(`[XML] [NOT InPropagateDomains] IGNORE --> ${url}`);
|
|
193
212
|
}
|
|
194
|
-
console.log([`[XML] [NOT InPropagateDomans] IGNORE --> ${url}`]);
|
|
195
213
|
return originalSend.apply(this, args);
|
|
196
214
|
};
|
|
197
215
|
}
|