@devskin/browser-sdk 1.0.46 → 1.0.48

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.
@@ -13621,37 +13621,21 @@ class Transport {
13621
13621
  }
13622
13622
  sendRecordingEvents(sessionId, events) {
13623
13623
  return __awaiter$1(this, void 0, void 0, function* () {
13624
- // Calculate payload size
13625
- const payload = {
13626
- session_id: sessionId,
13627
- events,
13628
- timestamp: new Date().toISOString(),
13629
- apiKey: this.config.apiKey,
13630
- appId: this.config.appId,
13631
- };
13632
- const payloadSize = new Blob([JSON.stringify(payload)]).size;
13633
13624
  // Check if this batch contains FullSnapshot (type 2)
13634
13625
  const hasFullSnapshot = events.some(e => e.type === 2);
13635
- const maxRetries = hasFullSnapshot ? 3 : 1; // Retry FullSnapshot batches up to 3 times
13636
- // Recording events can be large, send immediately with retry logic
13626
+ const maxRetries = hasFullSnapshot ? 3 : 1;
13627
+ // ALWAYS use XHR for recording events to avoid fetch keepalive 64KB limit
13628
+ // The browser silently drops fetch requests with keepalive:true when body > 64KB
13629
+ // FullSnapshot + Meta events commonly fall in the 64KB-100KB range,
13630
+ // causing them to be silently lost while smaller IncrementalSnapshot batches succeed
13637
13631
  let lastError = null;
13638
13632
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
13639
13633
  try {
13640
- // Use XMLHttpRequest for large payloads (more reliable than fetch for large data)
13641
- if (payloadSize > 100000) { // > 100KB
13642
- yield this.sendToBackendXHR('/v1/rum/recordings', {
13643
- session_id: sessionId,
13644
- events,
13645
- timestamp: new Date().toISOString(),
13646
- });
13647
- }
13648
- else {
13649
- yield this.sendToBackend('/v1/rum/recordings', {
13650
- session_id: sessionId,
13651
- events,
13652
- timestamp: new Date().toISOString(),
13653
- });
13654
- }
13634
+ yield this.sendToBackendXHR('/v1/rum/recordings', {
13635
+ session_id: sessionId,
13636
+ events,
13637
+ timestamp: new Date().toISOString(),
13638
+ });
13655
13639
  return; // Success, exit
13656
13640
  }
13657
13641
  catch (error) {
@@ -13775,7 +13759,8 @@ class Transport {
13775
13759
  const xhr = new XMLHttpRequest();
13776
13760
  xhr.open('POST', url, true);
13777
13761
  xhr.setRequestHeader('Content-Type', 'application/json');
13778
- xhr.setRequestHeader('Authorization', `Bearer ${this.config.apiKey}`);
13762
+ xhr.setRequestHeader('X-API-Key', this.config.apiKey);
13763
+ xhr.setRequestHeader('X-App-Id', this.config.appId);
13779
13764
  xhr.onload = () => {
13780
13765
  if (xhr.status >= 200 && xhr.status < 300) {
13781
13766
  if (this.config.debug) {
@@ -13835,7 +13820,8 @@ class Transport {
13835
13820
  method: 'POST',
13836
13821
  headers: {
13837
13822
  'Content-Type': 'application/json',
13838
- Authorization: `Bearer ${this.config.apiKey}`,
13823
+ 'X-API-Key': this.config.apiKey,
13824
+ 'X-App-Id': this.config.appId,
13839
13825
  },
13840
13826
  body: JSON.stringify(payload),
13841
13827
  // Use keepalive for better reliability during page unload