@sailfish-ai/recorder 1.7.33 → 1.7.34

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 CHANGED
@@ -41,11 +41,33 @@ export function fetchCaptureSettings(apiKey, backendApi) {
41
41
  }
42
42
  `, { apiKey, backendApi });
43
43
  }
44
- export function startRecordingSession(apiKey, recordingId, backendApi) {
45
- return sendGraphQLRequest("StartSession", `mutation StartSession($apiKey: UUID!, $recordingSessionId: UUID!) {
44
+ export function startRecordingSession(apiKey, recordingId, backendApi, serviceIdentifier, serviceVersion, mapUuid, gitSha, library, serviceAdditionalMetadata) {
45
+ // These must be sent as None/Null for now (not user-provided)
46
+ const startRecordingFilePath = null;
47
+ const startRecordingFileNumber = null;
48
+ return sendGraphQLRequest("StartSession", `mutation StartSession(
49
+ $apiKey: UUID!,
50
+ $recordingSessionId: UUID!,
51
+ $serviceIdentifier: String!,
52
+ $serviceVersion: String,
53
+ $mapUuid: String,
54
+ $gitSha: String,
55
+ $library: String,
56
+ $serviceAdditionalMetadata: JSON,
57
+ $startRecordingFilePath: String,
58
+ $startRecordingFileNumber: Int
59
+ ) {
46
60
  startRecordingSession(
47
61
  companyApiKey: $apiKey,
48
- sessionId: $recordingSessionId
62
+ sessionId: $recordingSessionId,
63
+ serviceIdentifier: $serviceIdentifier,
64
+ serviceVersion: $serviceVersion,
65
+ mapUuid: $mapUuid,
66
+ gitSha: $gitSha,
67
+ library: $library,
68
+ serviceAdditionalMetadata: $serviceAdditionalMetadata,
69
+ startRecordingFilePath: $startRecordingFilePath,
70
+ startRecordingFileNumber: $startRecordingFileNumber
49
71
  ) {
50
72
  id
51
73
  }
@@ -53,6 +75,14 @@ export function startRecordingSession(apiKey, recordingId, backendApi) {
53
75
  apiKey,
54
76
  recordingSessionId: recordingId,
55
77
  backendApi,
78
+ serviceIdentifier,
79
+ serviceVersion,
80
+ mapUuid,
81
+ gitSha,
82
+ library,
83
+ serviceAdditionalMetadata,
84
+ startRecordingFilePath,
85
+ startRecordingFileNumber,
56
86
  });
57
87
  }
58
88
  export function sendDomainsToNotPropagateHeaderTo(apiKey, domains, backendApi) {
package/dist/index.js CHANGED
@@ -771,9 +771,60 @@ function setupFetchInterceptor(domainsToNotPropagateHeadersTo = []) {
771
771
  }
772
772
  }
773
773
  }
774
+ // Note - if you update this, you must copy this function to the documentation in docs/docs/getting-started/updating-autoinstall-prs.md.
775
+ function getCompileTimeGitSha() {
776
+ // 1) Preferred: a hard-coded global replaced at build time (all bundlers support "define")
777
+ // e.g. webpack DefinePlugin/esbuild/rollup/vite: __GIT_SHA__ => JSON.stringify('<sha>')
778
+ try {
779
+ const g = globalThis;
780
+ if (g && typeof g.__GIT_SHA__ === "string" && g.__GIT_SHA__) {
781
+ return g.__GIT_SHA__;
782
+ }
783
+ }
784
+ catch { }
785
+ // 2) Common pattern: process.env.GIT_SHA (webpack/rollup/esbuild/parcel)
786
+ try {
787
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
788
+ const p = typeof process !== "undefined" ? process : undefined;
789
+ if (p?.env?.GIT_SHA)
790
+ return String(p.env.GIT_SHA);
791
+ }
792
+ catch { }
793
+ // 3) Vite (or other tools exposing import.meta.env)
794
+ try {
795
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
796
+ const im = import.meta;
797
+ if (im?.env?.VITE_GIT_SHA)
798
+ return String(im.env.VITE_GIT_SHA);
799
+ if (im?.env?.GIT_SHA)
800
+ return String(im.env.GIT_SHA);
801
+ }
802
+ catch { }
803
+ return undefined;
804
+ }
805
+ // --- helper for mapUuid default from window ---
806
+ function getMapUuidFromWindow() {
807
+ try {
808
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
809
+ const w = window;
810
+ if (w && typeof w.sfMapUuid === "string" && w.sfMapUuid) {
811
+ return w.sfMapUuid;
812
+ }
813
+ }
814
+ catch { }
815
+ return undefined;
816
+ }
774
817
  // Main Recording Function
775
- export async function startRecording({ apiKey, backendApi = "https://api-service.sailfishqa.com", domainsToPropagateHeaderTo = [], domainsToNotPropagateHeaderTo = [], serviceVersion = "", serviceIdentifier = "", }) {
776
- let sessionId = getOrSetSessionId();
818
+ // Note - we do NOT send serviceIdentifier because
819
+ // it would be 1 serviceIdentifier per frontend user session,
820
+ // which is very wasteful
821
+ export async function startRecording({ apiKey, backendApi = "https://api-service.sailfishqa.com", domainsToPropagateHeaderTo = [], domainsToNotPropagateHeaderTo = [], serviceVersion, serviceIdentifier, gitSha, serviceAdditionalMetadata, }) {
822
+ const effectiveGitSha = gitSha ?? getCompileTimeGitSha();
823
+ const effectiveServiceIdentifier = serviceIdentifier ?? "";
824
+ const effectiveServiceVersion = serviceVersion ?? "";
825
+ const effectiveLibrary = "JS/TS"; // from Recorder.LIBRARY_CHOICES
826
+ const effectiveMapUuid = getMapUuidFromWindow();
827
+ const sessionId = getOrSetSessionId();
777
828
  initializeDomContentEvents(sessionId);
778
829
  initializeConsolePlugin(DEFAULT_CONSOLE_RECORDING_SETTINGS, sessionId);
779
830
  storeCredentialsAndConnection({ apiKey, backendApi });
@@ -806,7 +857,7 @@ export async function startRecording({ apiKey, backendApi = "https://api-service
806
857
  const captureSettingsResponse = await fetchCaptureSettings(apiKey, backendApi);
807
858
  const captureSettings = captureSettingsResponse.data?.captureSettingsFromApiKey ||
808
859
  DEFAULT_CAPTURE_SETTINGS;
809
- const sessionResponse = await startRecordingSession(apiKey, sessionId, backendApi);
860
+ const sessionResponse = await startRecordingSession(apiKey, sessionId, backendApi, effectiveServiceIdentifier, effectiveServiceVersion, effectiveMapUuid, effectiveGitSha, effectiveLibrary, serviceAdditionalMetadata);
810
861
  if (sessionResponse.data?.startRecordingSession) {
811
862
  const websocket = await initializeRecording(captureSettings,
812
863
  // DEFAULT_NETWORK_CAPTURE_SETTINGS,