@devskin/browser-sdk 1.0.28 → 1.0.30

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.
@@ -13696,7 +13696,7 @@ class Transport {
13696
13696
  }
13697
13697
  const items = [...this.queue];
13698
13698
  this.queue = [];
13699
- // Group items by type
13699
+ // Group by type
13700
13700
  const grouped = {};
13701
13701
  items.forEach((item) => {
13702
13702
  if (!grouped[item.type]) {
@@ -13704,19 +13704,35 @@ class Transport {
13704
13704
  }
13705
13705
  grouped[item.type].push(item.data);
13706
13706
  });
13707
- // Send each group
13708
- Object.entries(grouped).forEach(([type, data]) => {
13707
+ // Send each type appropriately
13708
+ Object.entries(grouped).forEach(([type, dataArray]) => {
13709
13709
  const endpoint = this.getEndpointForType(type);
13710
- this.sendToBackend(endpoint, { [type + 's']: data }, useBeacon);
13710
+ if (type === 'event' && dataArray.length > 1) {
13711
+ // Events with batch support
13712
+ this.sendToBackend('/v1/rum/events/batch', { events: dataArray }, useBeacon);
13713
+ }
13714
+ else if (type === 'heatmap') {
13715
+ // Heatmap expects array format
13716
+ this.sendToBackend(endpoint, { heatmaps: dataArray }, useBeacon);
13717
+ }
13718
+ else {
13719
+ // Send each item individually (network, performance, error)
13720
+ dataArray.forEach((data) => {
13721
+ this.sendToBackend(endpoint, data, useBeacon);
13722
+ });
13723
+ }
13711
13724
  });
13712
13725
  if (this.config.debug) {
13713
13726
  console.log(`[DevSkin] Flushed ${items.length} items to backend`);
13714
13727
  }
13715
13728
  }
13716
13729
  enqueue(type, data) {
13730
+ // Add applicationId to RUM events (event, error, network, performance)
13731
+ // Heatmap uses apiKey/appId in payload root instead
13732
+ const enrichedData = type !== 'heatmap' ? Object.assign(Object.assign({}, data), { applicationId: this.config.appId }) : data;
13717
13733
  this.queue.push({
13718
13734
  type,
13719
- data,
13735
+ data: enrichedData,
13720
13736
  timestamp: Date.now(),
13721
13737
  });
13722
13738
  // Flush if queue is full
@@ -14115,15 +14131,33 @@ class DevSkinSDK {
14115
14131
  }
14116
14132
  }
14117
14133
  getContextData() {
14134
+ var _a, _b, _c, _d;
14118
14135
  const context = {};
14136
+ // Flatten device data to match backend schema
14119
14137
  if (this.deviceCollector) {
14120
- context.device = this.deviceCollector.collect();
14138
+ const device = this.deviceCollector.collect();
14139
+ context.deviceType = device.type;
14140
+ context.deviceModel = device.model;
14141
+ context.osName = (_a = device.os) === null || _a === void 0 ? void 0 : _a.name;
14142
+ context.osVersion = (_b = device.os) === null || _b === void 0 ? void 0 : _b.version;
14143
+ context.screenWidth = (_c = device.screen) === null || _c === void 0 ? void 0 : _c.width;
14144
+ context.screenHeight = (_d = device.screen) === null || _d === void 0 ? void 0 : _d.height;
14145
+ context.viewportWidth = window.innerWidth;
14146
+ context.viewportHeight = window.innerHeight;
14121
14147
  }
14148
+ // Flatten browser data to match backend schema
14122
14149
  if (this.browserCollector) {
14123
- context.browser = this.browserCollector.collect();
14150
+ const browser = this.browserCollector.collect();
14151
+ context.browserName = browser.name;
14152
+ context.browserVersion = browser.version;
14153
+ context.userAgent = browser.userAgent;
14124
14154
  }
14155
+ // Flatten location data to match backend schema
14125
14156
  if (this.locationCollector) {
14126
- context.location = this.locationCollector.collect();
14157
+ const location = this.locationCollector.collect();
14158
+ context.country = location.country;
14159
+ context.city = location.city;
14160
+ context.ipAddress = undefined; // Will be set by backend from request
14127
14161
  }
14128
14162
  return context;
14129
14163
  }