@product7/feedback-sdk 1.1.0 → 1.1.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.
- package/README.md +181 -33
- package/dist/README.md +181 -33
- package/dist/feedback-sdk.js +883 -90
- package/dist/feedback-sdk.js.map +1 -1
- package/dist/feedback-sdk.min.js +1 -1
- package/dist/feedback-sdk.min.js.map +1 -1
- package/package.json +1 -1
- package/src/core/APIService.js +55 -3
- package/src/core/FeedbackSDK.js +44 -1
- package/src/index.js +3 -0
- package/src/styles/styles.js +210 -75
- package/src/widgets/BaseWidget.js +68 -11
- package/src/widgets/SurveyWidget.js +504 -0
- package/src/widgets/WidgetFactory.js +2 -0
package/README.md
CHANGED
|
@@ -9,14 +9,18 @@ A lightweight, customizable JavaScript SDK for collecting user feedback on any w
|
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
12
|
+
- **Display modes** — Side panel or centered modal
|
|
13
|
+
- **Size options** — Small, medium, or large widget sizes
|
|
14
|
+
- **Full color customization** — Background, text, and primary colors
|
|
15
|
+
- **Custom triggers** — Use your own buttons instead of floating widget
|
|
16
|
+
- **Mock mode** — Development without backend connection
|
|
17
|
+
- **Multiple positions** — 7 position options including center
|
|
18
|
+
- **Responsive design** — Works on desktop, tablet, and mobile
|
|
19
|
+
- **Easy integration** — Simple JavaScript API, minimal setup
|
|
20
|
+
- **Lightweight** — ~12KB gzipped
|
|
21
|
+
- **TypeScript support** — Full type definitions included
|
|
22
|
+
- **Accessible** — WCAG 2.1 compliant
|
|
23
|
+
- **Secure** — CSP friendly, no `eval()` usage
|
|
20
24
|
|
|
21
25
|
---
|
|
22
26
|
|
|
@@ -90,22 +94,29 @@ widget.mount();
|
|
|
90
94
|
|
|
91
95
|
## Widget Types
|
|
92
96
|
|
|
93
|
-
**Button Widget**
|
|
97
|
+
**Button Widget with Side Panel**
|
|
94
98
|
|
|
95
99
|
```javascript
|
|
96
|
-
const
|
|
100
|
+
const widget = feedback.createWidget('button', {
|
|
97
101
|
position: 'bottom-right',
|
|
102
|
+
displayMode: 'panel', // Slides in from the side
|
|
103
|
+
size: 'medium',
|
|
98
104
|
});
|
|
99
|
-
|
|
105
|
+
widget.mount();
|
|
100
106
|
```
|
|
101
107
|
|
|
102
|
-
**
|
|
108
|
+
**Button Widget with Modal**
|
|
103
109
|
|
|
104
110
|
```javascript
|
|
105
|
-
const
|
|
106
|
-
position: 'bottom-
|
|
111
|
+
const widget = feedback.createWidget('button', {
|
|
112
|
+
position: 'bottom-right',
|
|
113
|
+
displayMode: 'modal', // Centered overlay
|
|
114
|
+
size: 'large',
|
|
115
|
+
backgroundColor: '#ffffff',
|
|
116
|
+
textColor: '#1F2937',
|
|
117
|
+
primaryColor: '#155EEF',
|
|
107
118
|
});
|
|
108
|
-
|
|
119
|
+
widget.mount();
|
|
109
120
|
```
|
|
110
121
|
|
|
111
122
|
**Inline Widget**
|
|
@@ -119,28 +130,165 @@ inline.mount('#feedback-container');
|
|
|
119
130
|
|
|
120
131
|
## Configuration
|
|
121
132
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
|
125
|
-
|
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
| `
|
|
133
|
+
### SDK Configuration
|
|
134
|
+
|
|
135
|
+
| Option | Type | Required | Default | Description |
|
|
136
|
+
| ------------- | ------- | -------- | -------------- | ------------------------------------ |
|
|
137
|
+
| `workspace` | string | ✅ | - | Your workspace subdomain |
|
|
138
|
+
| `boardId` | string | ❌ | 'general' | Target board for feedback |
|
|
139
|
+
| `userContext` | object | ❌ | null | User identification data |
|
|
140
|
+
| `mock` | boolean | ❌ | false | Enable mock mode for development |
|
|
141
|
+
| `debug` | boolean | ❌ | false | Enable debug logging |
|
|
142
|
+
|
|
143
|
+
### Widget Configuration
|
|
144
|
+
|
|
145
|
+
| Option | Type | Default | Description |
|
|
146
|
+
| ----------------- | ------ | -------------- | ---------------------------------------- |
|
|
147
|
+
| `displayMode` | string | 'panel' | `'panel'` (side slide) or `'modal'` (centered) |
|
|
148
|
+
| `size` | string | 'medium' | `'small'`, `'medium'`, or `'large'` |
|
|
149
|
+
| `position` | string | 'bottom-right' | Button position (see below) |
|
|
150
|
+
| `backgroundColor` | string | '#ffffff' | Panel/modal background color |
|
|
151
|
+
| `textColor` | string | '#1F2937' | Text color |
|
|
152
|
+
| `primaryColor` | string | '#155EEF' | Button and accent color |
|
|
153
|
+
|
|
154
|
+
### Position Options
|
|
155
|
+
|
|
156
|
+
- `bottom-right` (default)
|
|
157
|
+
- `bottom-left`
|
|
158
|
+
- `top-right`
|
|
159
|
+
- `top-left`
|
|
160
|
+
- `bottom-center`
|
|
161
|
+
- `top-center`
|
|
162
|
+
- `center`
|
|
163
|
+
|
|
164
|
+
### Size Variants
|
|
165
|
+
|
|
166
|
+
| Size | Modal Width | Panel Width |
|
|
167
|
+
| ------ | ----------- | ----------- |
|
|
168
|
+
| small | 360px | 320px |
|
|
169
|
+
| medium | 480px | 420px |
|
|
170
|
+
| large | 600px | 520px |
|
|
130
171
|
|
|
131
172
|
---
|
|
132
173
|
|
|
133
|
-
##
|
|
174
|
+
## Color Customization
|
|
175
|
+
|
|
176
|
+
Instead of predefined themes, use direct color values for full flexibility:
|
|
134
177
|
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
178
|
+
```javascript
|
|
179
|
+
const widget = feedback.createWidget('button', {
|
|
180
|
+
displayMode: 'modal',
|
|
181
|
+
backgroundColor: '#1a1a2e', // Dark background
|
|
182
|
+
textColor: '#ffffff', // White text
|
|
183
|
+
primaryColor: '#e94560', // Red accent
|
|
184
|
+
});
|
|
142
185
|
```
|
|
143
186
|
|
|
187
|
+
This approach works better than predefined themes because:
|
|
188
|
+
- Supports any brand color
|
|
189
|
+
- Works with both light and dark designs
|
|
190
|
+
- No restrictions on color combinations
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Custom Triggers
|
|
195
|
+
|
|
196
|
+
Hide the default floating button and trigger from your own UI:
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
window.FeedbackSDK.onReady((sdk) => {
|
|
200
|
+
const widget = sdk.createWidget('button', {
|
|
201
|
+
displayMode: 'modal',
|
|
202
|
+
size: 'medium',
|
|
203
|
+
});
|
|
204
|
+
widget.mount();
|
|
205
|
+
widget.hide(); // Hide the floating button
|
|
206
|
+
|
|
207
|
+
// Trigger from your own button
|
|
208
|
+
document.getElementById('my-feedback-btn').addEventListener('click', () => {
|
|
209
|
+
widget.openPanel();
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Mock Mode
|
|
217
|
+
|
|
218
|
+
For development without a backend connection:
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
window.FeedbackSDKConfig = {
|
|
222
|
+
workspace: 'demo',
|
|
223
|
+
mock: true, // No backend required
|
|
224
|
+
userContext: {
|
|
225
|
+
user_id: 'test_user',
|
|
226
|
+
email: 'test@example.com',
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Mock mode simulates:
|
|
232
|
+
- Session initialization
|
|
233
|
+
- Feedback submission (with 500ms delay)
|
|
234
|
+
- Default configuration values
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Environments
|
|
239
|
+
|
|
240
|
+
The SDK supports multiple environments for development and production use.
|
|
241
|
+
|
|
242
|
+
### Production (Default)
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
const feedback = new FeedbackSDK({
|
|
246
|
+
workspace: 'your-workspace',
|
|
247
|
+
environment: 'production', // Default, can be omitted
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**API URLs:**
|
|
252
|
+
- `https://api.product7.io/api/v1`
|
|
253
|
+
- `https://{workspace}.api.product7.io/api/v1`
|
|
254
|
+
|
|
255
|
+
### Staging
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
const feedback = new FeedbackSDK({
|
|
259
|
+
workspace: 'your-workspace',
|
|
260
|
+
environment: 'staging',
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**API URLs:**
|
|
265
|
+
- `https://staging.api.product7.io/api/v1`
|
|
266
|
+
- `https://{workspace}.staging.api.product7.io/api/v1`
|
|
267
|
+
|
|
268
|
+
### Custom API URL
|
|
269
|
+
|
|
270
|
+
For self-hosted or custom deployments:
|
|
271
|
+
|
|
272
|
+
```javascript
|
|
273
|
+
const feedback = new FeedbackSDK({
|
|
274
|
+
workspace: 'your-workspace',
|
|
275
|
+
apiUrl: 'https://your-custom-api.com/api/v1',
|
|
276
|
+
});
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Configuration Priority
|
|
282
|
+
|
|
283
|
+
Configuration values merge in this order (later overrides earlier):
|
|
284
|
+
|
|
285
|
+
1. **Default values** — Built-in SDK defaults
|
|
286
|
+
2. **Backend config** — Returned from `/widget/init` API
|
|
287
|
+
3. **SDK config** — `window.FeedbackSDKConfig`
|
|
288
|
+
4. **Widget options** — Passed to `createWidget()`
|
|
289
|
+
|
|
290
|
+
This allows backend-managed defaults while permitting per-widget customization.
|
|
291
|
+
|
|
144
292
|
---
|
|
145
293
|
|
|
146
294
|
## Events
|
|
@@ -184,8 +332,8 @@ npm run size
|
|
|
184
332
|
|
|
185
333
|
## Bundle Size
|
|
186
334
|
|
|
187
|
-
- **Minified**:
|
|
188
|
-
- **Minified + Gzipped**:
|
|
335
|
+
- **Minified**: ~41KB
|
|
336
|
+
- **Minified + Gzipped**: ~12KB
|
|
189
337
|
|
|
190
338
|
---
|
|
191
339
|
|
package/dist/README.md
CHANGED
|
@@ -9,14 +9,18 @@ A lightweight, customizable JavaScript SDK for collecting user feedback on any w
|
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
12
|
+
- **Display modes** — Side panel or centered modal
|
|
13
|
+
- **Size options** — Small, medium, or large widget sizes
|
|
14
|
+
- **Full color customization** — Background, text, and primary colors
|
|
15
|
+
- **Custom triggers** — Use your own buttons instead of floating widget
|
|
16
|
+
- **Mock mode** — Development without backend connection
|
|
17
|
+
- **Multiple positions** — 7 position options including center
|
|
18
|
+
- **Responsive design** — Works on desktop, tablet, and mobile
|
|
19
|
+
- **Easy integration** — Simple JavaScript API, minimal setup
|
|
20
|
+
- **Lightweight** — ~12KB gzipped
|
|
21
|
+
- **TypeScript support** — Full type definitions included
|
|
22
|
+
- **Accessible** — WCAG 2.1 compliant
|
|
23
|
+
- **Secure** — CSP friendly, no `eval()` usage
|
|
20
24
|
|
|
21
25
|
---
|
|
22
26
|
|
|
@@ -90,22 +94,29 @@ widget.mount();
|
|
|
90
94
|
|
|
91
95
|
## Widget Types
|
|
92
96
|
|
|
93
|
-
**Button Widget**
|
|
97
|
+
**Button Widget with Side Panel**
|
|
94
98
|
|
|
95
99
|
```javascript
|
|
96
|
-
const
|
|
100
|
+
const widget = feedback.createWidget('button', {
|
|
97
101
|
position: 'bottom-right',
|
|
102
|
+
displayMode: 'panel', // Slides in from the side
|
|
103
|
+
size: 'medium',
|
|
98
104
|
});
|
|
99
|
-
|
|
105
|
+
widget.mount();
|
|
100
106
|
```
|
|
101
107
|
|
|
102
|
-
**
|
|
108
|
+
**Button Widget with Modal**
|
|
103
109
|
|
|
104
110
|
```javascript
|
|
105
|
-
const
|
|
106
|
-
position: 'bottom-
|
|
111
|
+
const widget = feedback.createWidget('button', {
|
|
112
|
+
position: 'bottom-right',
|
|
113
|
+
displayMode: 'modal', // Centered overlay
|
|
114
|
+
size: 'large',
|
|
115
|
+
backgroundColor: '#ffffff',
|
|
116
|
+
textColor: '#1F2937',
|
|
117
|
+
primaryColor: '#155EEF',
|
|
107
118
|
});
|
|
108
|
-
|
|
119
|
+
widget.mount();
|
|
109
120
|
```
|
|
110
121
|
|
|
111
122
|
**Inline Widget**
|
|
@@ -119,28 +130,165 @@ inline.mount('#feedback-container');
|
|
|
119
130
|
|
|
120
131
|
## Configuration
|
|
121
132
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
|
125
|
-
|
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
| `
|
|
133
|
+
### SDK Configuration
|
|
134
|
+
|
|
135
|
+
| Option | Type | Required | Default | Description |
|
|
136
|
+
| ------------- | ------- | -------- | -------------- | ------------------------------------ |
|
|
137
|
+
| `workspace` | string | ✅ | - | Your workspace subdomain |
|
|
138
|
+
| `boardId` | string | ❌ | 'general' | Target board for feedback |
|
|
139
|
+
| `userContext` | object | ❌ | null | User identification data |
|
|
140
|
+
| `mock` | boolean | ❌ | false | Enable mock mode for development |
|
|
141
|
+
| `debug` | boolean | ❌ | false | Enable debug logging |
|
|
142
|
+
|
|
143
|
+
### Widget Configuration
|
|
144
|
+
|
|
145
|
+
| Option | Type | Default | Description |
|
|
146
|
+
| ----------------- | ------ | -------------- | ---------------------------------------- |
|
|
147
|
+
| `displayMode` | string | 'panel' | `'panel'` (side slide) or `'modal'` (centered) |
|
|
148
|
+
| `size` | string | 'medium' | `'small'`, `'medium'`, or `'large'` |
|
|
149
|
+
| `position` | string | 'bottom-right' | Button position (see below) |
|
|
150
|
+
| `backgroundColor` | string | '#ffffff' | Panel/modal background color |
|
|
151
|
+
| `textColor` | string | '#1F2937' | Text color |
|
|
152
|
+
| `primaryColor` | string | '#155EEF' | Button and accent color |
|
|
153
|
+
|
|
154
|
+
### Position Options
|
|
155
|
+
|
|
156
|
+
- `bottom-right` (default)
|
|
157
|
+
- `bottom-left`
|
|
158
|
+
- `top-right`
|
|
159
|
+
- `top-left`
|
|
160
|
+
- `bottom-center`
|
|
161
|
+
- `top-center`
|
|
162
|
+
- `center`
|
|
163
|
+
|
|
164
|
+
### Size Variants
|
|
165
|
+
|
|
166
|
+
| Size | Modal Width | Panel Width |
|
|
167
|
+
| ------ | ----------- | ----------- |
|
|
168
|
+
| small | 360px | 320px |
|
|
169
|
+
| medium | 480px | 420px |
|
|
170
|
+
| large | 600px | 520px |
|
|
130
171
|
|
|
131
172
|
---
|
|
132
173
|
|
|
133
|
-
##
|
|
174
|
+
## Color Customization
|
|
175
|
+
|
|
176
|
+
Instead of predefined themes, use direct color values for full flexibility:
|
|
134
177
|
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
178
|
+
```javascript
|
|
179
|
+
const widget = feedback.createWidget('button', {
|
|
180
|
+
displayMode: 'modal',
|
|
181
|
+
backgroundColor: '#1a1a2e', // Dark background
|
|
182
|
+
textColor: '#ffffff', // White text
|
|
183
|
+
primaryColor: '#e94560', // Red accent
|
|
184
|
+
});
|
|
142
185
|
```
|
|
143
186
|
|
|
187
|
+
This approach works better than predefined themes because:
|
|
188
|
+
- Supports any brand color
|
|
189
|
+
- Works with both light and dark designs
|
|
190
|
+
- No restrictions on color combinations
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Custom Triggers
|
|
195
|
+
|
|
196
|
+
Hide the default floating button and trigger from your own UI:
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
window.FeedbackSDK.onReady((sdk) => {
|
|
200
|
+
const widget = sdk.createWidget('button', {
|
|
201
|
+
displayMode: 'modal',
|
|
202
|
+
size: 'medium',
|
|
203
|
+
});
|
|
204
|
+
widget.mount();
|
|
205
|
+
widget.hide(); // Hide the floating button
|
|
206
|
+
|
|
207
|
+
// Trigger from your own button
|
|
208
|
+
document.getElementById('my-feedback-btn').addEventListener('click', () => {
|
|
209
|
+
widget.openPanel();
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Mock Mode
|
|
217
|
+
|
|
218
|
+
For development without a backend connection:
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
window.FeedbackSDKConfig = {
|
|
222
|
+
workspace: 'demo',
|
|
223
|
+
mock: true, // No backend required
|
|
224
|
+
userContext: {
|
|
225
|
+
user_id: 'test_user',
|
|
226
|
+
email: 'test@example.com',
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Mock mode simulates:
|
|
232
|
+
- Session initialization
|
|
233
|
+
- Feedback submission (with 500ms delay)
|
|
234
|
+
- Default configuration values
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Environments
|
|
239
|
+
|
|
240
|
+
The SDK supports multiple environments for development and production use.
|
|
241
|
+
|
|
242
|
+
### Production (Default)
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
const feedback = new FeedbackSDK({
|
|
246
|
+
workspace: 'your-workspace',
|
|
247
|
+
environment: 'production', // Default, can be omitted
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**API URLs:**
|
|
252
|
+
- `https://api.product7.io/api/v1`
|
|
253
|
+
- `https://{workspace}.api.product7.io/api/v1`
|
|
254
|
+
|
|
255
|
+
### Staging
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
const feedback = new FeedbackSDK({
|
|
259
|
+
workspace: 'your-workspace',
|
|
260
|
+
environment: 'staging',
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**API URLs:**
|
|
265
|
+
- `https://staging.api.product7.io/api/v1`
|
|
266
|
+
- `https://{workspace}.staging.api.product7.io/api/v1`
|
|
267
|
+
|
|
268
|
+
### Custom API URL
|
|
269
|
+
|
|
270
|
+
For self-hosted or custom deployments:
|
|
271
|
+
|
|
272
|
+
```javascript
|
|
273
|
+
const feedback = new FeedbackSDK({
|
|
274
|
+
workspace: 'your-workspace',
|
|
275
|
+
apiUrl: 'https://your-custom-api.com/api/v1',
|
|
276
|
+
});
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Configuration Priority
|
|
282
|
+
|
|
283
|
+
Configuration values merge in this order (later overrides earlier):
|
|
284
|
+
|
|
285
|
+
1. **Default values** — Built-in SDK defaults
|
|
286
|
+
2. **Backend config** — Returned from `/widget/init` API
|
|
287
|
+
3. **SDK config** — `window.FeedbackSDKConfig`
|
|
288
|
+
4. **Widget options** — Passed to `createWidget()`
|
|
289
|
+
|
|
290
|
+
This allows backend-managed defaults while permitting per-widget customization.
|
|
291
|
+
|
|
144
292
|
---
|
|
145
293
|
|
|
146
294
|
## Events
|
|
@@ -184,8 +332,8 @@ npm run size
|
|
|
184
332
|
|
|
185
333
|
## Bundle Size
|
|
186
334
|
|
|
187
|
-
- **Minified**:
|
|
188
|
-
- **Minified + Gzipped**:
|
|
335
|
+
- **Minified**: ~41KB
|
|
336
|
+
- **Minified + Gzipped**: ~12KB
|
|
189
337
|
|
|
190
338
|
---
|
|
191
339
|
|