@zaplier/sdk 1.2.4 → 1.2.6

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/index.esm.js CHANGED
@@ -6988,10 +6988,10 @@ class SessionReplayEngine {
6988
6988
  this.sessionId = sessionId;
6989
6989
  this.config = {
6990
6990
  enabled: true,
6991
- sampleRate: 0.1,
6991
+ sampleRate: 1.0, // 100% for development/testing
6992
6992
  maskSensitiveFields: true,
6993
6993
  maxEventBuffer: 1000,
6994
- batchInterval: 5000,
6994
+ batchInterval: 2000, // Send every 2 seconds for faster testing
6995
6995
  captureClicks: true,
6996
6996
  captureScrolls: true,
6997
6997
  captureInputs: true,
@@ -7247,10 +7247,13 @@ class SessionReplayEngine {
7247
7247
  * Send batch of events
7248
7248
  */
7249
7249
  sendBatch() {
7250
- if (this.events.length === 0)
7250
+ if (this.events.length === 0) {
7251
+ console.log('[Zaplier] No events to send in batch');
7251
7252
  return;
7253
+ }
7252
7254
  const batch = [...this.events];
7253
7255
  this.events = [];
7256
+ console.log(`[Zaplier] Sending batch with ${batch.length} events for session ${this.sessionId}`);
7254
7257
  const payload = {
7255
7258
  sessionId: this.sessionId,
7256
7259
  events: batch,
@@ -7276,23 +7279,55 @@ class SessionReplayEngine {
7276
7279
  try {
7277
7280
  // Try WebRTC first if anti-adblock manager is available
7278
7281
  if (this.antiAdblockManager) {
7279
- const result = await this.antiAdblockManager.send(payload, '/api/replay/record');
7282
+ console.log('[Zaplier] Trying WebRTC transport...');
7283
+ const result = await this.antiAdblockManager.send(payload, '/replays/record');
7280
7284
  if (result.success) {
7285
+ console.log('[Zaplier] Session replay sent via WebRTC');
7281
7286
  return; // Success via WebRTC
7282
7287
  }
7283
- }
7288
+ console.log('[Zaplier] WebRTC failed, falling back to fetch');
7289
+ }
7290
+ // Get API endpoint from global config
7291
+ const apiEndpoint = window.zaplier_config?.apiEndpoint || 'http://localhost:3001';
7292
+ const token = window.zaplier_config?.token || 'ws_demo_token';
7293
+ const url = `${apiEndpoint}/replays/record?token=${token}`;
7294
+ console.log(`[Zaplier] Sending replay batch to ${url}`);
7295
+ console.log(`[Zaplier] Payload:`, {
7296
+ sessionId: payload.sessionId,
7297
+ eventCount: payload.events.length,
7298
+ hasMetadata: !!payload.metadata
7299
+ });
7300
+ const requestBody = {
7301
+ sessionId: payload.sessionId,
7302
+ events: payload.events,
7303
+ metadata: {
7304
+ startUrl: window.location.href,
7305
+ duration: Date.now() - (performance.timeOrigin || Date.now()),
7306
+ funnelSteps: [],
7307
+ hasConversion: false,
7308
+ ...payload.metadata
7309
+ }
7310
+ };
7284
7311
  // Fallback to standard fetch
7285
- const response = await fetch('/api/replay/record', {
7312
+ const response = await fetch(url, {
7286
7313
  method: 'POST',
7287
7314
  headers: { 'Content-Type': 'application/json' },
7288
- body: JSON.stringify(payload)
7315
+ body: JSON.stringify(requestBody)
7289
7316
  });
7317
+ const responseText = await response.text();
7290
7318
  if (!response.ok) {
7291
- console.warn('[Zaplier] Session replay batch failed to send');
7319
+ console.error('[Zaplier] Session replay batch failed:', {
7320
+ status: response.status,
7321
+ statusText: response.statusText,
7322
+ response: responseText
7323
+ });
7324
+ }
7325
+ else {
7326
+ console.log('[Zaplier] Session replay batch sent successfully:', responseText);
7292
7327
  }
7293
7328
  }
7294
7329
  catch (error) {
7295
- console.warn('[Zaplier] Session replay error:', error);
7330
+ console.error('[Zaplier] Session replay error:', error);
7296
7331
  }
7297
7332
  }
7298
7333
  /**