@logspace/sdk 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/README.md +104 -90
  2. package/package.json +2 -5
package/README.md CHANGED
@@ -23,8 +23,8 @@ import LogSpace from '@logspace/sdk';
23
23
 
24
24
  // Initialize the SDK
25
25
  LogSpace.init({
26
- serverUrl: 'https://your-logspace-server.com',
27
- apiKey: 'project_id:environment_id',
26
+ serverUrl: 'https://your-logspace-server.com',
27
+ apiKey: 'project_id:environment_id',
28
28
  });
29
29
 
30
30
  // Start recording
@@ -32,8 +32,8 @@ LogSpace.startSession();
32
32
 
33
33
  // Identify the user (optional)
34
34
  LogSpace.identify('user-123', {
35
- email: 'user@example.com',
36
- plan: 'pro',
35
+ email: 'user@example.com',
36
+ plan: 'pro',
37
37
  });
38
38
 
39
39
  // Track custom events
@@ -62,87 +62,87 @@ await LogSpace.stopSession();
62
62
 
63
63
  ```javascript
64
64
  LogSpace.init({
65
- // Server configuration
66
- serverUrl: 'https://your-server.com',
67
- apiKey: 'project_id:environment_id',
68
-
69
- // What to capture
70
- capture: {
71
- rrweb: true, // DOM recording
72
- console: true, // Console logs
73
- network: true, // Network requests
74
- errors: true, // JavaScript errors
75
- interactions: true, // User interactions
76
- performance: true, // Performance metrics
77
- websocket: true, // WebSocket connections
78
- sse: true, // Server-Sent Events
79
- storage: true, // localStorage/sessionStorage
80
- resources: true, // Resource loading
81
- spaNavigation: true, // SPA route changes
82
- },
83
-
84
- // rrweb settings
85
- rrweb: {
86
- maskAllInputs: false, // Mask all input values
87
- maskTextSelector: null, // CSS selector for text masking
88
- blockSelector: null, // CSS selector to block elements
89
- recordCanvas: false, // Record canvas content
90
- checkoutEveryNth: 200, // Full snapshot interval
91
- },
92
-
93
- // Privacy settings
94
- privacy: {
95
- maskSensitiveData: true, // Auto-mask PII patterns
96
- maskSelectors: [], // CSS selectors to mask
97
- excludeUrls: [], // URL patterns to exclude
98
- blockNetworkBodies: [], // Block request/response bodies
99
- redactHeaders: [], // Headers to redact
100
- logLevels: ['log', 'info', 'warn', 'error', 'debug'],
101
- },
102
-
103
- // Session limits
104
- limits: {
105
- maxLogs: 10000, // Max logs per session
106
- maxSize: 10 * 1024 * 1024, // Max session size (10MB)
107
- maxDuration: 300, // Max duration in seconds (5 min)
108
- idleTimeout: 30, // Idle timeout in seconds
109
- rateLimit: 100, // Max logs per second
110
- deduplicate: true, // Deduplicate consecutive logs
111
- },
112
-
113
- // Auto-end behavior
114
- autoEnd: {
115
- continueOnRefresh: true, // Continue session on page refresh
116
- onIdle: true, // End on idle timeout
117
- onLimitReached: true, // End when limits reached
118
- },
119
-
120
- // Sampling mode (only record on errors)
121
- sampling: {
122
- enabled: false,
123
- bufferBefore: 15, // Seconds before trigger
124
- recordAfter: 15, // Seconds after trigger
125
- triggers: {
126
- onError: true,
127
- onConsoleError: true,
128
- onNetworkStatus: [500, 502, 503, 504],
129
- },
130
- },
131
-
132
- // Lifecycle hooks
133
- hooks: {
134
- onAction: (log, session) => {},
135
- beforeSend: (logs) => logs,
136
- onSessionStart: (session) => {},
137
- onSessionEnd: (session, logs) => {},
138
- onLimitReached: (reason) => {},
139
- onSamplingTrigger: (trigger, log) => {},
140
- onError: (error) => {},
141
- },
142
-
143
- // Additional options
144
- headers: {}, // Custom API headers
145
- debug: false, // Enable debug logging
65
+ // Server configuration
66
+ serverUrl: 'https://your-server.com',
67
+ apiKey: 'project_id:environment_id',
68
+
69
+ // What to capture
70
+ capture: {
71
+ rrweb: true, // DOM recording
72
+ console: true, // Console logs
73
+ network: true, // Network requests
74
+ errors: true, // JavaScript errors
75
+ interactions: true, // User interactions
76
+ performance: true, // Performance metrics
77
+ websocket: true, // WebSocket connections
78
+ sse: true, // Server-Sent Events
79
+ storage: true, // localStorage/sessionStorage
80
+ resources: true, // Resource loading
81
+ spaNavigation: true, // SPA route changes
82
+ },
83
+
84
+ // rrweb settings
85
+ rrweb: {
86
+ maskAllInputs: false, // Mask all input values
87
+ maskTextSelector: null, // CSS selector for text masking
88
+ blockSelector: null, // CSS selector to block elements
89
+ recordCanvas: false, // Record canvas content
90
+ checkoutEveryNth: 200, // Full snapshot interval
91
+ },
92
+
93
+ // Privacy settings
94
+ privacy: {
95
+ maskSensitiveData: true, // Auto-mask PII patterns
96
+ maskSelectors: [], // CSS selectors to mask
97
+ excludeUrls: [], // URL patterns to exclude
98
+ blockNetworkBodies: [], // Block request/response bodies
99
+ redactHeaders: [], // Headers to redact
100
+ logLevels: ['log', 'info', 'warn', 'error', 'debug'],
101
+ },
102
+
103
+ // Session limits
104
+ limits: {
105
+ maxLogs: 10000, // Max logs per session
106
+ maxSize: 10 * 1024 * 1024, // Max session size (10MB)
107
+ maxDuration: 300, // Max duration in seconds (5 min)
108
+ idleTimeout: 30, // Idle timeout in seconds
109
+ rateLimit: 100, // Max logs per second
110
+ deduplicate: true, // Deduplicate consecutive logs
111
+ },
112
+
113
+ // Auto-end behavior
114
+ autoEnd: {
115
+ continueOnRefresh: true, // Continue session on page refresh
116
+ onIdle: true, // End on idle timeout
117
+ onLimitReached: true, // End when limits reached
118
+ },
119
+
120
+ // Sampling mode (only record on errors)
121
+ sampling: {
122
+ enabled: false,
123
+ bufferBefore: 15, // Seconds before trigger
124
+ recordAfter: 15, // Seconds after trigger
125
+ triggers: {
126
+ onError: true,
127
+ onConsoleError: true,
128
+ onNetworkStatus: [500, 502, 503, 504],
129
+ },
130
+ },
131
+
132
+ // Lifecycle hooks
133
+ hooks: {
134
+ onAction: (log, session) => {},
135
+ beforeSend: (logs) => logs,
136
+ onSessionStart: (session) => {},
137
+ onSessionEnd: (session, logs) => {},
138
+ onLimitReached: (reason) => {},
139
+ onSamplingTrigger: (trigger, log) => {},
140
+ onError: (error) => {},
141
+ },
142
+
143
+ // Additional options
144
+ headers: {}, // Custom API headers
145
+ debug: false, // Enable debug logging
146
146
  });
147
147
  ```
