@deepsure/page-replay-sdk 1.0.0 → 1.0.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.
- package/README.md +93 -94
- package/dist/index.esm.js +15 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +15 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Page Replay JavaScript SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A JavaScript SDK for page session recording and replay, supporting automatic session management, incremental uploads, and data masking.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
### CDN
|
|
7
|
+
### CDN
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
10
|
<script src="https://cdn.yourplatform.com/sdk/v1/recorder.js"></script>
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
### NPM
|
|
13
|
+
### NPM
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm install @
|
|
16
|
+
npm install @deepsure/page-replay-sdk
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Quick Start
|
|
20
20
|
|
|
21
|
-
###
|
|
21
|
+
### Basic Usage
|
|
22
22
|
|
|
23
23
|
```html
|
|
24
24
|
<script src="https://cdn.yourplatform.com/sdk/v1/recorder.js"></script>
|
|
25
25
|
<script>
|
|
26
|
-
|
|
26
|
+
PageRecorder.init({
|
|
27
27
|
apiKey: 'your_api_key',
|
|
28
28
|
projectId: 'proj_12345',
|
|
29
29
|
autoStart: true
|
|
@@ -31,45 +31,45 @@ npm install @finance-recorder/sdk
|
|
|
31
31
|
</script>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
###
|
|
34
|
+
### Full Configuration
|
|
35
35
|
|
|
36
36
|
```javascript
|
|
37
|
-
import
|
|
37
|
+
import PageRecorder from '@deepsure/page-replay-sdk';
|
|
38
38
|
|
|
39
|
-
await
|
|
40
|
-
//
|
|
41
|
-
apiKey: 'your_api_key', // API
|
|
42
|
-
projectId: 'proj_12345', //
|
|
39
|
+
await PageRecorder.init({
|
|
40
|
+
// Required configuration
|
|
41
|
+
apiKey: 'your_api_key', // API key
|
|
42
|
+
projectId: 'proj_12345', // Project ID
|
|
43
43
|
|
|
44
|
-
//
|
|
45
|
-
apiBaseUrl: 'https://api.yourplatform.com', // API
|
|
46
|
-
autoStart:
|
|
47
|
-
chunkSize: 100, //
|
|
48
|
-
uploadInterval: 30000, //
|
|
44
|
+
// Optional configuration
|
|
45
|
+
apiBaseUrl: 'https://api.yourplatform.com', // API base URL
|
|
46
|
+
autoStart: false, // Auto-start recording
|
|
47
|
+
chunkSize: 100, // Batch upload size
|
|
48
|
+
uploadInterval: 30000, // Upload interval (milliseconds)
|
|
49
49
|
|
|
50
|
-
//
|
|
50
|
+
// Privacy configuration
|
|
51
51
|
privacy: {
|
|
52
|
-
maskAllInputs: false, //
|
|
52
|
+
maskAllInputs: false, // Mask all inputs
|
|
53
53
|
maskInputOptions: {
|
|
54
|
-
idCard: true, //
|
|
55
|
-
phone: true, //
|
|
56
|
-
bankCard: true, //
|
|
54
|
+
idCard: true, // Mask ID card numbers
|
|
55
|
+
phone: true, // Mask phone numbers
|
|
56
|
+
bankCard: true, // Mask bank card numbers
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
|
|
60
|
-
//
|
|
60
|
+
// Business metadata
|
|
61
61
|
metadata: {
|
|
62
|
-
productType: '
|
|
63
|
-
quoteId: 'quote_789', //
|
|
64
|
-
userId: 'user_123' //
|
|
62
|
+
productType: 'Auto Insurance', // Product type
|
|
63
|
+
quoteId: 'quote_789', // Quote ID
|
|
64
|
+
userId: 'user_123' // User ID
|
|
65
65
|
},
|
|
66
66
|
|
|
67
|
-
//
|
|
67
|
+
// Callback functions
|
|
68
68
|
onSessionCreated: (session) => {
|
|
69
|
-
console.log('
|
|
69
|
+
console.log('Session created:', session.sessionId);
|
|
70
70
|
},
|
|
71
71
|
onUploadProgress: (progress) => {
|
|
72
|
-
console.log('
|
|
72
|
+
console.log('Upload progress:', progress);
|
|
73
73
|
},
|
|
74
74
|
onError: (message, error) => {
|
|
75
75
|
console.error(message, error);
|
|
@@ -77,66 +77,66 @@ await FinanceRecorder.init({
|
|
|
77
77
|
});
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
## API
|
|
80
|
+
## API Reference
|
|
81
81
|
|
|
82
82
|
### init(config)
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
Initialize the recorder.
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
- `apiKey` (string,
|
|
88
|
-
- `projectId` (string,
|
|
89
|
-
- `apiBaseUrl` (string) - API
|
|
90
|
-
- `autoStart` (boolean) -
|
|
91
|
-
- `privacy` (object) -
|
|
92
|
-
- `metadata` (object) -
|
|
86
|
+
**Parameters:**
|
|
87
|
+
- `apiKey` (string, required) - API key
|
|
88
|
+
- `projectId` (string, required) - Project ID
|
|
89
|
+
- `apiBaseUrl` (string) - API base URL
|
|
90
|
+
- `autoStart` (boolean) - Whether to auto-start recording, defaults to true
|
|
91
|
+
- `privacy` (object) - Privacy configuration
|
|
92
|
+
- `metadata` (object) - Business metadata
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
**Returns:** Promise<PageRecorder>
|
|
95
95
|
|
|
96
96
|
### start(customMetadata?)
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
Manually start recording.
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
- `customMetadata` (object,
|
|
100
|
+
**Parameters:**
|
|
101
|
+
- `customMetadata` (object, optional) - Custom metadata
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
**Returns:** Promise<void>
|
|
104
104
|
|
|
105
105
|
### stop()
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
Stop recording and upload remaining data.
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
**Returns:** Promise<string> - Session ID
|
|
110
110
|
|
|
111
111
|
### setMetadata(metadata)
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
Update session metadata.
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
- `metadata` (object) -
|
|
115
|
+
**Parameters:**
|
|
116
|
+
- `metadata` (object) - Metadata to add/update
|
|
117
117
|
|
|
118
118
|
### getSessionId()
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
Get the current session ID.
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
**Returns:** string | null
|
|
123
123
|
|
|
124
124
|
### isRecording()
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
Check if recording is in progress.
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
**Returns:** boolean
|
|
129
129
|
|
|
130
|
-
##
|
|
130
|
+
## Use Cases
|
|
131
131
|
|
|
132
|
-
###
|
|
132
|
+
### Use Case 1: Insurance Application Recording
|
|
133
133
|
|
|
134
134
|
```javascript
|
|
135
|
-
|
|
135
|
+
PageRecorder.init({
|
|
136
136
|
apiKey: 'your_api_key',
|
|
137
137
|
projectId: 'proj_insurance',
|
|
138
138
|
metadata: {
|
|
139
|
-
productType: '
|
|
139
|
+
productType: 'Auto Insurance',
|
|
140
140
|
policyNumber: 'POL-2025-001',
|
|
141
141
|
applicantId: 'user_123'
|
|
142
142
|
},
|
|
@@ -150,35 +150,35 @@ FinanceRecorder.init({
|
|
|
150
150
|
});
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
###
|
|
153
|
+
### Use Case 2: Customer Support Recording
|
|
154
154
|
|
|
155
155
|
```javascript
|
|
156
|
-
//
|
|
156
|
+
// Record only during customer support
|
|
157
157
|
const startAssist = async () => {
|
|
158
|
-
await
|
|
158
|
+
await PageRecorder.init({
|
|
159
159
|
apiKey: 'your_api_key',
|
|
160
160
|
projectId: 'proj_support',
|
|
161
161
|
autoStart: false
|
|
162
162
|
});
|
|
163
163
|
|
|
164
|
-
//
|
|
165
|
-
await
|
|
164
|
+
// Start recording after user consent
|
|
165
|
+
await PageRecorder.start({
|
|
166
166
|
supportTicketId: 'TICKET-123',
|
|
167
167
|
agentId: 'agent_456'
|
|
168
168
|
});
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
const endAssist = async () => {
|
|
172
|
-
const sessionId = await
|
|
173
|
-
console.log('
|
|
172
|
+
const sessionId = await PageRecorder.stop();
|
|
173
|
+
console.log('Session saved:', sessionId);
|
|
174
174
|
};
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
###
|
|
177
|
+
### Use Case 3: Dynamic Metadata Updates
|
|
178
178
|
|
|
179
179
|
```javascript
|
|
180
|
-
//
|
|
181
|
-
await
|
|
180
|
+
// Initialize
|
|
181
|
+
await PageRecorder.init({
|
|
182
182
|
apiKey: 'your_api_key',
|
|
183
183
|
projectId: 'proj_12345',
|
|
184
184
|
metadata: {
|
|
@@ -186,46 +186,46 @@ await FinanceRecorder.init({
|
|
|
186
186
|
}
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
-
//
|
|
190
|
-
|
|
189
|
+
// User proceeds to next step
|
|
190
|
+
PageRecorder.setMetadata({ step: 'fill_info' });
|
|
191
191
|
|
|
192
|
-
//
|
|
193
|
-
|
|
192
|
+
// User submits application
|
|
193
|
+
PageRecorder.setMetadata({
|
|
194
194
|
step: 'submit',
|
|
195
195
|
applicationId: 'APP-2025-001'
|
|
196
196
|
});
|
|
197
197
|
```
|
|
198
198
|
|
|
199
|
-
##
|
|
199
|
+
## Privacy Protection
|
|
200
200
|
|
|
201
|
-
###
|
|
201
|
+
### Automatic Masking
|
|
202
202
|
|
|
203
|
-
SDK
|
|
203
|
+
The SDK automatically detects and masks the following sensitive information:
|
|
204
204
|
|
|
205
|
-
-
|
|
206
|
-
-
|
|
207
|
-
-
|
|
205
|
+
- **ID Card Number**: `110101199001011234` → `110101********1234`
|
|
206
|
+
- **Phone Number**: `13812345678` → `138****5678`
|
|
207
|
+
- **Bank Card Number**: `6222021234567890123` → `622202******123`
|
|
208
208
|
|
|
209
|
-
###
|
|
209
|
+
### Manual Element Blocking
|
|
210
210
|
|
|
211
|
-
|
|
211
|
+
Add the `rr-block` class name in HTML:
|
|
212
212
|
|
|
213
213
|
```html
|
|
214
214
|
<div class="rr-block">
|
|
215
|
-
|
|
215
|
+
This area will not be recorded
|
|
216
216
|
</div>
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
-
##
|
|
219
|
+
## Best Practices
|
|
220
220
|
|
|
221
|
-
### 1.
|
|
221
|
+
### 1. Error Handling
|
|
222
222
|
|
|
223
223
|
```javascript
|
|
224
|
-
|
|
224
|
+
PageRecorder.init({
|
|
225
225
|
apiKey: 'your_api_key',
|
|
226
226
|
projectId: 'proj_12345',
|
|
227
227
|
onError: (message, error) => {
|
|
228
|
-
//
|
|
228
|
+
// Report to error monitoring system
|
|
229
229
|
Sentry.captureException(error, {
|
|
230
230
|
tags: { component: 'recorder' },
|
|
231
231
|
extra: { message }
|
|
@@ -234,12 +234,12 @@ FinanceRecorder.init({
|
|
|
234
234
|
});
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
### 2.
|
|
237
|
+
### 2. Performance Monitoring
|
|
238
238
|
|
|
239
239
|
```javascript
|
|
240
240
|
const perfObserver = new PerformanceObserver((list) => {
|
|
241
241
|
for (const entry of list.getEntries()) {
|
|
242
|
-
|
|
242
|
+
PageRecorder.setMetadata({
|
|
243
243
|
[`perf_${entry.name}`]: entry.duration
|
|
244
244
|
});
|
|
245
245
|
}
|
|
@@ -248,14 +248,14 @@ const perfObserver = new PerformanceObserver((list) => {
|
|
|
248
248
|
perfObserver.observe({ entryTypes: ['navigation', 'resource'] });
|
|
249
249
|
```
|
|
250
250
|
|
|
251
|
-
### 3.
|
|
251
|
+
### 3. User Consent
|
|
252
252
|
|
|
253
253
|
```javascript
|
|
254
|
-
//
|
|
254
|
+
// Show user consent dialog
|
|
255
255
|
const consent = await showConsentDialog();
|
|
256
256
|
|
|
257
257
|
if (consent) {
|
|
258
|
-
await
|
|
258
|
+
await PageRecorder.init({
|
|
259
259
|
apiKey: 'your_api_key',
|
|
260
260
|
projectId: 'proj_12345',
|
|
261
261
|
metadata: {
|
|
@@ -266,14 +266,13 @@ if (consent) {
|
|
|
266
266
|
}
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
-
##
|
|
269
|
+
## Browser Compatibility
|
|
270
270
|
|
|
271
271
|
- Chrome 60+
|
|
272
272
|
- Firefox 55+
|
|
273
273
|
- Safari 11+
|
|
274
274
|
- Edge 79+
|
|
275
275
|
|
|
276
|
-
##
|
|
276
|
+
## License
|
|
277
277
|
|
|
278
278
|
MIT
|
|
279
|
-
|