@product7/feedback-sdk 1.2.2 → 1.2.4

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.
@@ -1360,7 +1360,7 @@
1360
1360
  this.isMinimized = false;
1361
1361
  }
1362
1362
 
1363
- _render() {
1363
+ render() {
1364
1364
  const button = document.createElement('div');
1365
1365
  button.className = `feedback-widget feedback-widget-button theme-${this.options.theme} position-${this.options.position}`;
1366
1366
  button.innerHTML = `
@@ -1391,25 +1391,34 @@
1391
1391
  return button;
1392
1392
  }
1393
1393
 
1394
- _attachEvents() {
1394
+ attachEvents() {
1395
1395
  const button = this.element.querySelector('.feedback-trigger-btn');
1396
- this.element.querySelector('.feedback-minimize-icon');
1397
- this.element.querySelector('.feedback-expand-icon');
1396
+ const minimizeIcon = this.element.querySelector('.feedback-minimize-icon');
1397
+ const expandIcon = this.element.querySelector('.feedback-expand-icon');
1398
+
1399
+ // Add click handlers directly to the icons
1400
+ minimizeIcon.addEventListener('click', (e) => {
1401
+ e.stopPropagation();
1402
+ e.preventDefault();
1403
+ this.minimize();
1404
+ });
1405
+
1406
+ expandIcon.addEventListener('click', (e) => {
1407
+ e.stopPropagation();
1408
+ e.preventDefault();
1409
+ this.restore();
1410
+ });
1398
1411
 
1412
+ // Main button click handler
1399
1413
  button.addEventListener('click', (e) => {
1400
- const clickedMinimize = e.target.closest('.feedback-minimize-icon');
1401
- const clickedExpand = e.target.closest('.feedback-expand-icon');
1414
+ // Check if the click originated from an icon
1415
+ if (e.target.closest('.feedback-minimize-icon') ||
1416
+ e.target.closest('.feedback-expand-icon')) {
1417
+ return; // Let the icon handlers deal with it
1418
+ }
1402
1419
 
1403
- if (clickedMinimize) {
1404
- e.stopPropagation();
1405
- this.minimize();
1406
- } else if (clickedExpand) {
1407
- e.stopPropagation();
1408
- this.restore();
1409
- } else {
1410
- if (!this.isMinimized) {
1411
- this.openPanel();
1412
- }
1420
+ if (!this.isMinimized) {
1421
+ this.openPanel();
1413
1422
  }
1414
1423
  });
1415
1424
 
@@ -4787,6 +4796,25 @@
4787
4796
  this.eventBus.emit('sdk:destroyed');
4788
4797
  }
4789
4798
 
4799
+ _detectEnvironment() {
4800
+ if (typeof window === 'undefined') {
4801
+ return 'production';
4802
+ }
4803
+
4804
+ const hostname = window.location.hostname.toLowerCase();
4805
+
4806
+ if (
4807
+ hostname.includes('staging') ||
4808
+ hostname.includes('localhost') ||
4809
+ hostname.includes('127.0.0.1') ||
4810
+ hostname.includes('.local')
4811
+ ) {
4812
+ return 'staging';
4813
+ }
4814
+
4815
+ return 'production';
4816
+ }
4817
+
4790
4818
  _validateAndMergeConfig(newConfig, existingConfig = {}) {
4791
4819
  const defaultConfig = {
4792
4820
  apiUrl: null,
@@ -4798,7 +4826,7 @@
4798
4826
  autoShow: true,
4799
4827
  debug: false,
4800
4828
  mock: false,
4801
- env: 'production', // 'production' or 'staging'
4829
+ env: this._detectEnvironment(),
4802
4830
  };
4803
4831
 
4804
4832
  const mergedConfig = deepMerge(
@@ -4806,6 +4834,10 @@
4806
4834
  newConfig
4807
4835
  );
4808
4836
 
4837
+ if (!newConfig.env && !existingConfig.env) {
4838
+ mergedConfig.env = this._detectEnvironment();
4839
+ }
4840
+
4809
4841
  if (!mergedConfig.workspace) {
4810
4842
  throw new ConfigError('Missing required configuration: workspace');
4811
4843
  }