@sailfish-ai/recorder 1.2.11 → 1.3.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.js CHANGED
@@ -82,7 +82,6 @@ function storeCredentialsAndConnection({ apiKey, backendApi, }) {
82
82
  }
83
83
  // Utility function to match domains or paths with wildcard support
84
84
  export function matchUrlWithWildcard(url, patterns) {
85
- console.log(`Calling matchUrlWithWildcard against ${url}`);
86
85
  if (!url || typeof url !== "string") {
87
86
  throw new Error("Invalid URL input");
88
87
  }
@@ -148,7 +147,6 @@ export function matchUrlWithWildcard(url, patterns) {
148
147
  }
149
148
  // Updated XMLHttpRequest interceptor with domain exclusion
150
149
  function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo, domainsToPropagateHeadersTo = []) {
151
- console.log("[Sailfish] RUNNING setupXMLHttpRequestInterceptor");
152
150
  const originalOpen = XMLHttpRequest.prototype.open;
153
151
  const originalSend = XMLHttpRequest.prototype.send;
154
152
  const sessionId = getOrSetSessionId();
@@ -159,26 +157,22 @@ function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo, domainsTo
159
157
  ];
160
158
  // Intercept open()
161
159
  XMLHttpRequest.prototype.open = function (method, url, ...args) {
162
- console.log("Sailfish XMLHttpRequest.prototype.open", method, url);
163
160
  this._requestUrl = typeof url === "string" && url.length > 0 ? url : null;
164
161
  return originalOpen.apply(this, [method, url, ...args]);
165
162
  };
166
163
  // Intercept send()
167
164
  XMLHttpRequest.prototype.send = function (...args) {
168
- console.log("Sailfish XMLHttpRequest.prototype.send", this._requestUrl);
169
165
  const url = this._requestUrl;
170
166
  if (!url)
171
167
  return originalSend.apply(this, args);
172
168
  // Skip domain check for excluded domains
173
169
  if (matchUrlWithWildcard(url, combinedIgnoreDomains)) {
174
- console.log(`[XML] [ExcludedDomain] IGNORE --> ${url}`);
175
170
  return originalSend.apply(this, args);
176
171
  }
177
172
  // Check if domain should propagate headers
178
173
  const shouldPropagateHeader = domainsToPropagateHeadersTo.length === 0 ||
179
174
  matchUrlWithWildcard(url, domainsToPropagateHeadersTo);
180
175
  if (sessionId && shouldPropagateHeader) {
181
- console.log(`[XML] [InPropagateDomains] PROPAGATE FOR --> ${url}`);
182
176
  try {
183
177
  this.setRequestHeader("X-Sf3-Rid", sessionId);
184
178
  }
@@ -186,15 +180,11 @@ function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo, domainsTo
186
180
  console.warn(`Could not set X-Sf3-Rid header for ${url}`, e);
187
181
  }
188
182
  }
189
- else {
190
- console.log(`[XML] [NOT InPropagateDomains] IGNORE --> ${url}`);
191
- }
192
183
  return originalSend.apply(this, args);
193
184
  };
194
185
  }
195
186
  // Updated fetch interceptor with exclusion handling
196
187
  function setupFetchInterceptor(domainsToNotPropagateHeadersTo, domainsToPropagateHeadersTo = []) {
197
- console.log("[Sailfish] RUNNING setupFetchInterceptor");
198
188
  const originalFetch = window.fetch;
199
189
  const sessionId = getOrSetSessionId();
200
190
  const combinedIgnoreDomains = [
@@ -217,24 +207,20 @@ function setupFetchInterceptor(domainsToNotPropagateHeadersTo, domainsToPropagat
217
207
  url = input.href;
218
208
  }
219
209
  else {
220
- console.log("Unsupported args -->", args);
221
210
  return target.apply(thisArg, args); // Skip unsupported inputs
222
211
  }
223
212
  // Cache check
224
213
  if (cache.has(url)) {
225
214
  const cachedResult = cache.get(url);
226
215
  if (cachedResult === "ignore") {
227
- console.log(`[CACHE] IGNORE --> ${url}`);
228
216
  return target.apply(thisArg, args);
229
217
  }
230
218
  if (cachedResult === "propagate") {
231
- console.log(`[CACHE] PROPAGATE FOR --> ${url}`);
232
219
  return injectHeader(target, thisArg, args, input, init, sessionId);
233
220
  }
234
221
  }
235
222
  // Check domain exclusion
236
223
  if (matchUrlWithWildcard(url, combinedIgnoreDomains)) {
237
- console.log(`[InIgnoreDomains] IGNORE --> ${url}`);
238
224
  cache.set(url, "ignore");
239
225
  return target.apply(thisArg, args);
240
226
  }
@@ -242,18 +228,15 @@ function setupFetchInterceptor(domainsToNotPropagateHeadersTo, domainsToPropagat
242
228
  const shouldPropagateHeader = domainsToPropagateHeadersTo.length === 0 ||
243
229
  matchUrlWithWildcard(url, domainsToPropagateHeadersTo);
244
230
  if (!shouldPropagateHeader) {
245
- console.log(`[NOT InPropagateDomans] IGNORE --> ${url}`);
246
231
  cache.set(url, "ignore");
247
232
  return target.apply(thisArg, args);
248
233
  }
249
234
  cache.set(url, "propagate");
250
- console.log(`[InPropagateDomans] PROPAGATE FOR --> ${url}`);
251
235
  return injectHeader(target, thisArg, args, input, init, sessionId);
252
236
  },
253
237
  });
254
238
  // Helper function to inject the X-Sf3-Rid header
255
239
  function injectHeader(target, thisArg, args, input, init, sessionId) {
256
- console.log("[Sailfish] RUNNING injectHeader");
257
240
  if (sessionId) {
258
241
  if (input instanceof Request) {
259
242
  // Clone the Request and modify headers
@@ -263,7 +246,6 @@ function setupFetchInterceptor(domainsToNotPropagateHeadersTo, domainsToPropagat
263
246
  const modifiedRequest = new Request(clonedRequest, {
264
247
  headers: newHeaders,
265
248
  });
266
- console.log(`[modified call] newHeaders --> `, newHeaders);
267
249
  return target.call(thisArg, modifiedRequest, init);
268
250
  }
269
251
  else {
@@ -272,12 +254,10 @@ function setupFetchInterceptor(domainsToNotPropagateHeadersTo, domainsToPropagat
272
254
  const newHeaders = new Headers(init.headers || {});
273
255
  newHeaders.set("X-Sf3-Rid", sessionId);
274
256
  modifiedInit.headers = newHeaders;
275
- console.log(`[modified call] newHeaders --> `, newHeaders);
276
257
  return target.call(thisArg, input, modifiedInit);
277
258
  }
278
259
  }
279
260
  else {
280
- console.log("[UNMODIFIED CALL]");
281
261
  return target.apply(thisArg, args);
282
262
  }
283
263
  }