@sailfish-ai/recorder 1.0.0-alpha-1

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.
@@ -0,0 +1,4 @@
1
+ import ReconnectingWebSocket from "reconnecting-websocket";
2
+ export declare function cacheEvents(event: any): void;
3
+ export declare function sendCachedEvents(webSocket: ReconnectingWebSocket): void;
4
+ export declare function sendRecordingEvents(webSocket: ReconnectingWebSocket, sessionId: string): void;
@@ -0,0 +1,4 @@
1
+ import { CaptureSettingsResponse, GraphQLResponse, StartSessionResponse } from "./types";
2
+ export declare function sendGraphQLRequest<T>(operationName: string, query: string, variables: object): Promise<GraphQLResponse<T>>;
3
+ export declare function fetchCaptureSettings(apiKey: string, backendApi: string): Promise<GraphQLResponse<CaptureSettingsResponse>>;
4
+ export declare function startRecordingSession(apiKey: string, recordingId: string, backendApi: string): Promise<GraphQLResponse<StartSessionResponse>>;
@@ -0,0 +1,16 @@
1
+ import { LogRecordOptions } from "@sailfish-rrweb/rrweb-plugin-console-record";
2
+ import { NetworkRecordOptions } from "@sailfish-rrweb/rrweb-plugin-network-record";
3
+ import { CaptureSettings } from "./types";
4
+ export declare const DEFAULT_DOMAINS_TO_IGNORE: string[];
5
+ export declare const DEFAULT_CAPTURE_SETTINGS: CaptureSettings;
6
+ export declare const DEFAULT_CONSOLE_RECORDING_SETTINGS: LogRecordOptions;
7
+ export declare const DEFAULT_NETWORK_CAPTURE_SETTINGS: NetworkRecordOptions;
8
+ export declare function startRecording({ apiKey, backendApi, }: {
9
+ apiKey: string;
10
+ backendApi: string;
11
+ }): Promise<void>;
12
+ export * from "./eventCache";
13
+ export * from "./graphql";
14
+ export * from "./recording";
15
+ export * from "./types";
16
+ export * from "./websocket";
@@ -0,0 +1,4 @@
1
+ import { LogRecordOptions } from "@sailfish-rrweb/rrweb-plugin-console-record";
2
+ import { NetworkRecordOptions } from "@sailfish-rrweb/rrweb-plugin-network-record";
3
+ export declare function initializeRecording(captureSettings: any, // TODO - Sibyl launch - replace type
4
+ consoleRecordSettings: LogRecordOptions, networkRecordSettings: NetworkRecordOptions, backendApi: string, apiKey: string, sessionId: string): Promise<void>;
@@ -0,0 +1,53 @@
1
+ export interface CaptureSettings {
2
+ recordCanvas: boolean;
3
+ recordCrossOriginIframes: boolean;
4
+ collectFonts: boolean;
5
+ inlineImages: boolean;
6
+ recordPassword: boolean;
7
+ recordRealName: boolean;
8
+ recordCreditCardInfo: boolean;
9
+ recordSsn: boolean;
10
+ recordDob: boolean;
11
+ sampling: object;
12
+ }
13
+ export interface ConsoleRecordSettings {
14
+ level: string[];
15
+ lengthThreshold: number;
16
+ stringifyOptions: {
17
+ stringLengthLimit: number;
18
+ numOfKeysLimit: number;
19
+ depthOfLimit: number;
20
+ };
21
+ logger: Console;
22
+ }
23
+ export interface NetworkRecordSettings {
24
+ initiatorTypes: string[];
25
+ ignoreRequestFn: (request: Request) => boolean;
26
+ recordHeaders: boolean;
27
+ ignoreHeaders: {
28
+ request: string[];
29
+ response: string[];
30
+ };
31
+ ignoreBodyParts: {
32
+ request: string[];
33
+ response: string[];
34
+ };
35
+ recordBody: boolean;
36
+ recordInitialRequests: boolean;
37
+ }
38
+ export interface StartRecordingOptions {
39
+ apiKey: string;
40
+ backendApi: string;
41
+ }
42
+ export interface GraphQLResponse<T> {
43
+ data?: T;
44
+ errors?: any;
45
+ }
46
+ export interface CaptureSettingsResponse {
47
+ captureSettingsFromApiKey: CaptureSettings;
48
+ }
49
+ export interface StartSessionResponse {
50
+ startRecordingSession: {
51
+ id: string;
52
+ };
53
+ }
@@ -0,0 +1,2 @@
1
+ import ReconnectingWebSocket from "reconnecting-websocket";
2
+ export declare function initializeWebSocket(backendApi: string, apiKey: string, sessionId: string): ReconnectingWebSocket;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ import ReconnectingWebSocket from "reconnecting-websocket";
2
+ import { sendCachedEvents } from "./eventCache";
3
+ export function initializeWebSocket(backendApi, apiKey, sessionId) {
4
+ const wsHost = getWebSocketHost(backendApi);
5
+ const wsScheme = window.location.protocol === "https:" ? "wss" : "ws";
6
+ const wsUrl = `${wsScheme}://${wsHost}/ws/notify/?apiKey=${apiKey}&sessionId=${sessionId}`;
7
+ const options = {
8
+ connectionTimeout: 5000,
9
+ maxRetries: 10,
10
+ };
11
+ const webSocket = new ReconnectingWebSocket(wsUrl, [], options);
12
+ webSocket.addEventListener("open", () => {
13
+ sendCachedEvents(webSocket);
14
+ });
15
+ webSocket.addEventListener("close", (event) => {
16
+ console.log("WebSocket closed:", event);
17
+ if (event.wasClean) {
18
+ console.log(`Closed cleanly, code=${event.code}, reason=${event.reason}`);
19
+ }
20
+ else {
21
+ console.log("Connection died");
22
+ }
23
+ });
24
+ webSocket.addEventListener("error", (error) => {
25
+ console.error("WebSocket error:", error);
26
+ });
27
+ return webSocket;
28
+ }
29
+ function getWebSocketHost(url) {
30
+ const parser = document.createElement("a");
31
+ parser.href = url;
32
+ return `${parser.hostname}${parser.port ? `:${parser.port}` : ""}`;
33
+ }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@sailfish-ai/recorder",
3
+ "version": "1.0.0-alpha-1",
4
+ "publishPublicly": true,
5
+ "main": "dist/sailfish-recorder.umd.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "build": "vite build && tsc --project tsconfig.json",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest watch",
12
+ "check-types": "tsc --noEmit",
13
+ "prepublish": "npm run check-types && npm run build",
14
+ "artifactregistry-login": "npx google-artifactregistry-auth"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "@sailfish-rrweb/record": "^0.1.1-sailfish",
21
+ "@sailfish-rrweb/rrweb": "^0.1.1-sailfish",
22
+ "@sailfish-rrweb/rrweb-plugin-console-record": "^0.1.1-sailfish",
23
+ "@sailfish-rrweb/rrweb-plugin-network-record": "^0.1.1-sailfish",
24
+ "@sailfish-rrweb/rrweb-snapshot": "^0.1.1-sailfish",
25
+ "@sailfish-rrweb/types": "^0.1.1-sailfish",
26
+ "@vitejs/plugin-react": "^4.3.1",
27
+ "@vitejs/plugin-vue": "^5.0.5",
28
+ "reconnecting-websocket": "^4.4.0",
29
+ "uuid": "^10.0.0",
30
+ "vite": "^5.3.4",
31
+ "vite-tsconfig-paths": "^4.3.2"
32
+ },
33
+ "devDependencies": {
34
+ "@types/jest": "^29.5.12",
35
+ "@types/node": "^18.0.0",
36
+ "@types/uuid": "^10.0.0",
37
+ "jest": "^29.7.0",
38
+ "jest-transform-stub": "^2.0.0",
39
+ "ts-jest": "^29.2.3",
40
+ "typescript": "^5.0.0",
41
+ "vue": "^3.4.33"
42
+ }
43
+ }