@sailfish-ai/recorder 1.7.49 → 1.8.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.
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ export declare function readDebugFlag(): boolean;
2
+ export declare function readGitSha(): string | undefined;
@@ -6,3 +6,4 @@ export declare function buildBatches<T extends {
6
6
  export declare function eventSize(event: any): number;
7
7
  declare let nowTimestamp: () => number;
8
8
  export { nowTimestamp };
9
+ export declare function withAppUrlMetadata(serviceAdditionalMetadata?: Record<string, any>): Record<string, any>;
package/dist/utils.js CHANGED
@@ -46,3 +46,9 @@ if (!( /*@__PURE__*//[1-9][0-9]{12}/.test(Date.now().toString()))) {
46
46
  nowTimestamp = () => new Date().getTime();
47
47
  }
48
48
  export { nowTimestamp };
49
+ export function withAppUrlMetadata(serviceAdditionalMetadata) {
50
+ return {
51
+ ...(serviceAdditionalMetadata ?? {}),
52
+ appUrl: serviceAdditionalMetadata?.appUrl ?? window?.location?.href,
53
+ };
54
+ }
package/dist/websocket.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import ReconnectingWebSocket from "reconnecting-websocket";
2
+ import { readDebugFlag } from "./env";
2
3
  import { deleteEventsByIds, getAllIndexedEvents, saveEventToIDB, } from "./eventStore";
3
4
  import { deleteNotifyMessageById, getAllNotifyMessages, saveNotifyMessageToIDB, } from "./notifyEventStore";
4
5
  import { getOrSetSessionId } from "./session";
5
6
  import { buildBatches, eventSize } from "./utils";
6
7
  import version from "./version";
8
+ const DEBUG = readDebugFlag(); // A wrapper around fetch that suppresses connection refused errors
7
9
  const MAX_MESSAGE_SIZE_MB = 50;
8
10
  const MAX_MESSAGE_SIZE_BYTES = MAX_MESSAGE_SIZE_MB * 1024 * 1024;
9
- const DEBUG = import.meta.env.VITE_DEBUG ? import.meta.env.VITE_DEBUG : false;
10
11
  let webSocket = null;
11
12
  let isDraining = false;
12
13
  let inFlightFlush = null;
@@ -48,7 +49,10 @@ export async function flushBufferedEvents() {
48
49
  for (const batch of idbBatches) {
49
50
  if (!isWebSocketOpen(webSocket))
50
51
  break;
51
- const eventsToSend = batch.map((e) => e.data);
52
+ const eventsToSend = batch.map((e) => ({
53
+ ...e.data,
54
+ appUrl: e.data?.appUrl ?? window?.location?.href,
55
+ }));
52
56
  const idsToDelete = batch
53
57
  .map((e) => e.id)
54
58
  .filter((id) => id != null);
@@ -73,21 +77,24 @@ export async function flushBufferedEvents() {
73
77
  }
74
78
  }
75
79
  export function sendEvent(event) {
76
- // while draining, never send live—persist so flush preserves order
80
+ const enrichedEvent = {
81
+ ...event,
82
+ app_url: event?.app_url ?? window?.location?.href,
83
+ };
77
84
  if (isDraining || !isWebSocketOpen(webSocket)) {
78
- saveEventToIDB(event);
85
+ saveEventToIDB(enrichedEvent);
79
86
  return;
80
87
  }
81
88
  const msg = JSON.stringify({
82
89
  type: "event",
83
- event,
90
+ event: enrichedEvent,
84
91
  mapUuid: window.sfMapUuid,
85
92
  });
86
93
  try {
87
94
  webSocket.send(msg);
88
95
  }
89
96
  catch (err) {
90
- saveEventToIDB(event);
97
+ saveEventToIDB(enrichedEvent);
91
98
  }
92
99
  }
93
100
  export function initializeWebSocket(backendApi, apiKey, sessionId) {
@@ -129,7 +136,10 @@ export function sendMessage(message) {
129
136
  if (!("sessionId" in message)) {
130
137
  message.sessionId = getOrSetSessionId();
131
138
  }
132
- const msg = JSON.stringify(message);
139
+ const msg = JSON.stringify({
140
+ ...message,
141
+ app_url: message?.app_url ?? window?.location?.href,
142
+ });
133
143
  if (isWebSocketOpen(webSocket)) {
134
144
  try {
135
145
  webSocket.send(msg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailfish-ai/recorder",
3
- "version": "1.7.49",
3
+ "version": "1.8.0",
4
4
  "publishPublicly": true,
5
5
  "main": "dist/sailfish-recorder.umd.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -29,19 +29,14 @@
29
29
  "@sailfish-rrweb/types": "0.5.2",
30
30
  "async-mutex": "^0.5.0",
31
31
  "idb": "^8.0.3",
32
- "react-zendesk": "^0.1.13",
33
32
  "reconnecting-websocket": "^4.4.0",
34
33
  "source-map-js": "^1.2.1",
35
- "uuid": "^10.0.0",
36
- "vite": "^6.2.0",
37
- "vite-tsconfig-paths": "^4.3.2"
34
+ "uuid": "^10.0.0"
38
35
  },
39
36
  "devDependencies": {
40
37
  "@rollup/plugin-terser": "^0.4.4",
41
38
  "@types/jest": "^30.0.0",
42
39
  "@types/node": "^20.19.10",
43
- "@types/react": "^19.1.8",
44
- "@types/react-dom": "^19.1.6",
45
40
  "@types/uuid": "^10.0.0",
46
41
  "fake-indexeddb": "^6.0.1",
47
42
  "jest": "^30.0.4",
@@ -49,13 +44,13 @@
49
44
  "jest-localstorage-mock": "^2.4.26",
50
45
  "jest-transform-stub": "^2.0.0",
51
46
  "jsdom": "^25.0.0",
52
- "react": "^19.1.0",
53
- "react-dom": "^19.1.0",
54
47
  "rollup-plugin-dts": "^6.1.1",
55
48
  "rollup-plugin-visualizer": "^5.12.0",
56
49
  "ts-jest": "^29.4.0",
57
50
  "typescript": "^5.0.0",
51
+ "vite": "^6.2.0",
58
52
  "vite-plugin-compression": "^0.5.1",
53
+ "vite-tsconfig-paths": "^4.3.2",
59
54
  "vitest": "^3.0.8"
60
55
  }
61
56
  }