@replayio-app-building/netlify-recorder 0.2.0 → 0.3.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.
- package/README.md +20 -26
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ const handler: Handler = async (event) => {
|
|
|
66
66
|
export { handler };
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
That's it for capturing. The `remoteCallbacks(url)` helper sends the captured blob data to the Netlify Recorder service, which uploads it to blob storage and stores the request metadata. The response includes an `X-Replay-Request-Id` header with the request ID managed by the service.
|
|
69
|
+
That's it for capturing. The `remoteCallbacks(url)` helper sends the captured blob data to the Netlify Recorder service's `/api/store-request` endpoint, which uploads it to blob storage and stores the request metadata. The response includes an `X-Replay-Request-Id` header with the request ID managed by the service.
|
|
70
70
|
|
|
71
71
|
### 2. Create recordings
|
|
72
72
|
|
|
@@ -74,40 +74,21 @@ When you want to turn a captured request into a Replay recording, POST to the se
|
|
|
74
74
|
|
|
75
75
|
```typescript
|
|
76
76
|
const response = await fetch(
|
|
77
|
-
`${RECORDER_URL}
|
|
78
|
-
{
|
|
79
|
-
method: "POST",
|
|
80
|
-
headers: { "Content-Type": "application/json" },
|
|
81
|
-
body: JSON.stringify({ requestId }),
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
The service looks up the stored blob data, dispatches the work to a pool container, and creates the recording. You can check the recording status via the service's Requests page, or provide a webhook to be notified on completion.
|
|
87
|
-
|
|
88
|
-
### 3. (Optional) Get notified when recordings complete
|
|
89
|
-
|
|
90
|
-
If you want to be notified when a recording finishes, call the blob endpoint directly with a `webhookUrl`:
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
await fetch(
|
|
94
|
-
`${RECORDER_URL}/.netlify/functions/create-recording-from-blob-background`,
|
|
77
|
+
`${RECORDER_URL}/api/create-recording`,
|
|
95
78
|
{
|
|
96
79
|
method: "POST",
|
|
97
80
|
headers: { "Content-Type": "application/json" },
|
|
98
81
|
body: JSON.stringify({
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
commitSha: "a1b2c3d4...",
|
|
102
|
-
branchName: "main",
|
|
103
|
-
repositoryUrl: "https://github.com/your-org/your-repo",
|
|
104
|
-
webhookUrl: "https://your-app.netlify.app/.netlify/functions/on-recording-complete",
|
|
82
|
+
requestId,
|
|
83
|
+
webhookUrl: "https://your-app.netlify.app/api/on-recording-complete", // optional
|
|
105
84
|
}),
|
|
106
85
|
}
|
|
107
86
|
);
|
|
108
87
|
```
|
|
109
88
|
|
|
110
|
-
|
|
89
|
+
The service looks up the stored blob data, dispatches the work to a pool container, and creates the recording.
|
|
90
|
+
|
|
91
|
+
If `webhookUrl` is provided, the service will POST the result to that URL when the recording completes (or fails):
|
|
111
92
|
|
|
112
93
|
On success:
|
|
113
94
|
```json
|
|
@@ -119,6 +100,19 @@ On failure:
|
|
|
119
100
|
{ "status": "failed", "error": "Error message" }
|
|
120
101
|
```
|
|
121
102
|
|
|
103
|
+
### 3. Check recording status
|
|
104
|
+
|
|
105
|
+
You can poll the recording status at any time:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
const res = await fetch(
|
|
109
|
+
`${RECORDER_URL}/api/get-request?requestId=${requestId}`
|
|
110
|
+
);
|
|
111
|
+
const { status, recordingId } = await res.json();
|
|
112
|
+
// status: "captured" | "processing" | "recorded" | "failed"
|
|
113
|
+
// recordingId: string | null
|
|
114
|
+
```
|
|
115
|
+
|
|
122
116
|
---
|
|
123
117
|
|
|
124
118
|
## Option B: Self-Hosted
|
package/dist/index.d.ts
CHANGED
|
@@ -124,8 +124,8 @@ declare function finishRequest(requestContext: RequestContext, callbacks: Finish
|
|
|
124
124
|
* to set up its own blob storage or database tables.
|
|
125
125
|
*
|
|
126
126
|
* The callbacks upload blob data and store request metadata via the
|
|
127
|
-
* service's
|
|
128
|
-
* and database insertion.
|
|
127
|
+
* service's `/api/store-request` endpoint, which handles UploadThing
|
|
128
|
+
* storage and database insertion.
|
|
129
129
|
*
|
|
130
130
|
* @param serviceUrl - Base URL of the Netlify Recorder service
|
|
131
131
|
* (e.g. "https://netlify-recorder-bm4wmw.netlify.app")
|
package/dist/index.js
CHANGED