@product7/feedback-sdk 1.6.5 → 1.6.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 +4 -0
- package/dist/README.md +4 -0
- package/dist/feedback-sdk.js +72 -8
- 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/widgets/MessengerWidget.js +72 -8
- package/types/index.d.ts +23 -0
package/README.md
CHANGED
|
@@ -439,6 +439,10 @@ messenger.mount();
|
|
|
439
439
|
| `welcomeMessage` | string | 'How can we help?' | Welcome message on home view |
|
|
440
440
|
| `enableHelp` | boolean | true | Show help articles section |
|
|
441
441
|
| `enableChangelog` | boolean | true | Show changelog section |
|
|
442
|
+
| `enableNews` | boolean | - | Alias for `enableChangelog` |
|
|
443
|
+
| `autoLoadData` | boolean | true | Auto-fetch conversations/help/changelog |
|
|
444
|
+
| `initialView` | string | 'home' | Initial view on mount |
|
|
445
|
+
| `previewData` | object | null | Seed deterministic local data |
|
|
442
446
|
| `logoUrl` | string | - | Custom logo URL |
|
|
443
447
|
| `primaryColor` | string | '#155EEF' | Primary accent color |
|
|
444
448
|
| `onSendMessage` | function | null | Callback when message is sent |
|
package/dist/README.md
CHANGED
|
@@ -439,6 +439,10 @@ messenger.mount();
|
|
|
439
439
|
| `welcomeMessage` | string | 'How can we help?' | Welcome message on home view |
|
|
440
440
|
| `enableHelp` | boolean | true | Show help articles section |
|
|
441
441
|
| `enableChangelog` | boolean | true | Show changelog section |
|
|
442
|
+
| `enableNews` | boolean | - | Alias for `enableChangelog` |
|
|
443
|
+
| `autoLoadData` | boolean | true | Auto-fetch conversations/help/changelog |
|
|
444
|
+
| `initialView` | string | 'home' | Initial view on mount |
|
|
445
|
+
| `previewData` | object | null | Seed deterministic local data |
|
|
442
446
|
| `logoUrl` | string | - | Custom logo URL |
|
|
443
447
|
| `primaryColor` | string | '#155EEF' | Primary accent color |
|
|
444
448
|
| `onSendMessage` | function | null | Callback when message is sent |
|
package/dist/feedback-sdk.js
CHANGED
|
@@ -5902,6 +5902,11 @@
|
|
|
5902
5902
|
constructor(options) {
|
|
5903
5903
|
super({ ...options, type: 'messenger' });
|
|
5904
5904
|
|
|
5905
|
+
const resolvedEnableChangelog =
|
|
5906
|
+
typeof options.enableChangelog === 'boolean'
|
|
5907
|
+
? options.enableChangelog
|
|
5908
|
+
: options.enableNews !== false;
|
|
5909
|
+
|
|
5905
5910
|
this.messengerOptions = {
|
|
5906
5911
|
position: options.position || 'bottom-right',
|
|
5907
5912
|
theme: options.theme || 'light',
|
|
@@ -5914,7 +5919,10 @@
|
|
|
5914
5919
|
greetingMessage: options.greetingMessage || 'Hi there 👋',
|
|
5915
5920
|
welcomeMessage: options.welcomeMessage || 'How can we help?',
|
|
5916
5921
|
enableHelp: options.enableHelp !== false,
|
|
5917
|
-
enableChangelog:
|
|
5922
|
+
enableChangelog: resolvedEnableChangelog,
|
|
5923
|
+
autoLoadData: options.autoLoadData !== false,
|
|
5924
|
+
initialView: options.initialView || 'home',
|
|
5925
|
+
previewData: options.previewData || null,
|
|
5918
5926
|
featuredContent: options.featuredContent || null,
|
|
5919
5927
|
feedbackUrl: options.feedbackUrl || null,
|
|
5920
5928
|
changelogUrl: options.changelogUrl || null,
|
|
@@ -6382,6 +6390,51 @@
|
|
|
6382
6390
|
};
|
|
6383
6391
|
}
|
|
6384
6392
|
|
|
6393
|
+
_applyPreviewData() {
|
|
6394
|
+
const data = this.messengerOptions.previewData;
|
|
6395
|
+
if (!data || typeof data !== 'object') {
|
|
6396
|
+
return;
|
|
6397
|
+
}
|
|
6398
|
+
|
|
6399
|
+
if (Array.isArray(data.conversations)) {
|
|
6400
|
+
this.messengerState.setConversations(data.conversations);
|
|
6401
|
+
}
|
|
6402
|
+
|
|
6403
|
+
if (Array.isArray(data.helpArticles)) {
|
|
6404
|
+
this.messengerState.setHelpArticles(data.helpArticles);
|
|
6405
|
+
}
|
|
6406
|
+
|
|
6407
|
+
if (Array.isArray(data.homeChangelogItems)) {
|
|
6408
|
+
this.messengerState.setHomeChangelogItems(data.homeChangelogItems);
|
|
6409
|
+
}
|
|
6410
|
+
|
|
6411
|
+
if (Array.isArray(data.changelogItems)) {
|
|
6412
|
+
this.messengerState.setChangelogItems(data.changelogItems);
|
|
6413
|
+
}
|
|
6414
|
+
|
|
6415
|
+
if (typeof data.unreadCount === 'number') {
|
|
6416
|
+
this.setUnreadCount(data.unreadCount);
|
|
6417
|
+
}
|
|
6418
|
+
|
|
6419
|
+
if (data.availability && typeof data.availability === 'object') {
|
|
6420
|
+
const availability = data.availability;
|
|
6421
|
+
this.messengerState.agentsOnline = Boolean(
|
|
6422
|
+
availability.agentsOnline ?? availability.agents_online
|
|
6423
|
+
);
|
|
6424
|
+
this.messengerState.onlineCount =
|
|
6425
|
+
availability.onlineCount ?? availability.online_count ?? 0;
|
|
6426
|
+
this.messengerState.responseTime =
|
|
6427
|
+
availability.responseTime ??
|
|
6428
|
+
availability.response_time ??
|
|
6429
|
+
this.messengerState.responseTime;
|
|
6430
|
+
this.messengerState._notify('availabilityUpdate', availability);
|
|
6431
|
+
}
|
|
6432
|
+
|
|
6433
|
+
if (typeof data.currentView === 'string') {
|
|
6434
|
+
this.messengerState.setView(data.currentView);
|
|
6435
|
+
}
|
|
6436
|
+
}
|
|
6437
|
+
|
|
6385
6438
|
async loadInitialData() {
|
|
6386
6439
|
try {
|
|
6387
6440
|
const conversations = await this._fetchConversations();
|
|
@@ -6708,17 +6761,28 @@
|
|
|
6708
6761
|
}
|
|
6709
6762
|
|
|
6710
6763
|
async onMount() {
|
|
6711
|
-
this.
|
|
6764
|
+
this._applyPreviewData();
|
|
6712
6765
|
|
|
6713
|
-
if (this.
|
|
6714
|
-
this.
|
|
6715
|
-
}
|
|
6766
|
+
if (this.messengerOptions.autoLoadData) {
|
|
6767
|
+
this.loadInitialData();
|
|
6716
6768
|
|
|
6717
|
-
|
|
6769
|
+
if (this.apiService?.sessionToken) {
|
|
6770
|
+
this._initWebSocket();
|
|
6771
|
+
}
|
|
6718
6772
|
|
|
6719
|
-
this._availabilityInterval = setInterval(() => {
|
|
6720
6773
|
this.checkAgentAvailability();
|
|
6721
|
-
|
|
6774
|
+
|
|
6775
|
+
this._availabilityInterval = setInterval(() => {
|
|
6776
|
+
this.checkAgentAvailability();
|
|
6777
|
+
}, 60000);
|
|
6778
|
+
}
|
|
6779
|
+
|
|
6780
|
+
if (
|
|
6781
|
+
this.messengerOptions.initialView &&
|
|
6782
|
+
this.messengerOptions.initialView !== this.messengerState.currentView
|
|
6783
|
+
) {
|
|
6784
|
+
this.messengerState.setView(this.messengerOptions.initialView);
|
|
6785
|
+
}
|
|
6722
6786
|
}
|
|
6723
6787
|
|
|
6724
6788
|
onDestroy() {
|