@sailfish-ai/recorder 1.8.12 → 1.8.13
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/graphql.js +7 -0
- package/dist/index.js +30 -4
- package/dist/recorder.cjs +801 -771
- package/dist/recorder.js +804 -771
- package/dist/recorder.js.br +0 -0
- package/dist/recorder.js.gz +0 -0
- package/dist/recorder.umd.cjs +801 -771
- package/dist/types/graphql.d.ts +2 -1
- package/dist/types/types.d.ts +3 -0
- package/dist/types/websocket.d.ts +10 -0
- package/dist/websocket.js +142 -64
- package/package.json +1 -1
package/dist/graphql.js
CHANGED
|
@@ -42,6 +42,13 @@ export function fetchCaptureSettings(apiKey, backendApi) {
|
|
|
42
42
|
}
|
|
43
43
|
`, { apiKey, backendApi });
|
|
44
44
|
}
|
|
45
|
+
export function fetchFunctionSpanTrackingEnabled(apiKey, backendApi) {
|
|
46
|
+
return sendGraphQLRequest("GetFunctionSpanTrackingEnabledFromApiKey", `
|
|
47
|
+
query GetFunctionSpanTrackingEnabledFromApiKey($apiKey: String!) {
|
|
48
|
+
isFunctionSpanTrackingEnabledFromApiKey(apiKey: $apiKey)
|
|
49
|
+
}
|
|
50
|
+
`, { apiKey, backendApi });
|
|
51
|
+
}
|
|
45
52
|
export function startRecordingSession(apiKey, recordingId, backendApi, serviceIdentifier, serviceVersion, mapUuid, gitSha, library, serviceAdditionalMetadata) {
|
|
46
53
|
// These must be sent as None/Null for now (not user-provided)
|
|
47
54
|
const startRecordingFilePath = null;
|
package/dist/index.js
CHANGED
|
@@ -5,14 +5,14 @@ import { NetworkRequestEventId, STATIC_EXTENSIONS, xSf3RidHeader, } from "./cons
|
|
|
5
5
|
import { gatherAndCacheDeviceInfo } from "./deviceInfo";
|
|
6
6
|
import { readGitSha } from "./env";
|
|
7
7
|
import { initializeErrorInterceptor } from "./errorInterceptor";
|
|
8
|
-
import { fetchCaptureSettings, sendDomainsToNotPropagateHeaderTo, startRecordingSession, } from "./graphql";
|
|
8
|
+
import { fetchCaptureSettings, fetchFunctionSpanTrackingEnabled, sendDomainsToNotPropagateHeaderTo, startRecordingSession, } from "./graphql";
|
|
9
9
|
import { setupIssueReporting } from "./inAppReportIssueModal";
|
|
10
10
|
import { sendMapUuidIfAvailable } from "./mapUuid";
|
|
11
11
|
import { getUrlAndStoredUuids, initializeConsolePlugin, initializeDomContentEvents, initializeRecording, } from "./recording";
|
|
12
12
|
import { HAS_DOCUMENT, HAS_LOCAL_STORAGE, HAS_SESSION_STORAGE, HAS_WINDOW, } from "./runtimeEnv";
|
|
13
13
|
import { getOrSetSessionId } from "./session";
|
|
14
14
|
import { withAppUrlMetadata } from "./utils";
|
|
15
|
-
import { getFuncSpanHeader, sendEvent, sendMessage } from "./websocket";
|
|
15
|
+
import { clearStaleFuncSpanState, getFuncSpanHeader, isFunctionSpanTrackingEnabled, sendEvent, sendMessage, } from "./websocket";
|
|
16
16
|
const DEBUG = readDebugFlag(); // A wrapper around fetch that suppresses connection refused errors
|
|
17
17
|
// Default list of domains to ignore
|
|
18
18
|
const DOMAINS_TO_NOT_PROPAGATE_HEADER_TO_DEFAULT = [
|
|
@@ -455,8 +455,8 @@ function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo = []) {
|
|
|
455
455
|
const allHeaders = this.getAllResponseHeaders();
|
|
456
456
|
if (allHeaders) {
|
|
457
457
|
// Parse headers string into object
|
|
458
|
-
allHeaders.split(
|
|
459
|
-
const parts = line.split(
|
|
458
|
+
allHeaders.split("\r\n").forEach((line) => {
|
|
459
|
+
const parts = line.split(": ");
|
|
460
460
|
if (parts.length === 2) {
|
|
461
461
|
responseHeaders[parts[0]] = parts[1];
|
|
462
462
|
}
|
|
@@ -814,6 +814,32 @@ export async function startRecording({ apiKey, backendApi = "https://api-service
|
|
|
814
814
|
trackDomainChangesOnce();
|
|
815
815
|
sessionStorage.setItem("sailfishApiKey", apiKey);
|
|
816
816
|
sessionStorage.setItem("sailfishBackendApi", backendApi);
|
|
817
|
+
// Function span tracking state is loaded from localStorage on module init (websocket.tsx)
|
|
818
|
+
// Validate localStorage state with backend if tracking appears to be enabled but WebSocket not connected
|
|
819
|
+
if (isFunctionSpanTrackingEnabled() && (!g.ws || g.ws.readyState !== 1)) {
|
|
820
|
+
fetchFunctionSpanTrackingEnabled(apiKey, backendApi)
|
|
821
|
+
.then((funcSpanResponse) => {
|
|
822
|
+
const isEnabled = funcSpanResponse.data?.isFunctionSpanTrackingEnabledFromApiKey ?? false;
|
|
823
|
+
if (!isEnabled) {
|
|
824
|
+
// Backend says tracking is NOT active, clear stale localStorage data
|
|
825
|
+
clearStaleFuncSpanState();
|
|
826
|
+
if (DEBUG) {
|
|
827
|
+
console.log("[Sailfish] Cleared stale function span tracking state - backend validation shows tracking is not active");
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
if (DEBUG) {
|
|
832
|
+
console.log("[Sailfish] Function span tracking state validated with backend: ACTIVE");
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
})
|
|
836
|
+
.catch((error) => {
|
|
837
|
+
if (DEBUG) {
|
|
838
|
+
console.warn("[Sailfish] Failed to validate function span tracking status with backend:", error);
|
|
839
|
+
}
|
|
840
|
+
// On error, keep the localStorage state and let WebSocket correct it when it connects
|
|
841
|
+
});
|
|
842
|
+
}
|
|
817
843
|
if (!g.sentDoNotPropagateOnce) {
|
|
818
844
|
sendDomainsToNotPropagateHeaderTo(apiKey, [
|
|
819
845
|
...domainsToNotPropagateHeaderTo,
|