@devskin/browser-sdk 1.0.16 → 1.0.18

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.
@@ -1032,24 +1032,24 @@ class HeatmapCollector {
1032
1032
  });
1033
1033
  }
1034
1034
  flush() {
1035
+ // Send clicks individually (backend expects one click event per item)
1035
1036
  if (this.clickData.length > 0) {
1036
- this.transport.sendHeatmapData({
1037
- type: 'clicks',
1038
- data: this.clickData,
1037
+ this.clickData.forEach(click => {
1038
+ this.transport.sendHeatmapData(Object.assign({ type: 'click' }, click));
1039
1039
  });
1040
1040
  this.clickData = [];
1041
1041
  }
1042
+ // Send scroll data individually
1042
1043
  if (this.scrollData.length > 0) {
1043
- this.transport.sendHeatmapData({
1044
- type: 'scroll',
1045
- data: this.scrollData,
1044
+ this.scrollData.forEach(scroll => {
1045
+ this.transport.sendHeatmapData(Object.assign({ type: 'scroll' }, scroll));
1046
1046
  });
1047
1047
  this.scrollData = [];
1048
1048
  }
1049
+ // Send mouse moves individually
1049
1050
  if (this.mouseMoveData.length > 0) {
1050
- this.transport.sendHeatmapData({
1051
- type: 'mousemove',
1052
- data: this.mouseMoveData,
1051
+ this.mouseMoveData.forEach(move => {
1052
+ this.transport.sendHeatmapData(Object.assign({ type: 'mousemove' }, move));
1053
1053
  });
1054
1054
  this.mouseMoveData = [];
1055
1055
  }
@@ -5950,12 +5950,17 @@ class DevSkinSDK {
5950
5950
  * Initialize the DevSkin SDK
5951
5951
  */
5952
5952
  init(config) {
5953
- var _a, _b;
5953
+ var _a, _b, _c, _d;
5954
5954
  if (this.initialized) {
5955
5955
  console.warn('[DevSkin] SDK already initialized');
5956
5956
  return;
5957
5957
  }
5958
- this.config = Object.assign({ debug: false, captureWebVitals: true, captureNetworkRequests: true, captureErrors: true, captureUserAgent: true, captureLocation: true, captureDevice: true }, config);
5958
+ this.config = Object.assign({ debug: false, captureWebVitals: true, captureNetworkRequests: true, captureErrors: true, captureUserAgent: true, captureLocation: true, captureDevice: true, heatmapOptions: {
5959
+ enabled: true,
5960
+ trackClicks: true,
5961
+ trackScroll: true,
5962
+ trackMouseMovement: false, // Disabled by default to avoid too much data
5963
+ } }, config);
5959
5964
  if (this.config.debug) {
5960
5965
  console.log('[DevSkin] Initializing SDK with config:', this.config);
5961
5966
  }
@@ -5982,12 +5987,20 @@ class DevSkinSDK {
5982
5987
  this.networkCollector.start();
5983
5988
  }
5984
5989
  // Initialize heatmap collector
5985
- if ((_a = this.config.heatmapOptions) === null || _a === void 0 ? void 0 : _a.enabled) {
5990
+ // Auto-enable heatmap if session recording is enabled
5991
+ const heatmapEnabled = ((_a = this.config.heatmapOptions) === null || _a === void 0 ? void 0 : _a.enabled) || ((_b = this.config.sessionRecording) === null || _b === void 0 ? void 0 : _b.enabled);
5992
+ if (heatmapEnabled) {
5993
+ // Merge default heatmap config with user config
5994
+ const heatmapConfig = Object.assign({ enabled: true, trackClicks: true, trackScroll: true, trackMouseMovement: false }, this.config.heatmapOptions);
5995
+ this.config.heatmapOptions = heatmapConfig;
5986
5996
  this.heatmapCollector = new HeatmapCollector(this.config, this.transport);
5987
5997
  this.heatmapCollector.start();
5998
+ if (this.config.debug) {
5999
+ console.log('[DevSkin] Heatmap collection enabled', ((_c = this.config.sessionRecording) === null || _c === void 0 ? void 0 : _c.enabled) ? '(auto-enabled with session recording)' : '');
6000
+ }
5988
6001
  }
5989
6002
  // Initialize session recording with rrweb
5990
- if ((_b = this.config.sessionRecording) === null || _b === void 0 ? void 0 : _b.enabled) {
6003
+ if ((_d = this.config.sessionRecording) === null || _d === void 0 ? void 0 : _d.enabled) {
5991
6004
  // Use RRWebRecorder for complete DOM recording
5992
6005
  this.rrwebRecorder = new RRWebRecorder(this.sessionId, {
5993
6006
  enabled: true,