devx-web-widget 1.1.1 → 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.
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "devx-web-widget",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
+ "types": "./dist/index.d.ts",
6
7
  "keywords": [],
7
- "author": "",
8
+ "author": "DevX",
8
9
  "license": "ISC",
9
10
  "devEngines": {
10
11
  "packageManager": {
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!');
package/tsconfig.json CHANGED
@@ -4,7 +4,6 @@
4
4
  // File Layout
5
5
  "rootDir": "./src",
6
6
  "outDir": "./dist",
7
-
8
7
  // Environment Settings
9
8
  // See also https://aka.ms/tsconfig/module
10
9
  "module": "nodenext",
@@ -14,16 +13,13 @@
14
13
  // "lib": ["esnext"],
15
14
  // "types": ["node"],
16
15
  // and npm install -D @types/node
17
-
18
16
  // Other Outputs
19
17
  "sourceMap": true,
20
18
  "declaration": true,
21
19
  "declarationMap": true,
22
-
23
20
  // Stricter Typechecking Options
24
21
  "noUncheckedIndexedAccess": true,
25
22
  "exactOptionalPropertyTypes": true,
26
-
27
23
  // Style Options
28
24
  // "noImplicitReturns": true,
29
25
  // "noImplicitOverride": true,
@@ -31,7 +27,6 @@
31
27
  // "noUnusedParameters": true,
32
28
  // "noFallthroughCasesInSwitch": true,
33
29
  // "noPropertyAccessFromIndexSignature": true,
34
-
35
30
  // Recommended Options
36
31
  "strict": true,
37
32
  "jsx": "react-jsx",
@@ -40,5 +35,8 @@
40
35
  "noUncheckedSideEffectImports": true,
41
36
  "moduleDetection": "force",
42
37
  "skipLibCheck": true,
43
- }
44
- }
38
+ },
39
+ "include": [
40
+ "src/**/*"
41
+ ]
42
+ }