@sailfish-ai/recorder 1.7.9 → 1.7.12-alpha5

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/recording.js CHANGED
@@ -3,8 +3,7 @@ import { getRecordConsolePlugin, } from "@sailfish-rrweb/rrweb-plugin-console-re
3
3
  // import { NetworkRecordOptions } from "@sailfish-rrweb/rrweb-plugin-network-record";
4
4
  import { EventType } from "@sailfish-rrweb/types";
5
5
  import { ZendeskAPI } from "react-zendesk";
6
- import { cacheEvents, sendRecordingEvents } from "./eventCache";
7
- import { initializeWebSocket } from "./websocket";
6
+ import { initializeWebSocket, sendEvent } from "./websocket";
8
7
  import { DomContentEventId, DomContentSource, Loading, Complete } from "./constants";
9
8
  const MASK_CLASS = "sailfishSanitize";
10
9
  const ZENDESK_ELEMENT_ID = "zendesk_chat";
@@ -40,13 +39,14 @@ export const getUrlAndStoredUuids = () => ({
40
39
  prev_page_visit_uuid: sessionStorage.getItem("prevPageVisitUUID"),
41
40
  href: location.origin + location.pathname,
42
41
  });
43
- export function initializeDomContentEvents() {
42
+ export function initializeDomContentEvents(sessionId) {
44
43
  document.addEventListener("readystatechange", () => {
45
44
  const timestamp = Date.now();
46
45
  const newEvent = {
47
46
  type: DomContentEventId,
48
47
  data: { source: 0, info: "" },
49
48
  timestamp,
49
+ sessionId,
50
50
  ...getUrlAndStoredUuids(),
51
51
  };
52
52
  switch (document.readyState) {
@@ -58,43 +58,51 @@ export function initializeDomContentEvents() {
58
58
  break;
59
59
  }
60
60
  if (newEvent.data.info)
61
- cacheEvents(newEvent);
61
+ sendEvent(newEvent);
62
62
  });
63
63
  document.addEventListener("DOMContentLoaded", () => {
64
- cacheEvents({
64
+ sendEvent({
65
65
  type: DomContentEventId,
66
66
  data: { source: DomContentSource.contentLoaded },
67
67
  timestamp: Date.now(),
68
+ sessionId,
68
69
  ...getUrlAndStoredUuids(),
69
70
  });
70
71
  });
71
72
  window.addEventListener("beforeunload", () => {
72
- cacheEvents({
73
+ sendEvent({
73
74
  type: DomContentEventId,
74
75
  data: { source: DomContentSource.beforeunload },
75
76
  timestamp: Date.now(),
77
+ sessionId,
76
78
  ...getUrlAndStoredUuids(),
77
79
  });
78
80
  });
79
81
  window.addEventListener("unload", () => {
80
- cacheEvents({
82
+ sendEvent({
81
83
  type: DomContentEventId,
82
84
  data: { source: DomContentSource.unload },
83
85
  timestamp: Date.now(),
86
+ sessionId,
84
87
  ...getUrlAndStoredUuids(),
85
88
  });
86
89
  });
87
90
  }
88
- export function initializeConsolePlugin(consoleRecordSettings) {
91
+ export function initializeConsolePlugin(consoleRecordSettings, sessionId) {
89
92
  const { name, observer } = getRecordConsolePlugin(consoleRecordSettings);
90
- observer((payload) => cacheEvents({
91
- type: EventType.Plugin,
92
- timestamp: Date.now(),
93
- data: {
94
- plugin: name,
95
- payload,
96
- },
97
- }), window, consoleRecordSettings);
93
+ observer((payload) => {
94
+ const eventData = {
95
+ type: EventType.Plugin,
96
+ timestamp: Date.now(),
97
+ data: {
98
+ plugin: name,
99
+ payload,
100
+ },
101
+ sessionId: sessionId,
102
+ ...getUrlAndStoredUuids(),
103
+ };
104
+ sendEvent(eventData);
105
+ }, window, consoleRecordSettings);
98
106
  }
99
107
  export async function initializeRecording(captureSettings, // TODO - Sibyl post-launch - replace type
100
108
  // networkRecordSettings: NetworkRecordOptions,
@@ -106,7 +114,7 @@ backendApi, apiKey, sessionId) {
106
114
  Object.assign(event, getUrlAndStoredUuids());
107
115
  // Attach sessionId to each event
108
116
  event.sessionId = sessionId;
109
- cacheEvents(event);
117
+ sendEvent(event);
110
118
  },
111
119
  maskInputOptions: { text: true }, // Fix the incorrect property name
112
120
  maskInputFn,
@@ -140,7 +148,6 @@ backendApi, apiKey, sessionId) {
140
148
  ZendeskAPI("messenger:on", "open", handleWidgetOpen);
141
149
  ZendeskAPI("messenger:on", "close", handleWidgetClose);
142
150
  ZendeskAPI("messenger:on", "unreadMessages", handleUnreadMessages);
143
- setInterval(() => sendRecordingEvents(webSocket), 10000);
144
151
  }
145
152
  catch (error) {
146
153
  console.error("Error importing plugins!", error);