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