@product7/feedback-sdk 1.4.0 → 1.4.2
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 +2 -2
- package/dist/README.md +2 -2
- package/dist/feedback-sdk.js +242 -105
- 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 +1 -1
- package/src/styles/messengerCustomStyles.js +105 -0
- package/src/widgets/MessengerWidget.js +139 -104
package/package.json
CHANGED
package/src/core/APIService.js
CHANGED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export function applyMessengerCustomStyles(options = {}) {
|
|
2
|
+
const {
|
|
3
|
+
primaryColor = '#155EEF',
|
|
4
|
+
textColor = '#1d1d1f',
|
|
5
|
+
backgroundColor = '#ffffff',
|
|
6
|
+
theme = 'light',
|
|
7
|
+
} = options;
|
|
8
|
+
|
|
9
|
+
let styleElement = document.getElementById(
|
|
10
|
+
'product7-messenger-custom-styles'
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
if (!styleElement) {
|
|
14
|
+
styleElement = document.createElement('style');
|
|
15
|
+
styleElement.id = 'product7-messenger-custom-styles';
|
|
16
|
+
document.head.appendChild(styleElement);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const adjustColor = (hex, percent, alpha = 1) => {
|
|
20
|
+
const num = parseInt(hex.replace('#', ''), 16);
|
|
21
|
+
const r = Math.max(0, Math.min(255, (num >> 16) + percent));
|
|
22
|
+
const g = Math.max(0, Math.min(255, ((num >> 8) & 0x00ff) + percent));
|
|
23
|
+
const b = Math.max(0, Math.min(255, (num & 0x0000ff) + percent));
|
|
24
|
+
|
|
25
|
+
if (alpha < 1) {
|
|
26
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return '#' + ((r << 16) | (g << 8) | b).toString(16).padStart(6, '0');
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
styleElement.textContent = `
|
|
33
|
+
#product7-messenger-widget {
|
|
34
|
+
--color-primary: ${primaryColor} !important;
|
|
35
|
+
--color-primary-hover: ${adjustColor(primaryColor, -10)} !important;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.messenger-launcher-btn {
|
|
39
|
+
background: ${primaryColor} !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.messenger-launcher-btn:hover {
|
|
43
|
+
box-shadow: 0 8px 24px ${adjustColor(primaryColor, 0, 0.3)} !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sdk-btn-primary {
|
|
47
|
+
background: ${primaryColor} !important;
|
|
48
|
+
border-color: ${primaryColor} !important;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.sdk-btn-primary:hover {
|
|
52
|
+
background: ${adjustColor(primaryColor, -10)} !important;
|
|
53
|
+
border-color: ${adjustColor(primaryColor, -10)} !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.messenger-compose-send {
|
|
57
|
+
background: ${primaryColor} !important;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.messenger-compose-send:hover:not(:disabled) {
|
|
61
|
+
background: ${adjustColor(primaryColor, -10)} !important;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.messenger-nav-tab.active .messenger-nav-icon,
|
|
65
|
+
.messenger-nav-tab.active .messenger-nav-label {
|
|
66
|
+
color: ${primaryColor} !important;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.messenger-home-view::before {
|
|
70
|
+
background: radial-gradient(circle, ${adjustColor(primaryColor, 0, 0.08)} 0%, transparent 70%) !important;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
${
|
|
74
|
+
backgroundColor !== '#ffffff'
|
|
75
|
+
? `
|
|
76
|
+
.messenger-panel-content {
|
|
77
|
+
background: ${backgroundColor} !important;
|
|
78
|
+
}
|
|
79
|
+
`
|
|
80
|
+
: ''
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
${
|
|
84
|
+
textColor !== '#1d1d1f'
|
|
85
|
+
? `
|
|
86
|
+
.messenger-panel-content,
|
|
87
|
+
.messenger-view {
|
|
88
|
+
color: ${textColor} !important;
|
|
89
|
+
}
|
|
90
|
+
`
|
|
91
|
+
: ''
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
console.log('✅ Custom messenger styles applied:', { primaryColor, theme });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function removeMessengerCustomStyles() {
|
|
99
|
+
const styleElement = document.getElementById(
|
|
100
|
+
'product7-messenger-custom-styles'
|
|
101
|
+
);
|
|
102
|
+
if (styleElement && styleElement.parentNode) {
|
|
103
|
+
styleElement.parentNode.removeChild(styleElement);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { WebSocketService } from '../core/WebSocketService.js';
|
|
2
|
+
import {
|
|
3
|
+
applyMessengerCustomStyles,
|
|
4
|
+
removeMessengerCustomStyles,
|
|
5
|
+
} from '../styles/messengerCustomStyles.js';
|
|
2
6
|
import { BaseWidget } from './BaseWidget.js';
|
|
3
7
|
import { MessengerState } from './messenger/MessengerState.js';
|
|
4
8
|
import { MessengerLauncher } from './messenger/components/MessengerLauncher.js';
|
|
@@ -17,14 +21,16 @@ export class MessengerWidget extends BaseWidget {
|
|
|
17
21
|
this.messengerOptions = {
|
|
18
22
|
position: options.position || 'bottom-right',
|
|
19
23
|
theme: options.theme || 'light',
|
|
24
|
+
primaryColor: options.primaryColor || '#155EEF',
|
|
25
|
+
textColor: options.textColor || '#1d1d1f',
|
|
26
|
+
backgroundColor: options.backgroundColor || '#ffffff',
|
|
27
|
+
logoUrl: options.logoUrl || 'https://product7.io/p7logo.svg',
|
|
20
28
|
teamName: options.teamName || 'Support',
|
|
21
29
|
teamAvatars: options.teamAvatars || [],
|
|
22
30
|
welcomeMessage: options.welcomeMessage || 'How can we help?',
|
|
23
31
|
enableHelp: options.enableHelp !== false,
|
|
24
32
|
enableChangelog: options.enableChangelog !== false,
|
|
25
|
-
logoUrl: options.logoUrl || 'https://product7.io/p7logo.svg',
|
|
26
33
|
featuredContent: options.featuredContent || null,
|
|
27
|
-
primaryColor: options.primaryColor || '#1c1c1e',
|
|
28
34
|
onSendMessage: options.onSendMessage || null,
|
|
29
35
|
onArticleClick: options.onArticleClick || null,
|
|
30
36
|
onChangelogClick: options.onChangelogClick || null,
|
|
@@ -56,6 +62,13 @@ export class MessengerWidget extends BaseWidget {
|
|
|
56
62
|
container.className = `messenger-widget theme-${this.messengerOptions.theme}`;
|
|
57
63
|
container.style.zIndex = '999999';
|
|
58
64
|
|
|
65
|
+
applyMessengerCustomStyles({
|
|
66
|
+
primaryColor: this.messengerOptions.primaryColor,
|
|
67
|
+
textColor: this.messengerOptions.textColor,
|
|
68
|
+
backgroundColor: this.messengerOptions.backgroundColor,
|
|
69
|
+
theme: this.messengerOptions.theme,
|
|
70
|
+
});
|
|
71
|
+
|
|
59
72
|
this.launcher = new MessengerLauncher(this.messengerState, {
|
|
60
73
|
position: this.messengerOptions.position,
|
|
61
74
|
primaryColor: this.messengerOptions.primaryColor,
|
|
@@ -526,25 +539,25 @@ export class MessengerWidget extends BaseWidget {
|
|
|
526
539
|
}
|
|
527
540
|
}
|
|
528
541
|
|
|
529
|
-
async _fetchHelpArticles() {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
542
|
+
async _fetchHelpArticles() {
|
|
543
|
+
try {
|
|
544
|
+
const response = await this.apiService.getHelpCollections();
|
|
545
|
+
if (response.success && response.data) {
|
|
546
|
+
const collections = response.data.collections || response.data;
|
|
547
|
+
return collections.map((collection) => ({
|
|
548
|
+
id: collection.id,
|
|
549
|
+
title: collection.title,
|
|
550
|
+
description: collection.description || '',
|
|
551
|
+
articleCount: collection.article_count || 0,
|
|
552
|
+
url: collection.url_slug ? `/help-docs/${collection.url_slug}` : null,
|
|
553
|
+
}));
|
|
554
|
+
}
|
|
555
|
+
return [];
|
|
556
|
+
} catch (error) {
|
|
557
|
+
console.error('[MessengerWidget] Failed to fetch help articles:', error);
|
|
558
|
+
return [];
|
|
559
|
+
}
|
|
560
|
+
}
|
|
548
561
|
|
|
549
562
|
async fetchMessages(conversationId) {
|
|
550
563
|
try {
|
|
@@ -669,89 +682,109 @@ async _fetchHelpArticles() {
|
|
|
669
682
|
}
|
|
670
683
|
}
|
|
671
684
|
|
|
672
|
-
async _fetchChangelog() {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
685
|
+
async _fetchChangelog() {
|
|
686
|
+
if (this.apiService?.mock) {
|
|
687
|
+
return {
|
|
688
|
+
homeItems: [
|
|
689
|
+
{
|
|
690
|
+
id: 'changelog_5',
|
|
691
|
+
title: 'New integrations available',
|
|
692
|
+
description:
|
|
693
|
+
'Connect with more tools you love and streamline your workflow.',
|
|
694
|
+
tags: ['Integration'],
|
|
695
|
+
coverImage:
|
|
696
|
+
'https://images.unsplash.com/photo-1674027444485-cec3da58eef4?w=500&auto=format&fit=crop&q=60',
|
|
697
|
+
publishedAt: new Date(
|
|
698
|
+
Date.now() - 14 * 24 * 60 * 60 * 1000
|
|
699
|
+
).toISOString(),
|
|
700
|
+
url: '#',
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
id: 'changelog_2',
|
|
704
|
+
title: 'A new era of Insights has arrived',
|
|
705
|
+
description:
|
|
706
|
+
'We announced Fin Insights, a groundbreaking, AI-powered product that gives you complete visibility into every customer conversation.',
|
|
707
|
+
tags: ['New feature', 'AI'],
|
|
708
|
+
coverImage:
|
|
709
|
+
'https://images.unsplash.com/photo-1666875753105-c63a6f3bdc86?w=500&auto=format&fit=crop&q=60',
|
|
710
|
+
publishedAt: new Date(
|
|
711
|
+
Date.now() - 5 * 24 * 60 * 60 * 1000
|
|
712
|
+
).toISOString(),
|
|
713
|
+
url: '#',
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
id: 'changelog_1',
|
|
717
|
+
title: 'The 2025 Customer Service Transformation Report',
|
|
718
|
+
description:
|
|
719
|
+
'Learn how AI has transformed customer service from the ground up—rewriting its economics and reshaping expectations.',
|
|
720
|
+
tags: ['Report'],
|
|
721
|
+
coverImage:
|
|
722
|
+
'https://images.unsplash.com/photo-1762330467475-a565d04e1808?w=500&auto=format&fit=crop&q=60',
|
|
723
|
+
publishedAt: new Date(
|
|
724
|
+
Date.now() - 2 * 24 * 60 * 60 * 1000
|
|
725
|
+
).toISOString(),
|
|
726
|
+
url: '#',
|
|
727
|
+
},
|
|
728
|
+
],
|
|
729
|
+
changelogItems: [
|
|
730
|
+
{
|
|
731
|
+
id: 'changelog_4',
|
|
732
|
+
title: 'Enhanced conversation analytics',
|
|
733
|
+
description:
|
|
734
|
+
'Get deeper insights into your customer conversations with our new analytics dashboard.',
|
|
735
|
+
tags: ['Analytics'],
|
|
736
|
+
coverImage:
|
|
737
|
+
'https://images.unsplash.com/photo-1523961131990-5ea7c61b2107?w=500&auto=format&fit=crop&q=60',
|
|
738
|
+
publishedAt: new Date(
|
|
739
|
+
Date.now() - 10 * 24 * 60 * 60 * 1000
|
|
740
|
+
).toISOString(),
|
|
741
|
+
url: '#',
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
id: 'changelog_3',
|
|
745
|
+
title: 'Escalation guidance for complex issues',
|
|
746
|
+
description:
|
|
747
|
+
'New AI-powered escalation guidance helps your team handle complex customer issues more effectively.',
|
|
748
|
+
tags: ['New feature', 'AI'],
|
|
749
|
+
coverImage:
|
|
750
|
+
'https://images.unsplash.com/photo-1764773516703-b246ac2ad5ef?w=500&auto=format&fit=crop&q=60',
|
|
751
|
+
publishedAt: new Date(
|
|
752
|
+
Date.now() - 7 * 24 * 60 * 60 * 1000
|
|
753
|
+
).toISOString(),
|
|
754
|
+
url: '#',
|
|
755
|
+
},
|
|
756
|
+
],
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
try {
|
|
761
|
+
const response = await this.apiService.getChangelogs({ limit: 20 });
|
|
762
|
+
|
|
763
|
+
if (response.success && response.data) {
|
|
764
|
+
const changelogs = Array.isArray(response.data) ? response.data : [];
|
|
765
|
+
|
|
766
|
+
const mappedItems = changelogs.map((item) => ({
|
|
767
|
+
id: item.id,
|
|
768
|
+
title: item.title,
|
|
769
|
+
description: item.excerpt || item.description || '',
|
|
770
|
+
tags: item.labels ? item.labels.map((label) => label.name) : [],
|
|
771
|
+
coverImage: item.cover_image || null,
|
|
772
|
+
publishedAt: item.published_at,
|
|
773
|
+
url: item.slug ? `/changelog/${item.slug}` : null,
|
|
774
|
+
}));
|
|
775
|
+
|
|
776
|
+
return {
|
|
777
|
+
homeItems: mappedItems.slice(0, 3),
|
|
778
|
+
changelogItems: mappedItems,
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
return { homeItems: [], changelogItems: [] };
|
|
783
|
+
} catch (error) {
|
|
784
|
+
console.error('[MessengerWidget] Failed to fetch changelog:', error);
|
|
785
|
+
return { homeItems: [], changelogItems: [] };
|
|
786
|
+
}
|
|
787
|
+
}
|
|
755
788
|
|
|
756
789
|
async onMount() {
|
|
757
790
|
this.loadInitialData();
|
|
@@ -785,6 +818,8 @@ async _fetchChangelog() {
|
|
|
785
818
|
}
|
|
786
819
|
|
|
787
820
|
destroy() {
|
|
821
|
+
removeMessengerCustomStyles();
|
|
822
|
+
|
|
788
823
|
if (this.launcher) {
|
|
789
824
|
this.launcher.destroy();
|
|
790
825
|
}
|