148
148
 
@@ -151,11 +151,13 @@ LogSpace.init({
151
151
  ### Initialization
152
152
 
153
153
  #### `LogSpace.init(config)`
154
+
154
155
  Initialize the SDK with configuration options.
155
156
 
156
157
  ### Session Control
157
158
 
158
159
  #### `LogSpace.startSession(metadata?)`
160
+
159
161
  Start a new recording session with optional metadata.
160
162
 
161
163
  ```javascript
@@ -163,6 +165,7 @@ LogSpace.startSession({ page: 'checkout', variant: 'A' });
163
165
  ```
164
166
 
165
167
  #### `LogSpace.stopSession()`
168
+
166
169
  Stop recording and send the session to the server.
167
170
 
168
171
  ```javascript
@@ -170,37 +173,42 @@ await LogSpace.stopSession();
170
173
  ```
171
174
 
172
175
  #### `LogSpace.pauseRecording()`
176
+
173
177
  Temporarily pause recording.
174
178
 
175
179
  #### `LogSpace.resumeRecording()`
180
+
176
181
  Resume a paused recording.
177
182
 
178
183
  ### User Identification
179
184
 
180
185
  #### `LogSpace.identify(userId, traits?)`
186
+
181
187
  Associate the session with a user.
182
188
 
183
189
  ```javascript
184
190
  LogSpace.identify('user-123', {
185
- email: 'user@example.com',
186
- name: 'John Doe',
187
- plan: 'enterprise',
191
+ email: 'user@example.com',
192
+ name: 'John Doe',
193
+ plan: 'enterprise',
188
194
  });
189
195
  ```
190
196
 
191
197
  ### Custom Events
192
198
 
193
199
  #### `LogSpace.track(event, properties?)`
200
+
194
201
  Track a custom event.
195
202
 
196
203
  ```javascript
197
204
  LogSpace.track('purchase_completed', {
198
- orderId: 'ORD-123',
199
- amount: 99.99,
205
+ orderId: 'ORD-123',
206
+ amount: 99.99,
200
207
  });
201
208
  ```
202
209
 
203
210
  #### `LogSpace.breadcrumb(message, category?)`
211
+
204
212
  Add a breadcrumb for debugging context.
205
213
 
206
214
  ```javascript
@@ -210,6 +218,7 @@ LogSpace.breadcrumb('User clicked add to cart', 'action');
210
218
  ### Sampling Mode
211
219
 
212
220
  #### `LogSpace.trigger(reason?)`
221
+
213
222
  Manually trigger session capture in sampling mode.
214
223
 
215
224
  ```javascript
@@ -219,20 +228,25 @@ LogSpace.trigger('user_reported_issue');
219
228
  ### Session Data
220
229
 
221
230
  #### `LogSpace.getSession()`
231
+
222
232
  Get the current session object.
223
233
 
224
234
  #### `LogSpace.getSessionLogs()`
235
+
225
236
  Get all logs for the current session.
226
237
 
227
238
  #### `LogSpace.getSessionData()`
239
+
228
240
  Get full session payload for local export.
229
241
 
230
242
  #### `LogSpace.getRRWebEvents()`
243
+
231
244
  Get rrweb events for the current session.
232
245
 
233
246
  ### Cleanup
234
247
 
235
248
  #### `LogSpace.destroy()`
249
+
236
250
  Destroy the SDK and clean up resources.
237
251
 
238
252
  ## Usage Formats
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logspace/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "LogSpace JavaScript SDK for session recording and logging",
5
5
  "type": "module",
6
6
  "main": "./logspace.umd.js",
@@ -38,8 +38,5 @@
38
38
  "monitoring"
39
39
  ],
40
40
  "author": "LogSpace",
41
- "license": "MIT",
42
- "scripts": {
43
- "preinstall": "npx only-allow bun && bun --version | grep -q '^1.2.21$' || (echo 'Error: Bun version 1.2.21 is required' && exit 1)"
44
- }
41
+ "license": "MIT"
45
42
  }