@product7/feedback-sdk 1.2.4 → 1.2.6
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 +176 -7
- package/dist/README.md +176 -7
- package/dist/feedback-sdk.js +8156 -5140
- 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 +643 -0
- package/src/core/FeedbackSDK.js +115 -5
- package/src/core/WebSocketService.js +273 -0
- package/src/index.js +3 -0
- package/src/styles/messengerStyles.js +100 -0
- package/src/styles/styles.js +747 -1
- package/src/widgets/BaseWidget.js +96 -0
- package/src/widgets/ButtonWidget.js +93 -91
- package/src/widgets/ChangelogWidget.js +619 -0
- package/src/widgets/MessengerWidget.js +374 -89
- package/src/widgets/WidgetFactory.js +2 -0
- package/src/widgets/messenger/MessengerState.js +12 -0
- package/src/widgets/messenger/components/NavigationTabs.js +1 -1
- package/src/widgets/messenger/views/ChatView.js +121 -16
- package/src/widgets/messenger/views/ConversationsView.js +12 -11
- package/src/widgets/messenger/views/HomeView.js +23 -1
- package/types/index.d.ts +152 -123
package/README.md
CHANGED
|
@@ -21,6 +21,10 @@ A lightweight, customizable JavaScript SDK for collecting user feedback on any w
|
|
|
21
21
|
- **TypeScript support** — Full type definitions included
|
|
22
22
|
- **Accessible** — WCAG 2.1 compliant
|
|
23
23
|
- **Secure** — CSP friendly, no `eval()` usage
|
|
24
|
+
- **Messenger widget** — Real-time chat with WebSocket support
|
|
25
|
+
- **Help center** — Integrated help articles and collections
|
|
26
|
+
- **Changelog** — Display product updates and announcements
|
|
27
|
+
- **Environment auto-detection** — Automatic staging/production switching
|
|
24
28
|
|
|
25
29
|
---
|
|
26
30
|
|
|
@@ -126,19 +130,34 @@ const inline = feedback.createWidget('inline');
|
|
|
126
130
|
inline.mount('#feedback-container');
|
|
127
131
|
```
|
|
128
132
|
|
|
133
|
+
**Messenger Widget**
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
const messenger = feedback.createWidget('messenger', {
|
|
137
|
+
position: 'bottom-right',
|
|
138
|
+
theme: 'light',
|
|
139
|
+
teamName: 'Support',
|
|
140
|
+
enableHelp: true,
|
|
141
|
+
enableChangelog: true,
|
|
142
|
+
});
|
|
143
|
+
messenger.mount();
|
|
144
|
+
```
|
|
145
|
+
|
|
129
146
|
---
|
|
130
147
|
|
|
131
148
|
## Configuration
|
|
132
149
|
|
|
133
150
|
### SDK Configuration
|
|
134
151
|
|
|
135
|
-
| Option | Type | Required | Default
|
|
136
|
-
| ------------- | ------- | -------- |
|
|
137
|
-
| `workspace` | string | ✅ | -
|
|
138
|
-
| `boardId` | string | ❌ | 'general'
|
|
139
|
-
| `userContext` | object | ❌ | null
|
|
140
|
-
| `mock` | boolean | ❌ | false
|
|
141
|
-
| `debug` | boolean | ❌ | false
|
|
152
|
+
| Option | Type | Required | Default | Description |
|
|
153
|
+
| ------------- | ------- | -------- | ------------ | ------------------------------------- |
|
|
154
|
+
| `workspace` | string | ✅ | - | Your workspace subdomain |
|
|
155
|
+
| `boardId` | string | ❌ | 'general' | Target board for feedback |
|
|
156
|
+
| `userContext` | object | ❌ | null | User identification data |
|
|
157
|
+
| `mock` | boolean | ❌ | false | Enable mock mode for development |
|
|
158
|
+
| `debug` | boolean | ❌ | false | Enable debug logging |
|
|
159
|
+
| `env` | string | ❌ | auto-detect | Environment: 'production' or 'staging'|
|
|
160
|
+
| `apiUrl` | string | ❌ | null | Custom API URL (overrides env) |
|
|
142
161
|
|
|
143
162
|
### Widget Configuration
|
|
144
163
|
|
|
@@ -234,6 +253,10 @@ Mock mode simulates:
|
|
|
234
253
|
- Session initialization
|
|
235
254
|
- Feedback submission (with 500ms delay)
|
|
236
255
|
- Default configuration values
|
|
256
|
+
- Messenger conversations and messages
|
|
257
|
+
- Help articles and collections
|
|
258
|
+
- Changelog entries
|
|
259
|
+
- Agent availability status
|
|
237
260
|
|
|
238
261
|
---
|
|
239
262
|
|
|
@@ -368,6 +391,152 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
368
391
|
|
|
369
392
|
---
|
|
370
393
|
|
|
394
|
+
## Messenger Widget
|
|
395
|
+
|
|
396
|
+
The SDK includes a full-featured messenger widget for real-time customer conversations, help articles, and changelog updates.
|
|
397
|
+
|
|
398
|
+
### Features
|
|
399
|
+
|
|
400
|
+
- **Real-time messaging** — WebSocket-powered live chat with typing indicators
|
|
401
|
+
- **Conversation management** — View and manage multiple conversations
|
|
402
|
+
- **Help center integration** — Browse help articles and collections
|
|
403
|
+
- **Changelog updates** — Display product updates and announcements
|
|
404
|
+
- **Agent availability** — Show online status and response times
|
|
405
|
+
- **Customizable UI** — Theme, colors, and position options
|
|
406
|
+
|
|
407
|
+
### Quick Start
|
|
408
|
+
|
|
409
|
+
```javascript
|
|
410
|
+
const feedback = new FeedbackSDK({
|
|
411
|
+
workspace: 'your-workspace',
|
|
412
|
+
userContext: {
|
|
413
|
+
user_id: 'user_123',
|
|
414
|
+
email: 'user@example.com',
|
|
415
|
+
name: 'John Doe',
|
|
416
|
+
},
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
await feedback.init();
|
|
420
|
+
|
|
421
|
+
const messenger = feedback.createWidget('messenger', {
|
|
422
|
+
position: 'bottom-right',
|
|
423
|
+
theme: 'light',
|
|
424
|
+
teamName: 'Support Team',
|
|
425
|
+
welcomeMessage: 'How can we help you today?',
|
|
426
|
+
enableHelp: true,
|
|
427
|
+
enableChangelog: true,
|
|
428
|
+
primaryColor: '#1c1c1e',
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
messenger.mount();
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Messenger Configuration Options
|
|
435
|
+
|
|
436
|
+
| Option | Type | Default | Description |
|
|
437
|
+
| ------------------ | -------- | ---------------- | ---------------------------------------- |
|
|
438
|
+
| `position` | string | 'bottom-right' | Widget position on screen |
|
|
439
|
+
| `theme` | string | 'light' | 'light' or 'dark' |
|
|
440
|
+
| `teamName` | string | 'Support' | Team name displayed in header |
|
|
441
|
+
| `teamAvatars` | array | [] | Array of team member avatar URLs |
|
|
442
|
+
| `welcomeMessage` | string | 'How can we help?' | Welcome message on home view |
|
|
443
|
+
| `enableHelp` | boolean | true | Show help articles section |
|
|
444
|
+
| `enableChangelog` | boolean | true | Show changelog section |
|
|
445
|
+
| `logoUrl` | string | - | Custom logo URL |
|
|
446
|
+
| `primaryColor` | string | '#1c1c1e' | Primary accent color |
|
|
447
|
+
| `onSendMessage` | function | null | Callback when message is sent |
|
|
448
|
+
| `onArticleClick` | function | null | Callback when help article is clicked |
|
|
449
|
+
| `onChangelogClick` | function | null | Callback when changelog item is clicked |
|
|
450
|
+
|
|
451
|
+
### Messenger Views
|
|
452
|
+
|
|
453
|
+
The messenger widget includes multiple views:
|
|
454
|
+
|
|
455
|
+
| View | Description |
|
|
456
|
+
| --------------- | ---------------------------------------------- |
|
|
457
|
+
| `home` | Welcome screen with quick actions |
|
|
458
|
+
| `messages` | List of all conversations |
|
|
459
|
+
| `chat` | Individual conversation chat view |
|
|
460
|
+
| `help` | Help articles and collections |
|
|
461
|
+
| `changelog` | Product updates and announcements |
|
|
462
|
+
|
|
463
|
+
### Programmatic Control
|
|
464
|
+
|
|
465
|
+
```javascript
|
|
466
|
+
// Open/close messenger
|
|
467
|
+
messenger.open();
|
|
468
|
+
messenger.close();
|
|
469
|
+
messenger.toggle();
|
|
470
|
+
|
|
471
|
+
// Navigate to specific view
|
|
472
|
+
messenger.navigateTo('messages');
|
|
473
|
+
messenger.navigateTo('help');
|
|
474
|
+
messenger.navigateTo('changelog');
|
|
475
|
+
|
|
476
|
+
// Get current state
|
|
477
|
+
const state = messenger.getState();
|
|
478
|
+
console.log(state.isOpen, state.currentView, state.unreadCount);
|
|
479
|
+
|
|
480
|
+
// Update unread count
|
|
481
|
+
messenger.setUnreadCount(3);
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### Real-time Events
|
|
485
|
+
|
|
486
|
+
```javascript
|
|
487
|
+
// Message sent
|
|
488
|
+
feedback.eventBus.on('messenger:messageSent', (data) => {
|
|
489
|
+
console.log('Message sent:', data.message);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
// Messenger opened/closed
|
|
493
|
+
feedback.eventBus.on('messenger:opened', () => {
|
|
494
|
+
console.log('Messenger opened');
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
feedback.eventBus.on('messenger:closed', () => {
|
|
498
|
+
console.log('Messenger closed');
|
|
499
|
+
});
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
### WebSocket Connection
|
|
503
|
+
|
|
504
|
+
The messenger automatically establishes a WebSocket connection for real-time features:
|
|
505
|
+
|
|
506
|
+
- **Incoming messages** — New messages appear instantly
|
|
507
|
+
- **Typing indicators** — See when agents are typing
|
|
508
|
+
- **Presence updates** — Real-time agent availability
|
|
509
|
+
|
|
510
|
+
The WebSocket connection is managed automatically and reconnects on disconnection.
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## Environment Auto-Detection
|
|
515
|
+
|
|
516
|
+
The SDK automatically detects the environment based on the hostname:
|
|
517
|
+
|
|
518
|
+
| Hostname Pattern | Environment |
|
|
519
|
+
| ----------------------------------------- | ----------- |
|
|
520
|
+
| `localhost`, `127.0.0.1`, `*.local` | staging |
|
|
521
|
+
| Contains `staging` | staging |
|
|
522
|
+
| All other hostnames | production |
|
|
523
|
+
|
|
524
|
+
```javascript
|
|
525
|
+
// Auto-detection (recommended)
|
|
526
|
+
const feedback = new FeedbackSDK({
|
|
527
|
+
workspace: 'your-workspace',
|
|
528
|
+
// env is auto-detected from window.location.hostname
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
// Manual override
|
|
532
|
+
const feedback = new FeedbackSDK({
|
|
533
|
+
workspace: 'your-workspace',
|
|
534
|
+
env: 'staging', // Force staging environment
|
|
535
|
+
});
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
371
540
|
## Survey Widget
|
|
372
541
|
|
|
373
542
|
The SDK includes a powerful survey widget for collecting structured user feedback through NPS, CSAT, CES, and custom surveys. Surveys can be triggered manually, on specific events, or managed through the backend dashboard.
|
package/dist/README.md
CHANGED
|
@@ -21,6 +21,10 @@ A lightweight, customizable JavaScript SDK for collecting user feedback on any w
|
|
|
21
21
|
- **TypeScript support** — Full type definitions included
|
|
22
22
|
- **Accessible** — WCAG 2.1 compliant
|
|
23
23
|
- **Secure** — CSP friendly, no `eval()` usage
|
|
24
|
+
- **Messenger widget** — Real-time chat with WebSocket support
|
|
25
|
+
- **Help center** — Integrated help articles and collections
|
|
26
|
+
- **Changelog** — Display product updates and announcements
|
|
27
|
+
- **Environment auto-detection** — Automatic staging/production switching
|
|
24
28
|
|
|
25
29
|
---
|
|
26
30
|
|
|
@@ -126,19 +130,34 @@ const inline = feedback.createWidget('inline');
|
|
|
126
130
|
inline.mount('#feedback-container');
|
|
127
131
|
```
|
|
128
132
|
|
|
133
|
+
**Messenger Widget**
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
const messenger = feedback.createWidget('messenger', {
|
|
137
|
+
position: 'bottom-right',
|
|
138
|
+
theme: 'light',
|
|
139
|
+
teamName: 'Support',
|
|
140
|
+
enableHelp: true,
|
|
141
|
+
enableChangelog: true,
|
|
142
|
+
});
|
|
143
|
+
messenger.mount();
|
|
144
|
+
```
|
|
145
|
+
|
|
129
146
|
---
|
|
130
147
|
|
|
131
148
|
## Configuration
|
|
132
149
|
|
|
133
150
|
### SDK Configuration
|
|
134
151
|
|
|
135
|
-
| Option | Type | Required | Default
|
|
136
|
-
| ------------- | ------- | -------- |
|
|
137
|
-
| `workspace` | string | ✅ | -
|
|
138
|
-
| `boardId` | string | ❌ | 'general'
|
|
139
|
-
| `userContext` | object | ❌ | null
|
|
140
|
-
| `mock` | boolean | ❌ | false
|
|
141
|
-
| `debug` | boolean | ❌ | false
|
|
152
|
+
| Option | Type | Required | Default | Description |
|
|
153
|
+
| ------------- | ------- | -------- | ------------ | ------------------------------------- |
|
|
154
|
+
| `workspace` | string | ✅ | - | Your workspace subdomain |
|
|
155
|
+
| `boardId` | string | ❌ | 'general' | Target board for feedback |
|
|
156
|
+
| `userContext` | object | ❌ | null | User identification data |
|
|
157
|
+
| `mock` | boolean | ❌ | false | Enable mock mode for development |
|
|
158
|
+
| `debug` | boolean | ❌ | false | Enable debug logging |
|
|
159
|
+
| `env` | string | ❌ | auto-detect | Environment: 'production' or 'staging'|
|
|
160
|
+
| `apiUrl` | string | ❌ | null | Custom API URL (overrides env) |
|
|
142
161
|
|
|
143
162
|
### Widget Configuration
|
|
144
163
|
|
|
@@ -234,6 +253,10 @@ Mock mode simulates:
|
|
|
234
253
|
- Session initialization
|
|
235
254
|
- Feedback submission (with 500ms delay)
|
|
236
255
|
- Default configuration values
|
|
256
|
+
- Messenger conversations and messages
|
|
257
|
+
- Help articles and collections
|
|
258
|
+
- Changelog entries
|
|
259
|
+
- Agent availability status
|
|
237
260
|
|
|
238
261
|
---
|
|
239
262
|
|
|
@@ -368,6 +391,152 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
368
391
|
|
|
369
392
|
---
|
|
370
393
|
|
|
394
|
+
## Messenger Widget
|
|
395
|
+
|
|
396
|
+
The SDK includes a full-featured messenger widget for real-time customer conversations, help articles, and changelog updates.
|
|
397
|
+
|
|
398
|
+
### Features
|
|
399
|
+
|
|
400
|
+
- **Real-time messaging** — WebSocket-powered live chat with typing indicators
|
|
401
|
+
- **Conversation management** — View and manage multiple conversations
|
|
402
|
+
- **Help center integration** — Browse help articles and collections
|
|
403
|
+
- **Changelog updates** — Display product updates and announcements
|
|
404
|
+
- **Agent availability** — Show online status and response times
|
|
405
|
+
- **Customizable UI** — Theme, colors, and position options
|
|
406
|
+
|
|
407
|
+
### Quick Start
|
|
408
|
+
|
|
409
|
+
```javascript
|
|
410
|
+
const feedback = new FeedbackSDK({
|
|
411
|
+
workspace: 'your-workspace',
|
|
412
|
+
userContext: {
|
|
413
|
+
user_id: 'user_123',
|
|
414
|
+
email: 'user@example.com',
|
|
415
|
+
name: 'John Doe',
|
|
416
|
+
},
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
await feedback.init();
|
|
420
|
+
|
|
421
|
+
const messenger = feedback.createWidget('messenger', {
|
|
422
|
+
position: 'bottom-right',
|
|
423
|
+
theme: 'light',
|
|
424
|
+
teamName: 'Support Team',
|
|
425
|
+
welcomeMessage: 'How can we help you today?',
|
|
426
|
+
enableHelp: true,
|
|
427
|
+
enableChangelog: true,
|
|
428
|
+
primaryColor: '#1c1c1e',
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
messenger.mount();
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Messenger Configuration Options
|
|
435
|
+
|
|
436
|
+
| Option | Type | Default | Description |
|
|
437
|
+
| ------------------ | -------- | ---------------- | ---------------------------------------- |
|
|
438
|
+
| `position` | string | 'bottom-right' | Widget position on screen |
|
|
439
|
+
| `theme` | string | 'light' | 'light' or 'dark' |
|
|
440
|
+
| `teamName` | string | 'Support' | Team name displayed in header |
|
|
441
|
+
| `teamAvatars` | array | [] | Array of team member avatar URLs |
|
|
442
|
+
| `welcomeMessage` | string | 'How can we help?' | Welcome message on home view |
|
|
443
|
+
| `enableHelp` | boolean | true | Show help articles section |
|
|
444
|
+
| `enableChangelog` | boolean | true | Show changelog section |
|
|
445
|
+
| `logoUrl` | string | - | Custom logo URL |
|
|
446
|
+
| `primaryColor` | string | '#1c1c1e' | Primary accent color |
|
|
447
|
+
| `onSendMessage` | function | null | Callback when message is sent |
|
|
448
|
+
| `onArticleClick` | function | null | Callback when help article is clicked |
|
|
449
|
+
| `onChangelogClick` | function | null | Callback when changelog item is clicked |
|
|
450
|
+
|
|
451
|
+
### Messenger Views
|
|
452
|
+
|
|
453
|
+
The messenger widget includes multiple views:
|
|
454
|
+
|
|
455
|
+
| View | Description |
|
|
456
|
+
| --------------- | ---------------------------------------------- |
|
|
457
|
+
| `home` | Welcome screen with quick actions |
|
|
458
|
+
| `messages` | List of all conversations |
|
|
459
|
+
| `chat` | Individual conversation chat view |
|
|
460
|
+
| `help` | Help articles and collections |
|
|
461
|
+
| `changelog` | Product updates and announcements |
|
|
462
|
+
|
|
463
|
+
### Programmatic Control
|
|
464
|
+
|
|
465
|
+
```javascript
|
|
466
|
+
// Open/close messenger
|
|
467
|
+
messenger.open();
|
|
468
|
+
messenger.close();
|
|
469
|
+
messenger.toggle();
|
|
470
|
+
|
|
471
|
+
// Navigate to specific view
|
|
472
|
+
messenger.navigateTo('messages');
|
|
473
|
+
messenger.navigateTo('help');
|
|
474
|
+
messenger.navigateTo('changelog');
|
|
475
|
+
|
|
476
|
+
// Get current state
|
|
477
|
+
const state = messenger.getState();
|
|
478
|
+
console.log(state.isOpen, state.currentView, state.unreadCount);
|
|
479
|
+
|
|
480
|
+
// Update unread count
|
|
481
|
+
messenger.setUnreadCount(3);
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### Real-time Events
|
|
485
|
+
|
|
486
|
+
```javascript
|
|
487
|
+
// Message sent
|
|
488
|
+
feedback.eventBus.on('messenger:messageSent', (data) => {
|
|
489
|
+
console.log('Message sent:', data.message);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
// Messenger opened/closed
|
|
493
|
+
feedback.eventBus.on('messenger:opened', () => {
|
|
494
|
+
console.log('Messenger opened');
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
feedback.eventBus.on('messenger:closed', () => {
|
|
498
|
+
console.log('Messenger closed');
|
|
499
|
+
});
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
### WebSocket Connection
|
|
503
|
+
|
|
504
|
+
The messenger automatically establishes a WebSocket connection for real-time features:
|
|
505
|
+
|
|
506
|
+
- **Incoming messages** — New messages appear instantly
|
|
507
|
+
- **Typing indicators** — See when agents are typing
|
|
508
|
+
- **Presence updates** — Real-time agent availability
|
|
509
|
+
|
|
510
|
+
The WebSocket connection is managed automatically and reconnects on disconnection.
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## Environment Auto-Detection
|
|
515
|
+
|
|
516
|
+
The SDK automatically detects the environment based on the hostname:
|
|
517
|
+
|
|
518
|
+
| Hostname Pattern | Environment |
|
|
519
|
+
| ----------------------------------------- | ----------- |
|
|
520
|
+
| `localhost`, `127.0.0.1`, `*.local` | staging |
|
|
521
|
+
| Contains `staging` | staging |
|
|
522
|
+
| All other hostnames | production |
|
|
523
|
+
|
|
524
|
+
```javascript
|
|
525
|
+
// Auto-detection (recommended)
|
|
526
|
+
const feedback = new FeedbackSDK({
|
|
527
|
+
workspace: 'your-workspace',
|
|
528
|
+
// env is auto-detected from window.location.hostname
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
// Manual override
|
|
532
|
+
const feedback = new FeedbackSDK({
|
|
533
|
+
workspace: 'your-workspace',
|
|
534
|
+
env: 'staging', // Force staging environment
|
|
535
|
+
});
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
371
540
|
## Survey Widget
|
|
372
541
|
|
|
373
542
|
The SDK includes a powerful survey widget for collecting structured user feedback through NPS, CSAT, CES, and custom surveys. Surveys can be triggered manually, on specific events, or managed through the backend dashboard.
|