crexperium-sdk 1.1.0 → 1.2.0
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/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.js +26 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -4
package/dist/index.js
CHANGED
|
@@ -132,22 +132,17 @@ class NetworkError extends CRMError {
|
|
|
132
132
|
const isBrowser$1 = typeof window !== 'undefined';
|
|
133
133
|
// Get fetch implementation
|
|
134
134
|
function getFetch() {
|
|
135
|
+
// Browser environment
|
|
135
136
|
if (isBrowser$1 && typeof window.fetch !== 'undefined') {
|
|
136
137
|
return window.fetch.bind(window);
|
|
137
138
|
}
|
|
138
|
-
//
|
|
139
|
+
// Node.js 18+ with native fetch
|
|
139
140
|
if (typeof globalThis.fetch !== 'undefined') {
|
|
140
141
|
return globalThis.fetch.bind(globalThis);
|
|
141
142
|
}
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const nodeFetch = require('node-fetch');
|
|
146
|
-
return nodeFetch.default || nodeFetch;
|
|
147
|
-
}
|
|
148
|
-
catch {
|
|
149
|
-
throw new Error('Fetch is not available. Please upgrade to Node.js 18+ or install node-fetch.');
|
|
150
|
-
}
|
|
143
|
+
// Node.js <18 without fetch - throw helpful error
|
|
144
|
+
throw new Error('Fetch is not available. Please upgrade to Node.js 18+ which includes native fetch support. ' +
|
|
145
|
+
'Alternatively, install and configure a polyfill.');
|
|
151
146
|
}
|
|
152
147
|
class HTTPClient {
|
|
153
148
|
constructor(config) {
|
|
@@ -13192,10 +13187,14 @@ class SessionReplayPlugin {
|
|
|
13192
13187
|
*/
|
|
13193
13188
|
async init() {
|
|
13194
13189
|
try {
|
|
13190
|
+
console.log('[SessionReplay] Initializing session replay...');
|
|
13195
13191
|
// Start session on backend
|
|
13196
13192
|
await this.startSession();
|
|
13193
|
+
console.log('[SessionReplay] Session started on backend, sessionId:', this.session?.sessionId);
|
|
13197
13194
|
// Start rrweb recording
|
|
13195
|
+
console.log('[SessionReplay] Starting rrweb recording...');
|
|
13198
13196
|
this.startRrwebRecording();
|
|
13197
|
+
console.log('[SessionReplay] rrweb recording started');
|
|
13199
13198
|
// Intercept console methods
|
|
13200
13199
|
if (this.config.telemetry?.captureConsole) {
|
|
13201
13200
|
this.interceptConsole();
|
|
@@ -13267,9 +13266,18 @@ class SessionReplayPlugin {
|
|
|
13267
13266
|
startRrwebRecording() {
|
|
13268
13267
|
this.stopRecording = record({
|
|
13269
13268
|
emit: (event) => {
|
|
13269
|
+
// Debug: Log event types
|
|
13270
|
+
if (event.type === 4) {
|
|
13271
|
+
console.log('[SessionReplay] Captured Meta event (type 4)');
|
|
13272
|
+
}
|
|
13273
|
+
else if (event.type === 2) {
|
|
13274
|
+
console.log('[SessionReplay] Captured Full Snapshot event (type 2)');
|
|
13275
|
+
}
|
|
13270
13276
|
this.eventBuffer.push(event);
|
|
13277
|
+
console.log(`[SessionReplay] Event buffered. Type: ${event.type}, Buffer size: ${this.eventBuffer.length}`);
|
|
13271
13278
|
// Auto-flush if buffer reaches max size
|
|
13272
13279
|
if (this.eventBuffer.length >= (this.config.buffering?.maxBufferSize || 100)) {
|
|
13280
|
+
console.log('[SessionReplay] Buffer full, flushing...');
|
|
13273
13281
|
this.flush();
|
|
13274
13282
|
}
|
|
13275
13283
|
},
|
|
@@ -13611,9 +13619,16 @@ class SessionReplayPlugin {
|
|
|
13611
13619
|
* Flush buffered events to backend
|
|
13612
13620
|
*/
|
|
13613
13621
|
async flush() {
|
|
13614
|
-
|
|
13622
|
+
console.log(`[SessionReplay] flush() called. Session: ${!!this.session}, Event buffer: ${this.eventBuffer.length}, Telemetry buffer: ${this.telemetryBuffer.length}`);
|
|
13623
|
+
if (!this.session) {
|
|
13624
|
+
console.warn('[SessionReplay] flush() skipped - no session yet!');
|
|
13625
|
+
return;
|
|
13626
|
+
}
|
|
13627
|
+
if (this.eventBuffer.length === 0 && this.telemetryBuffer.length === 0) {
|
|
13628
|
+
console.log('[SessionReplay] flush() skipped - buffers empty');
|
|
13615
13629
|
return;
|
|
13616
13630
|
}
|
|
13631
|
+
console.log(`[SessionReplay] Flushing ${this.eventBuffer.length} events to backend...`);
|
|
13617
13632
|
const eventsToSend = [...this.eventBuffer];
|
|
13618
13633
|
const telemetryToSend = [...this.telemetryBuffer];
|
|
13619
13634
|
// Clear buffers
|