devx-web-widget 1.1.2 → 1.2.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +5 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devx-web-widget",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/src/index.ts CHANGED
@@ -85,10 +85,9 @@ class FeedbackWidget {
85
85
  private selectedEl: Element | null;
86
86
  private hoverRafId: number | null;
87
87
  private hostId: string;
88
- private apiKey: string;
89
88
  private endPoint: string;
90
89
 
91
- constructor(apiKey: string | null = null, config: FeedbackWidgetConfig = {}) {
90
+ constructor(config: FeedbackWidgetConfig = {}) {
92
91
  this.config = { ...DEFAULT_CONFIG, ...config };
93
92
  this.hostId = `feedback-widget-host-${Math.random().toString(36).substr(2, 9)}`;
94
93
  this.state = 'idle';
@@ -96,7 +95,6 @@ class FeedbackWidget {
96
95
  this.selectedSelector = null;
97
96
  this.selectedEl = null;
98
97
  this.hoverRafId = null;
99
- this.apiKey = apiKey || '';
100
98
  this.endPoint = "https://devx.today/v1/widget/ingest";
101
99
 
102
100
  this.initialize();
@@ -794,8 +792,8 @@ class FeedbackWidget {
794
792
  const feedbackBody = payload.feedback || '(No additional details provided)';
795
793
  const pageTitle = payload.pageTitle;
796
794
  const message = `${feedbackBody}\n\nPage: ${pageTitle}\nURL: ${payload.pageUrl}\nSelector: ${payload.elementSelector}\nOption: ${payload.optionType}\nSubmitted: ${payload.submittedAt}`;
797
-
798
-
795
+
796
+
799
797
  return {
800
798
  title: feedbackTitle,
801
799
  body: message,
@@ -804,21 +802,8 @@ class FeedbackWidget {
804
802
  }
805
803
 
806
804
  private submitFeedback(payload: FeedbackPayload): void {
807
- window.dispatchEvent(new CustomEvent('feedbackwidget:submit', { detail: payload }));
808
-
809
- if (this.apiKey) {
810
- const messageBody = this.prepareMessageBody(payload);
811
- fetch(this.endPoint, {
812
- method: 'POST',
813
- headers: {
814
- 'Content-Type': 'application/json',
815
- 'Authorization': `Bearer ${this.apiKey}`
816
- },
817
- body: JSON.stringify(messageBody)
818
- }).catch(() => {
819
- // Swallow network errors, UX already confirmed below
820
- });
821
- }
805
+ const messageBody = this.prepareMessageBody(payload);
806
+ window.dispatchEvent(new CustomEvent('feedbackwidget:submit', { detail: messageBody }));
822
807
 
823
808
  this.cancelAll();
824
809
  this.showToast('Thanks for the feedback!');