@sailfish-ai/recorder 1.4.4 → 1.5.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.js +32 -0
- 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
|
@@ -57,6 +57,37 @@ const PERSIST_SESSION_FOR_REOPENING_TABS = false;
|
|
|
57
57
|
// recordBody: true,
|
|
58
58
|
// recordInitialRequests: false,
|
|
59
59
|
// };
|
|
60
|
+
function trackDomainChanges() {
|
|
61
|
+
let lastDomain = window.location.href;
|
|
62
|
+
const checkDomainChange = (forceSend = false) => {
|
|
63
|
+
const currentDomain = window.location.href;
|
|
64
|
+
if (forceSend || currentDomain !== lastDomain) {
|
|
65
|
+
console.log(`Domain changed from ${lastDomain} to ${currentDomain}`);
|
|
66
|
+
lastDomain = currentDomain;
|
|
67
|
+
const timestamp = Date.now();
|
|
68
|
+
sendMessage({
|
|
69
|
+
type: "routeChange",
|
|
70
|
+
data: {
|
|
71
|
+
url: currentDomain,
|
|
72
|
+
timestamp,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const debouncedCheck = debounce(() => checkDomainChange(), 500);
|
|
78
|
+
// Force the first check to send the initial URL on load
|
|
79
|
+
checkDomainChange(true);
|
|
80
|
+
// Set interval to periodically check if the domain or path has changed
|
|
81
|
+
setInterval(debouncedCheck, 1000); // Adjust the interval as needed
|
|
82
|
+
}
|
|
83
|
+
// Debounce utility function
|
|
84
|
+
function debounce(func, wait) {
|
|
85
|
+
let timeout;
|
|
86
|
+
return function (...args) {
|
|
87
|
+
clearTimeout(timeout);
|
|
88
|
+
timeout = setTimeout(() => func(...args), wait);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
60
91
|
// Functions
|
|
61
92
|
function sendUserDeviceUuid() {
|
|
62
93
|
const userDeviceUuid = getOrSetUserDeviceUuid();
|
|
@@ -322,6 +353,7 @@ function setupFetchInterceptor(domainsToNotPropagateHeadersTo, domainsToPropagat
|
|
|
322
353
|
export async function startRecording({ apiKey, backendApi = "https://api-service.sailfishqa.com", domainsToPropagateHeaderTo = [], domainsToNotPropagateHeaderTo = [], }) {
|
|
323
354
|
let sessionId = getOrSetSessionId();
|
|
324
355
|
storeCredentialsAndConnection({ apiKey, backendApi });
|
|
356
|
+
trackDomainChanges();
|
|
325
357
|
// Non-blocking GraphQL request to send the domains if provided
|
|
326
358
|
if (domainsToNotPropagateHeaderTo.length > 0) {
|
|
327
359
|
sendDomainsToNotPropagateHeaderTo(apiKey, domainsToNotPropagateHeaderTo, backendApi).catch((error) => console.error("Failed to send domains to not propagate header to:", error));
|