@base44-preview/sdk 0.8.17-pr.74.aa2810d → 0.8.17-pr.75.4ddbc56
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/client.js +0 -2
- package/dist/client.types.d.ts +0 -3
- package/dist/modules/analytics.js +1 -0
- package/dist/modules/types.d.ts +0 -1
- package/dist/modules/types.js +0 -1
- package/package.json +1 -3
- package/dist/modules/recording.d.ts +0 -8
- package/dist/modules/recording.js +0 -266
- package/dist/modules/recording.types.d.ts +0 -118
- package/dist/modules/recording.types.js +0 -1
package/dist/client.js
CHANGED
|
@@ -11,7 +11,6 @@ import { createAppLogsModule } from "./modules/app-logs.js";
|
|
|
11
11
|
import { createUsersModule } from "./modules/users.js";
|
|
12
12
|
import { RoomsSocket } from "./utils/socket-utils.js";
|
|
13
13
|
import { createAnalyticsModule } from "./modules/analytics.js";
|
|
14
|
-
import { createRecordingModule } from "./modules/recording.js";
|
|
15
14
|
/**
|
|
16
15
|
* Creates a Base44 client.
|
|
17
16
|
*
|
|
@@ -128,7 +127,6 @@ export function createClient(config) {
|
|
|
128
127
|
appId,
|
|
129
128
|
userAuthModule,
|
|
130
129
|
}),
|
|
131
|
-
recording: createRecordingModule(),
|
|
132
130
|
cleanup: () => {
|
|
133
131
|
userModules.analytics.cleanup();
|
|
134
132
|
if (socket) {
|
package/dist/client.types.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import type { FunctionsModule } from "./modules/functions.types.js";
|
|
|
7
7
|
import type { AgentsModule } from "./modules/agents.types.js";
|
|
8
8
|
import type { AppLogsModule } from "./modules/app-logs.types.js";
|
|
9
9
|
import type { AnalyticsModule } from "./modules/analytics.types.js";
|
|
10
|
-
import type { RecordingModule } from "./modules/recording.types.js";
|
|
11
10
|
/**
|
|
12
11
|
* Options for creating a Base44 client.
|
|
13
12
|
*/
|
|
@@ -86,8 +85,6 @@ export interface Base44Client {
|
|
|
86
85
|
appLogs: AppLogsModule;
|
|
87
86
|
/** {@link AnalyticsModule | Analytics module} for tracking app usage. */
|
|
88
87
|
analytics: AnalyticsModule;
|
|
89
|
-
/** {@link RecordingModule | Recording module} for capturing debug sessions. */
|
|
90
|
-
recording: RecordingModule;
|
|
91
88
|
/** Cleanup function to disconnect WebSocket connections. Call when you're done with the client. */
|
|
92
89
|
cleanup: () => void;
|
|
93
90
|
/**
|
|
@@ -166,6 +166,7 @@ function startHeartBeatProcessor(track) {
|
|
|
166
166
|
return () => { };
|
|
167
167
|
}
|
|
168
168
|
analyticsSharedState.isHeartBeatProcessing = true;
|
|
169
|
+
track({ eventName: USER_HEARTBEAT_EVENT_NAME });
|
|
169
170
|
const interval = setInterval(() => {
|
|
170
171
|
track({ eventName: USER_HEARTBEAT_EVENT_NAME });
|
|
171
172
|
}, analyticsSharedState.config.heartBeatInterval);
|
package/dist/modules/types.d.ts
CHANGED
package/dist/modules/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/sdk",
|
|
3
|
-
"version": "0.8.17-pr.
|
|
3
|
+
"version": "0.8.17-pr.75.4ddbc56",
|
|
4
4
|
"description": "JavaScript SDK for Base44 API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,9 +24,7 @@
|
|
|
24
24
|
"create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@rrweb/rrweb-plugin-console-record": "^2.0.0-alpha.18",
|
|
28
27
|
"axios": "^1.6.2",
|
|
29
|
-
"rrweb": "^2.0.0-alpha.18",
|
|
30
28
|
"socket.io-client": "^4.7.5",
|
|
31
29
|
"uuid": "^13.0.0"
|
|
32
30
|
},
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { RecordingModule } from "./recording.types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Creates the recording module for the Base44 SDK.
|
|
4
|
-
*
|
|
5
|
-
* @returns Recording module with methods for capturing debug sessions
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare function createRecordingModule(): RecordingModule;
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { record, IncrementalSource, MouseInteractions, } from "rrweb";
|
|
2
|
-
import { getRecordConsolePlugin } from "@rrweb/rrweb-plugin-console-record";
|
|
3
|
-
import { generateUuid } from "../utils/common.js";
|
|
4
|
-
const state = {
|
|
5
|
-
isRecording: false,
|
|
6
|
-
sessionId: null,
|
|
7
|
-
startTime: null,
|
|
8
|
-
events: [],
|
|
9
|
-
stopFn: null,
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Creates the recording module for the Base44 SDK.
|
|
13
|
-
*
|
|
14
|
-
* @returns Recording module with methods for capturing debug sessions
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export function createRecordingModule() {
|
|
18
|
-
return {
|
|
19
|
-
start() {
|
|
20
|
-
if (state.isRecording) {
|
|
21
|
-
throw new Error("Recording is already in progress");
|
|
22
|
-
}
|
|
23
|
-
if (typeof window === "undefined") {
|
|
24
|
-
throw new Error("Recording is only available in browser environments");
|
|
25
|
-
}
|
|
26
|
-
// Reset state
|
|
27
|
-
state.isRecording = true;
|
|
28
|
-
state.sessionId = generateUuid();
|
|
29
|
-
state.startTime = new Date().toISOString();
|
|
30
|
-
state.events = [];
|
|
31
|
-
const stopFn = record({
|
|
32
|
-
emit: (event) => {
|
|
33
|
-
state.events.push(event);
|
|
34
|
-
},
|
|
35
|
-
plugins: [
|
|
36
|
-
getRecordConsolePlugin({
|
|
37
|
-
level: ["log", "warn", "error", "info", "debug"],
|
|
38
|
-
lengthThreshold: 10000,
|
|
39
|
-
stringifyOptions: {
|
|
40
|
-
stringLengthLimit: 5000,
|
|
41
|
-
numOfKeysLimit: 100,
|
|
42
|
-
depthOfLimit: 5,
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
],
|
|
46
|
-
});
|
|
47
|
-
state.stopFn = stopFn !== null && stopFn !== void 0 ? stopFn : null;
|
|
48
|
-
},
|
|
49
|
-
stop() {
|
|
50
|
-
if (!state.isRecording) {
|
|
51
|
-
throw new Error("No recording is in progress");
|
|
52
|
-
}
|
|
53
|
-
// Stop rrweb recording
|
|
54
|
-
if (state.stopFn) {
|
|
55
|
-
state.stopFn();
|
|
56
|
-
state.stopFn = null;
|
|
57
|
-
}
|
|
58
|
-
const endTime = new Date().toISOString();
|
|
59
|
-
const startTime = state.startTime;
|
|
60
|
-
const duration = new Date(endTime).getTime() - new Date(startTime).getTime();
|
|
61
|
-
// Extract data from events
|
|
62
|
-
const consoleEntries = extractConsoleEntries(state.events);
|
|
63
|
-
const userActions = extractUserActions(state.events);
|
|
64
|
-
const report = {
|
|
65
|
-
sessionId: state.sessionId,
|
|
66
|
-
startTime,
|
|
67
|
-
endTime,
|
|
68
|
-
duration,
|
|
69
|
-
console: consoleEntries,
|
|
70
|
-
userActions,
|
|
71
|
-
};
|
|
72
|
-
// Reset state
|
|
73
|
-
state.isRecording = false;
|
|
74
|
-
state.sessionId = null;
|
|
75
|
-
state.startTime = null;
|
|
76
|
-
state.events = [];
|
|
77
|
-
return report;
|
|
78
|
-
},
|
|
79
|
-
isRecording() {
|
|
80
|
-
return state.isRecording;
|
|
81
|
-
},
|
|
82
|
-
toText(report) {
|
|
83
|
-
const lines = [
|
|
84
|
-
"## Debug Session Report",
|
|
85
|
-
`Session ID: ${report.sessionId}`,
|
|
86
|
-
`Duration: ${report.duration}ms`,
|
|
87
|
-
`Recorded: ${report.startTime} to ${report.endTime}`,
|
|
88
|
-
"",
|
|
89
|
-
`### User Actions (${report.userActions.length} actions)`,
|
|
90
|
-
];
|
|
91
|
-
if (report.userActions.length === 0) {
|
|
92
|
-
lines.push("No user actions captured.");
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
for (const action of report.userActions) {
|
|
96
|
-
const timestamp = new Date(action.timestamp).toISOString();
|
|
97
|
-
const valueStr = action.value ? ` = "${action.value}"` : "";
|
|
98
|
-
lines.push(`[${timestamp}] ${action.type}: ${action.target}${valueStr}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
lines.push("");
|
|
102
|
-
lines.push(`### Console Output (${report.console.length} entries)`);
|
|
103
|
-
if (report.console.length === 0) {
|
|
104
|
-
lines.push("No console output captured.");
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
for (const entry of report.console) {
|
|
108
|
-
const timestamp = new Date(entry.timestamp).toISOString();
|
|
109
|
-
lines.push(`[${timestamp}] [${entry.level.toUpperCase()}] ${entry.message}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return lines.join("\n");
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Extracts console entries from rrweb events.
|
|
118
|
-
*/
|
|
119
|
-
function extractConsoleEntries(events) {
|
|
120
|
-
var _a;
|
|
121
|
-
const consoleEntries = [];
|
|
122
|
-
for (const event of events) {
|
|
123
|
-
// rrweb plugin events have type 6
|
|
124
|
-
if (event.type === 6 && ((_a = event.data) === null || _a === void 0 ? void 0 : _a.plugin) === "rrweb/console@1") {
|
|
125
|
-
const payload = event.data.payload;
|
|
126
|
-
if (payload && payload.level && payload.payload) {
|
|
127
|
-
const message = stringifyConsolePayload(payload.payload);
|
|
128
|
-
consoleEntries.push({
|
|
129
|
-
level: payload.level,
|
|
130
|
-
message,
|
|
131
|
-
timestamp: event.timestamp,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return consoleEntries;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Converts console payload array to a readable string.
|
|
140
|
-
*/
|
|
141
|
-
function stringifyConsolePayload(payload) {
|
|
142
|
-
return payload
|
|
143
|
-
.map((item) => {
|
|
144
|
-
if (typeof item === "string") {
|
|
145
|
-
return item;
|
|
146
|
-
}
|
|
147
|
-
try {
|
|
148
|
-
return JSON.stringify(item);
|
|
149
|
-
}
|
|
150
|
-
catch (_a) {
|
|
151
|
-
return String(item);
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
|
-
.join(" ");
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Extracts user actions from rrweb events.
|
|
158
|
-
*/
|
|
159
|
-
function extractUserActions(events) {
|
|
160
|
-
const userActions = [];
|
|
161
|
-
// Build a map of node IDs to readable descriptions from the full snapshot
|
|
162
|
-
const nodeMap = buildNodeMap(events);
|
|
163
|
-
for (const event of events) {
|
|
164
|
-
// IncrementalSnapshot events have type 3
|
|
165
|
-
if (event.type !== 3 || !event.data)
|
|
166
|
-
continue;
|
|
167
|
-
const { source, type, id, text } = event.data;
|
|
168
|
-
// Mouse interactions
|
|
169
|
-
if (source === IncrementalSource.MouseInteraction && id !== undefined) {
|
|
170
|
-
const actionType = getMouseInteractionType(type);
|
|
171
|
-
if (actionType) {
|
|
172
|
-
userActions.push({
|
|
173
|
-
type: actionType,
|
|
174
|
-
target: nodeMap.get(id) || `element#${id}`,
|
|
175
|
-
timestamp: event.timestamp,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
// Input events
|
|
180
|
-
if (source === IncrementalSource.Input && id !== undefined) {
|
|
181
|
-
userActions.push({
|
|
182
|
-
type: "input",
|
|
183
|
-
target: nodeMap.get(id) || `input#${id}`,
|
|
184
|
-
value: text ? truncateString(text, 100) : undefined,
|
|
185
|
-
timestamp: event.timestamp,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return userActions;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Maps mouse interaction type number to readable action type.
|
|
193
|
-
*/
|
|
194
|
-
function getMouseInteractionType(type) {
|
|
195
|
-
switch (type) {
|
|
196
|
-
case MouseInteractions.Click:
|
|
197
|
-
return "click";
|
|
198
|
-
case MouseInteractions.DblClick:
|
|
199
|
-
return "dblclick";
|
|
200
|
-
default:
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Builds a map of node IDs to readable descriptions from the full snapshot.
|
|
206
|
-
*/
|
|
207
|
-
function buildNodeMap(events) {
|
|
208
|
-
var _a;
|
|
209
|
-
const nodeMap = new Map();
|
|
210
|
-
// Find the full snapshot (type 2)
|
|
211
|
-
const fullSnapshot = events.find((e) => e.type === 2);
|
|
212
|
-
if (!fullSnapshot)
|
|
213
|
-
return nodeMap;
|
|
214
|
-
// Recursively extract node info
|
|
215
|
-
const extractNodes = (node) => {
|
|
216
|
-
if (!node || typeof node !== "object")
|
|
217
|
-
return;
|
|
218
|
-
if (node.id !== undefined && node.tagName) {
|
|
219
|
-
const parts = [`<${node.tagName.toLowerCase()}`];
|
|
220
|
-
if (node.attributes) {
|
|
221
|
-
if (node.attributes.id) {
|
|
222
|
-
parts[0] += `#${node.attributes.id}`;
|
|
223
|
-
}
|
|
224
|
-
if (node.attributes.class) {
|
|
225
|
-
const firstClass = node.attributes.class.split(" ")[0];
|
|
226
|
-
if (firstClass)
|
|
227
|
-
parts[0] += `.${firstClass}`;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
parts[0] += ">";
|
|
231
|
-
// Add text content hint if available
|
|
232
|
-
if (node.childNodes) {
|
|
233
|
-
for (const child of node.childNodes) {
|
|
234
|
-
if (child.type === 3 && child.textContent) {
|
|
235
|
-
// Text node
|
|
236
|
-
const text = child.textContent.trim().slice(0, 30);
|
|
237
|
-
if (text) {
|
|
238
|
-
parts.push(`"${text}"`);
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
nodeMap.set(node.id, parts.join(" "));
|
|
245
|
-
}
|
|
246
|
-
// Recurse into children
|
|
247
|
-
if (node.childNodes) {
|
|
248
|
-
for (const child of node.childNodes) {
|
|
249
|
-
extractNodes(child);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
// Start from the snapshot data
|
|
254
|
-
if ((_a = fullSnapshot.data) === null || _a === void 0 ? void 0 : _a.node) {
|
|
255
|
-
extractNodes(fullSnapshot.data.node);
|
|
256
|
-
}
|
|
257
|
-
return nodeMap;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Truncates a string to a maximum length.
|
|
261
|
-
*/
|
|
262
|
-
function truncateString(str, maxLength) {
|
|
263
|
-
if (str.length <= maxLength)
|
|
264
|
-
return str;
|
|
265
|
-
return str.slice(0, maxLength - 3) + "...";
|
|
266
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A console log entry captured during recording.
|
|
3
|
-
*/
|
|
4
|
-
export interface ConsoleEntry {
|
|
5
|
-
/** The console method that was called. */
|
|
6
|
-
level: "log" | "warn" | "error" | "info" | "debug";
|
|
7
|
-
/** The logged message content. */
|
|
8
|
-
message: string;
|
|
9
|
-
/** Unix timestamp when the log occurred. */
|
|
10
|
-
timestamp: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A user action captured during recording.
|
|
14
|
-
*/
|
|
15
|
-
export interface UserAction {
|
|
16
|
-
/** The type of interaction. */
|
|
17
|
-
type: "click" | "dblclick" | "input";
|
|
18
|
-
/** Description of the target element. */
|
|
19
|
-
target: string;
|
|
20
|
-
/** Value entered (for input actions). */
|
|
21
|
-
value?: string;
|
|
22
|
-
/** Unix timestamp when the action occurred. */
|
|
23
|
-
timestamp: number;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Debug report containing captured session data.
|
|
27
|
-
*/
|
|
28
|
-
export interface DebugReport {
|
|
29
|
-
/** Unique session identifier. */
|
|
30
|
-
sessionId: string;
|
|
31
|
-
/** Recording start time (ISO 8601). */
|
|
32
|
-
startTime: string;
|
|
33
|
-
/** Recording end time (ISO 8601). */
|
|
34
|
-
endTime: string;
|
|
35
|
-
/** Duration in milliseconds. */
|
|
36
|
-
duration: number;
|
|
37
|
-
/** Captured console output. */
|
|
38
|
-
console: ConsoleEntry[];
|
|
39
|
-
/** Captured user actions (clicks, inputs, etc.). */
|
|
40
|
-
userActions: UserAction[];
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Recording module for capturing debug sessions.
|
|
44
|
-
*
|
|
45
|
-
* This module captures console output from the running app to help debug issues.
|
|
46
|
-
* It's designed to provide context for AI agents analyzing app problems.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* // Start recording
|
|
51
|
-
* base44.recording.start();
|
|
52
|
-
*
|
|
53
|
-
* // ... user reproduces the issue ...
|
|
54
|
-
*
|
|
55
|
-
* // Stop and get the report
|
|
56
|
-
* const report = base44.recording.stop();
|
|
57
|
-
* console.log(report.console); // All console output
|
|
58
|
-
*
|
|
59
|
-
* // Get text summary for LLM
|
|
60
|
-
* const summary = base44.recording.toText(report);
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export interface RecordingModule {
|
|
64
|
-
/**
|
|
65
|
-
* Starts a debug recording session.
|
|
66
|
-
*
|
|
67
|
-
* Captures console output until stopped.
|
|
68
|
-
* Only one recording can be active at a time.
|
|
69
|
-
*
|
|
70
|
-
* @throws {Error} If a recording is already in progress.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* base44.recording.start();
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
start(): void;
|
|
78
|
-
/**
|
|
79
|
-
* Stops the current recording and returns the captured data.
|
|
80
|
-
*
|
|
81
|
-
* @returns The debug report containing all captured console output.
|
|
82
|
-
* @throws {Error} If no recording is in progress.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const report = base44.recording.stop();
|
|
87
|
-
* console.log(`Captured ${report.console.length} console entries`);
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
stop(): DebugReport;
|
|
91
|
-
/**
|
|
92
|
-
* Checks if a recording is currently in progress.
|
|
93
|
-
*
|
|
94
|
-
* @returns True if recording, false otherwise.
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```typescript
|
|
98
|
-
* if (!base44.recording.isRecording()) {
|
|
99
|
-
* base44.recording.start();
|
|
100
|
-
* }
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
isRecording(): boolean;
|
|
104
|
-
/**
|
|
105
|
-
* Generates a text summary of a debug report for LLM consumption.
|
|
106
|
-
*
|
|
107
|
-
* @param report - The debug report to summarize.
|
|
108
|
-
* @returns A formatted text summary.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```typescript
|
|
112
|
-
* const report = base44.recording.stop();
|
|
113
|
-
* const summary = base44.recording.toText(report);
|
|
114
|
-
* // Send summary to your backend for LLM processing
|
|
115
|
-
* ```
|
|
116
|
-
*/
|
|
117
|
-
toText(report: DebugReport): string;
|
|
118
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|