@sailfish-ai/recorder 1.7.49 → 1.7.50
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 +3 -1
- 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/dist/types/utils.d.ts +1 -0
- package/dist/utils.js +6 -0
- package/dist/websocket.js +15 -6
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -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
|
@@ -48,7 +48,10 @@ export async function flushBufferedEvents() {
|
|
|
48
48
|
for (const batch of idbBatches) {
|
|
49
49
|
if (!isWebSocketOpen(webSocket))
|
|
50
50
|
break;
|
|
51
|
-
const eventsToSend = batch.map((e) =>
|
|
51
|
+
const eventsToSend = batch.map((e) => ({
|
|
52
|
+
...e.data,
|
|
53
|
+
appUrl: e.data?.appUrl ?? window?.location?.href,
|
|
54
|
+
}));
|
|
52
55
|
const idsToDelete = batch
|
|
53
56
|
.map((e) => e.id)
|
|
54
57
|
.filter((id) => id != null);
|
|
@@ -73,21 +76,24 @@ export async function flushBufferedEvents() {
|
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
export function sendEvent(event) {
|
|
76
|
-
|
|
79
|
+
const enrichedEvent = {
|
|
80
|
+
...event,
|
|
81
|
+
app_url: event?.app_url ?? window?.location?.href,
|
|
82
|
+
};
|
|
77
83
|
if (isDraining || !isWebSocketOpen(webSocket)) {
|
|
78
|
-
saveEventToIDB(
|
|
84
|
+
saveEventToIDB(enrichedEvent);
|
|
79
85
|
return;
|
|
80
86
|
}
|
|
81
87
|
const msg = JSON.stringify({
|
|
82
88
|
type: "event",
|
|
83
|
-
event,
|
|
89
|
+
event: enrichedEvent,
|
|
84
90
|
mapUuid: window.sfMapUuid,
|
|
85
91
|
});
|
|
86
92
|
try {
|
|
87
93
|
webSocket.send(msg);
|
|
88
94
|
}
|
|
89
95
|
catch (err) {
|
|
90
|
-
saveEventToIDB(
|
|
96
|
+
saveEventToIDB(enrichedEvent);
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
99
|
export function initializeWebSocket(backendApi, apiKey, sessionId) {
|
|
@@ -129,7 +135,10 @@ export function sendMessage(message) {
|
|
|
129
135
|
if (!("sessionId" in message)) {
|
|
130
136
|
message.sessionId = getOrSetSessionId();
|
|
131
137
|
}
|
|
132
|
-
const msg = JSON.stringify(
|
|
138
|
+
const msg = JSON.stringify({
|
|
139
|
+
...message,
|
|
140
|
+
app_url: message?.app_url ?? window?.location?.href,
|
|
141
|
+
});
|
|
133
142
|
if (isWebSocketOpen(webSocket)) {
|
|
134
143
|
try {
|
|
135
144
|
webSocket.send(msg);
|