@sailfish-ai/recorder 1.2.10 → 1.2.11

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 CHANGED
@@ -55,22 +55,6 @@ export const DEFAULT_CONSOLE_RECORDING_SETTINGS = {
55
55
  // recordBody: true,
56
56
  // recordInitialRequests: false,
57
57
  // };
58
- // Function to strip 'www.' and get the effective domain from a URL without tldts
59
- function getEffectiveDomain(url) {
60
- try {
61
- const parsedUrl = new URL(url);
62
- let domain = parsedUrl.hostname;
63
- // Strip 'www.' if present
64
- if (domain.startsWith("www.")) {
65
- domain = domain.slice(4);
66
- }
67
- return domain;
68
- }
69
- catch (error) {
70
- console.error("Invalid URL passed to getEffectiveDomain:", url);
71
- return url; // Return the input if URL parsing fails
72
- }
73
- }
74
58
  // Functions
75
59
  // Function to get the current sessionId from sessionStorage
76
60
  function getOrSetSessionId(forceNew = false) {
@@ -162,9 +146,9 @@ export function matchUrlWithWildcard(url, patterns) {
162
146
  return true;
163
147
  });
164
148
  }
165
- // Updated XMLHttpRequest interceptor with CORS protection
166
149
  // Updated XMLHttpRequest interceptor with domain exclusion
167
150
  function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo, domainsToPropagateHeadersTo = []) {
151
+ console.log("[Sailfish] RUNNING setupXMLHttpRequestInterceptor");
168
152
  const originalOpen = XMLHttpRequest.prototype.open;
169
153
  const originalSend = XMLHttpRequest.prototype.send;
170
154
  const sessionId = getOrSetSessionId();
@@ -177,11 +161,6 @@ function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo, domainsTo
177
161
  XMLHttpRequest.prototype.open = function (method, url, ...args) {
178
162
  console.log("Sailfish XMLHttpRequest.prototype.open", method, url);
179
163
  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
- }
185
164
  return originalOpen.apply(this, [method, url, ...args]);
186
165
  };
187
166
  // Intercept send()
@@ -215,6 +194,7 @@ function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo, domainsTo
215
194
  }
216
195
  // Updated fetch interceptor with exclusion handling
217
196
  function setupFetchInterceptor(domainsToNotPropagateHeadersTo, domainsToPropagateHeadersTo = []) {
197
+ console.log("[Sailfish] RUNNING setupFetchInterceptor");
218
198
  const originalFetch = window.fetch;
219
199
  const sessionId = getOrSetSessionId();
220
200
  const combinedIgnoreDomains = [
@@ -273,6 +253,7 @@ function setupFetchInterceptor(domainsToNotPropagateHeadersTo, domainsToPropagat
273
253
  });
274
254
  // Helper function to inject the X-Sf3-Rid header
275
255
  function injectHeader(target, thisArg, args, input, init, sessionId) {
256
+ console.log("[Sailfish] RUNNING injectHeader");
276
257
  if (sessionId) {
277
258
  if (input instanceof Request) {
278
259
  // Clone the Request and modify headers