@temps-sdk/react-analytics 0.0.1-beta.24 → 0.0.1-beta.25

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SessionRecorder.d.ts","sourceRoot":"","sources":["../src/SessionRecorder.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAE1D,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA2CD,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EAAG,uBAAuB;AAClC,MAAM,EACN,OAAe,EACf,aAAkB,EAClB,iBAAuB,EACvB,aAAoB,EACpB,gBAAgC,EAChC,UAAuB,EACvB,WAAyB,EACzB,aAAyB,EACzB,YAAoB,EACpB,YAAoB,EACpB,cAUC,EACD,SAAe,EACf,aAAoB,GACrB,EAAE,oBAAoB,QA4XtB"}
1
+ {"version":3,"file":"SessionRecorder.d.ts","sourceRoot":"","sources":["../src/SessionRecorder.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAE1D,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA2CD,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EAAG,uBAAuB;AAClC,MAAM,EACN,OAAe,EACf,aAAkB,EAClB,iBAAuB,EACvB,aAAoB,EACpB,gBAAgC,EAChC,UAAuB,EACvB,WAAyB,EACzB,aAAyB,EACzB,YAAoB,EACpB,YAAoB,EACpB,cAUC,EACD,SAAe,EACf,aAAoB,GACrB,EAAE,oBAAoB,QAoZtB"}
@@ -159,7 +159,8 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
159
159
  if (events.length === 0)
160
160
  return;
161
161
  const eventsToSend = [...events];
162
- eventsRef.current = [];
162
+ // Don't clear the array immediately - clear only after successful send
163
+ // eventsRef.current = [];
163
164
  try {
164
165
  // Pack the events for more efficient transmission
165
166
  const packedEvents = pack(eventsToSend);
@@ -184,6 +185,9 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
184
185
  keepalive: true,
185
186
  });
186
187
  }
188
+ // For reliable sends, we don't clear events as they're sent via beacon
189
+ // which doesn't provide response feedback
190
+ eventsRef.current = [];
187
191
  }
188
192
  else {
189
193
  // Fallback to fetch with keepalive
@@ -193,6 +197,8 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
193
197
  body: JSON.stringify(payload),
194
198
  keepalive: true,
195
199
  });
200
+ // Clear events after successful send
201
+ eventsRef.current = [];
196
202
  }
197
203
  }
198
204
  else {
@@ -216,27 +222,42 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
216
222
  stopFnRef.current = null;
217
223
  }
218
224
  // Don't restore events - they're lost
225
+ eventsRef.current = [];
219
226
  }
220
227
  else if (!response.ok) {
221
228
  console.error("[SessionRecorder] Failed to send events:", response.status);
222
- // Restore events on failure
223
- eventsRef.current.unshift(...eventsToSend);
229
+ // Don't restore events - keep them for next attempt
230
+ // eventsRef.current.unshift(...eventsToSend);
231
+ }
232
+ else {
233
+ // Clear events after successful send
234
+ eventsRef.current = [];
224
235
  }
225
236
  }
226
237
  }
227
238
  catch (error) {
228
239
  console.error("[SessionRecorder] Failed to send session events:", error);
229
- // Restore events on failure
230
- eventsRef.current.unshift(...eventsToSend);
240
+ // Don't restore events - keep them for next attempt
241
+ // eventsRef.current.unshift(...eventsToSend);
231
242
  }
232
- }, [basePath, initializeSession]);
243
+ }, [basePath]);
233
244
  const scheduleFlush = useCallback(() => {
234
245
  if (flushTimeoutRef.current) {
235
246
  clearTimeout(flushTimeoutRef.current);
236
247
  }
237
- flushTimeoutRef.current = setTimeout(() => {
248
+ const flushAndReschedule = () => {
238
249
  sendEvents(false);
239
- }, flushInterval);
250
+ // Always schedule the next flush, even if the current send fails
251
+ // This ensures continuous retry attempts
252
+ scheduleNextFlush();
253
+ };
254
+ const scheduleNextFlush = () => {
255
+ if (flushTimeoutRef.current) {
256
+ clearTimeout(flushTimeoutRef.current);
257
+ }
258
+ flushTimeoutRef.current = setTimeout(flushAndReschedule, flushInterval);
259
+ };
260
+ scheduleNextFlush();
240
261
  }, [sendEvents, flushInterval]);
241
262
  const startRecording = useCallback(async () => {
242
263
  if (stopFnRef.current)
@@ -261,7 +282,7 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
261
282
  // Batch send when we reach the batch size
262
283
  if (eventsRef.current.length >= batchSize) {
263
284
  sendEvents(false);
264
- scheduleFlush();
285
+ // scheduleFlush() is now called automatically after each send
265
286
  }
266
287
  },
267
288
  sampling: {
@@ -269,6 +290,8 @@ domain, enabled = false, excludedPaths = [], sessionSampleRate = 1.0, maskAllInp
269
290
  media: 800,
270
291
  input: "last"
271
292
  },
293
+ blockSelector: "[data-private]",
294
+ ignoreSelector: "[data-ignore]",
272
295
  recordCanvas,
273
296
  collectFonts,
274
297
  maskAllInputs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temps-sdk/react-analytics",
3
- "version": "0.0.1-beta.24",
3
+ "version": "0.0.1-beta.25",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",