@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.
@@ -13627,37 +13627,21 @@
13627
13627
  }
13628
13628
  sendRecordingEvents(sessionId, events) {
13629
13629
  return __awaiter$1(this, void 0, void 0, function* () {
13630
- // Calculate payload size
13631
- const payload = {
13632
- session_id: sessionId,
13633
- events,
13634
- timestamp: new Date().toISOString(),
13635
- apiKey: this.config.apiKey,
13636
- appId: this.config.appId,
13637
- };
13638
- const payloadSize = new Blob([JSON.stringify(payload)]).size;
13639
13630
  // Check if this batch contains FullSnapshot (type 2)
13640
13631
  const hasFullSnapshot = events.some(e => e.type === 2);
13641
- const maxRetries = hasFullSnapshot ? 3 : 1; // Retry FullSnapshot batches up to 3 times
13642
- // Recording events can be large, send immediately with retry logic
13632
+ const maxRetries = hasFullSnapshot ? 3 : 1;
13633
+ // ALWAYS use XHR for recording events to avoid fetch keepalive 64KB limit
13634
+ // The browser silently drops fetch requests with keepalive:true when body > 64KB
13635
+ // FullSnapshot + Meta events commonly fall in the 64KB-100KB range,
13636
+ // causing them to be silently lost while smaller IncrementalSnapshot batches succeed
13643
13637
  let lastError = null;
13644
13638
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
13645
13639
  try {
13646
- // Use XMLHttpRequest for large payloads (more reliable than fetch for large data)
13647
- if (payloadSize > 100000) { // > 100KB
13648
- yield this.sendToBackendXHR('/v1/rum/recordings', {
13649
- session_id: sessionId,
13650
- events,
13651
- timestamp: new Date().toISOString(),
13652
- });
13653
- }
13654
- else {
13655
- yield this.sendToBackend('/v1/rum/recordings', {
13656
- session_id: sessionId,
13657
- events,
13658
- timestamp: new Date().toISOString(),
13659
- });
13660
- }
13640
+ yield this.sendToBackendXHR('/v1/rum/recordings', {
13641
+ session_id: sessionId,
13642
+ events,
13643
+ timestamp: new Date().toISOString(),
13644
+ });
13661
13645
  return; // Success, exit
13662
13646
  }
13663
13647
  catch (error) {
@@ -13781,7 +13765,8 @@
13781
13765
  const xhr = new XMLHttpRequest();
13782
13766
  xhr.open('POST', url, true);
13783
13767
  xhr.setRequestHeader('Content-Type', 'application/json');
13784
- xhr.setRequestHeader('Authorization', `Bearer ${this.config.apiKey}`);
13768
+ xhr.setRequestHeader('X-API-Key', this.config.apiKey);
13769
+ xhr.setRequestHeader('X-App-Id', this.config.appId);
13785
13770
  xhr.onload = () => {
13786
13771
  if (xhr.status >= 200 && xhr.status < 300) {
13787
13772
  if (this.config.debug) {
@@ -13841,7 +13826,8 @@
13841
13826
  method: 'POST',
13842
13827
  headers: {
13843
13828
  'Content-Type': 'application/json',
13844
- Authorization: `Bearer ${this.config.apiKey}`,
13829
+ 'X-API-Key': this.config.apiKey,
13830
+ 'X-App-Id': this.config.appId,
13845
13831
  },
13846
13832
  body: JSON.stringify(payload),
13847
13833
  // Use keepalive for better reliability during page unload