@product7/feedback-sdk 1.4.0 → 1.4.1
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/README.md
CHANGED
|
@@ -425,7 +425,7 @@ const messenger = feedback.createWidget('messenger', {
|
|
|
425
425
|
welcomeMessage: 'How can we help you today?',
|
|
426
426
|
enableHelp: true,
|
|
427
427
|
enableChangelog: true,
|
|
428
|
-
primaryColor: '#
|
|
428
|
+
primaryColor: '#155EEF',
|
|
429
429
|
});
|
|
430
430
|
|
|
431
431
|
messenger.mount();
|
|
@@ -443,7 +443,7 @@ messenger.mount();
|
|
|
443
443
|
| `enableHelp` | boolean | true | Show help articles section |
|
|
444
444
|
| `enableChangelog` | boolean | true | Show changelog section |
|
|
445
445
|
| `logoUrl` | string | - | Custom logo URL |
|
|
446
|
-
| `primaryColor` | string | '#
|
|
446
|
+
| `primaryColor` | string | '#155EEF' | Primary accent color |
|
|
447
447
|
| `onSendMessage` | function | null | Callback when message is sent |
|
|
448
448
|
| `onArticleClick` | function | null | Callback when help article is clicked |
|
|
449
449
|
| `onChangelogClick` | function | null | Callback when changelog item is clicked |
|
package/dist/README.md
CHANGED
|
@@ -425,7 +425,7 @@ const messenger = feedback.createWidget('messenger', {
|
|
|
425
425
|
welcomeMessage: 'How can we help you today?',
|
|
426
426
|
enableHelp: true,
|
|
427
427
|
enableChangelog: true,
|
|
428
|
-
primaryColor: '#
|
|
428
|
+
primaryColor: '#155EEF',
|
|
429
429
|
});
|
|
430
430
|
|
|
431
431
|
messenger.mount();
|
|
@@ -443,7 +443,7 @@ messenger.mount();
|
|
|
443
443
|
| `enableHelp` | boolean | true | Show help articles section |
|
|
444
444
|
| `enableChangelog` | boolean | true | Show changelog section |
|
|
445
445
|
| `logoUrl` | string | - | Custom logo URL |
|
|
446
|
-
| `primaryColor` | string | '#
|
|
446
|
+
| `primaryColor` | string | '#155EEF' | Primary accent color |
|
|
447
447
|
| `onSendMessage` | function | null | Callback when message is sent |
|
|
448
448
|
| `onArticleClick` | function | null | Callback when help article is clicked |
|
|
449
449
|
| `onChangelogClick` | function | null | Callback when changelog item is clicked |
|
package/dist/feedback-sdk.js
CHANGED
|
@@ -1283,7 +1283,7 @@
|
|
|
1283
1283
|
}
|
|
1284
1284
|
|
|
1285
1285
|
async getChangelogs(options) {
|
|
1286
|
-
|
|
1286
|
+
return this.changelog.getChangelogs(options);
|
|
1287
1287
|
}
|
|
1288
1288
|
|
|
1289
1289
|
_loadStoredSession() {
|
|
@@ -3256,6 +3256,112 @@
|
|
|
3256
3256
|
}
|
|
3257
3257
|
}
|
|
3258
3258
|
|
|
3259
|
+
function applyMessengerCustomStyles(options = {}) {
|
|
3260
|
+
const {
|
|
3261
|
+
primaryColor = '#155EEF',
|
|
3262
|
+
textColor = '#1d1d1f',
|
|
3263
|
+
backgroundColor = '#ffffff',
|
|
3264
|
+
theme = 'light',
|
|
3265
|
+
} = options;
|
|
3266
|
+
|
|
3267
|
+
let styleElement = document.getElementById(
|
|
3268
|
+
'product7-messenger-custom-styles'
|
|
3269
|
+
);
|
|
3270
|
+
|
|
3271
|
+
if (!styleElement) {
|
|
3272
|
+
styleElement = document.createElement('style');
|
|
3273
|
+
styleElement.id = 'product7-messenger-custom-styles';
|
|
3274
|
+
document.head.appendChild(styleElement);
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
const adjustColor = (hex, percent, alpha = 1) => {
|
|
3278
|
+
const num = parseInt(hex.replace('#', ''), 16);
|
|
3279
|
+
const r = Math.max(0, Math.min(255, (num >> 16) + percent));
|
|
3280
|
+
const g = Math.max(0, Math.min(255, ((num >> 8) & 0x00ff) + percent));
|
|
3281
|
+
const b = Math.max(0, Math.min(255, (num & 0x0000ff) + percent));
|
|
3282
|
+
|
|
3283
|
+
if (alpha < 1) {
|
|
3284
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
return '#' + ((r << 16) | (g << 8) | b).toString(16).padStart(6, '0');
|
|
3288
|
+
};
|
|
3289
|
+
|
|
3290
|
+
styleElement.textContent = `
|
|
3291
|
+
#product7-messenger-widget {
|
|
3292
|
+
--color-primary: ${primaryColor} !important;
|
|
3293
|
+
--color-primary-hover: ${adjustColor(primaryColor, -10)} !important;
|
|
3294
|
+
}
|
|
3295
|
+
|
|
3296
|
+
.messenger-launcher-btn {
|
|
3297
|
+
background: ${primaryColor} !important;
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3300
|
+
.messenger-launcher-btn:hover {
|
|
3301
|
+
box-shadow: 0 8px 24px ${adjustColor(primaryColor, 0, 0.3)} !important;
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
.sdk-btn-primary {
|
|
3305
|
+
background: ${primaryColor} !important;
|
|
3306
|
+
border-color: ${primaryColor} !important;
|
|
3307
|
+
}
|
|
3308
|
+
|
|
3309
|
+
.sdk-btn-primary:hover {
|
|
3310
|
+
background: ${adjustColor(primaryColor, -10)} !important;
|
|
3311
|
+
border-color: ${adjustColor(primaryColor, -10)} !important;
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
.messenger-compose-send {
|
|
3315
|
+
background: ${primaryColor} !important;
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
.messenger-compose-send:hover:not(:disabled) {
|
|
3319
|
+
background: ${adjustColor(primaryColor, -10)} !important;
|
|
3320
|
+
}
|
|
3321
|
+
|
|
3322
|
+
.messenger-nav-tab.active .messenger-nav-icon,
|
|
3323
|
+
.messenger-nav-tab.active .messenger-nav-label {
|
|
3324
|
+
color: ${primaryColor} !important;
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
.messenger-home-view::before {
|
|
3328
|
+
background: radial-gradient(circle, ${adjustColor(primaryColor, 0, 0.08)} 0%, transparent 70%) !important;
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
${
|
|
3332
|
+
backgroundColor !== '#ffffff'
|
|
3333
|
+
? `
|
|
3334
|
+
.messenger-panel-content {
|
|
3335
|
+
background: ${backgroundColor} !important;
|
|
3336
|
+
}
|
|
3337
|
+
`
|
|
3338
|
+
: ''
|
|
3339
|
+
}
|
|
3340
|
+
|
|
3341
|
+
${
|
|
3342
|
+
textColor !== '#1d1d1f'
|
|
3343
|
+
? `
|
|
3344
|
+
.messenger-panel-content,
|
|
3345
|
+
.messenger-view {
|
|
3346
|
+
color: ${textColor} !important;
|
|
3347
|
+
}
|
|
3348
|
+
`
|
|
3349
|
+
: ''
|
|
3350
|
+
}
|
|
3351
|
+
`;
|
|
3352
|
+
|
|
3353
|
+
console.log('✅ Custom messenger styles applied:', { primaryColor, theme });
|
|
3354
|
+
}
|
|
3355
|
+
|
|
3356
|
+
function removeMessengerCustomStyles() {
|
|
3357
|
+
const styleElement = document.getElementById(
|
|
3358
|
+
'product7-messenger-custom-styles'
|
|
3359
|
+
);
|
|
3360
|
+
if (styleElement && styleElement.parentNode) {
|
|
3361
|
+
styleElement.parentNode.removeChild(styleElement);
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
|
|
3259
3365
|
class MessengerState {
|
|
3260
3366
|
constructor(options = {}) {
|
|
3261
3367
|
this.currentView = 'home';
|
|
@@ -5565,14 +5671,16 @@
|
|
|
5565
5671
|
this.messengerOptions = {
|
|
5566
5672
|
position: options.position || 'bottom-right',
|
|
5567
5673
|
theme: options.theme || 'light',
|
|
5674
|
+
primaryColor: options.primaryColor || '#155EEF',
|
|
5675
|
+
textColor: options.textColor || '#1d1d1f',
|
|
5676
|
+
backgroundColor: options.backgroundColor || '#ffffff',
|
|
5677
|
+
logoUrl: options.logoUrl || 'https://product7.io/p7logo.svg',
|
|
5568
5678
|
teamName: options.teamName || 'Support',
|
|
5569
5679
|
teamAvatars: options.teamAvatars || [],
|
|
5570
5680
|
welcomeMessage: options.welcomeMessage || 'How can we help?',
|
|
5571
5681
|
enableHelp: options.enableHelp !== false,
|
|
5572
5682
|
enableChangelog: options.enableChangelog !== false,
|
|
5573
|
-
logoUrl: options.logoUrl || 'https://product7.io/p7logo.svg',
|
|
5574
5683
|
featuredContent: options.featuredContent || null,
|
|
5575
|
-
primaryColor: options.primaryColor || '#1c1c1e',
|
|
5576
5684
|
onSendMessage: options.onSendMessage || null,
|
|
5577
5685
|
onArticleClick: options.onArticleClick || null,
|
|
5578
5686
|
onChangelogClick: options.onChangelogClick || null,
|
|
@@ -5604,6 +5712,13 @@
|
|
|
5604
5712
|
container.className = `messenger-widget theme-${this.messengerOptions.theme}`;
|
|
5605
5713
|
container.style.zIndex = '999999';
|
|
5606
5714
|
|
|
5715
|
+
applyMessengerCustomStyles({
|
|
5716
|
+
primaryColor: this.messengerOptions.primaryColor,
|
|
5717
|
+
textColor: this.messengerOptions.textColor,
|
|
5718
|
+
backgroundColor: this.messengerOptions.backgroundColor,
|
|
5719
|
+
theme: this.messengerOptions.theme,
|
|
5720
|
+
});
|
|
5721
|
+
|
|
5607
5722
|
this.launcher = new MessengerLauncher(this.messengerState, {
|
|
5608
5723
|
position: this.messengerOptions.position,
|
|
5609
5724
|
primaryColor: this.messengerOptions.primaryColor,
|
|
@@ -6074,25 +6189,25 @@
|
|
|
6074
6189
|
}
|
|
6075
6190
|
}
|
|
6076
6191
|
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6192
|
+
async _fetchHelpArticles() {
|
|
6193
|
+
try {
|
|
6194
|
+
const response = await this.apiService.getHelpCollections();
|
|
6195
|
+
if (response.success && response.data) {
|
|
6196
|
+
const collections = response.data.collections || response.data;
|
|
6197
|
+
return collections.map((collection) => ({
|
|
6198
|
+
id: collection.id,
|
|
6199
|
+
title: collection.title,
|
|
6200
|
+
description: collection.description || '',
|
|
6201
|
+
articleCount: collection.article_count || 0,
|
|
6202
|
+
url: collection.url_slug ? `/help/${collection.url_slug}` : null,
|
|
6203
|
+
}));
|
|
6204
|
+
}
|
|
6205
|
+
return [];
|
|
6206
|
+
} catch (error) {
|
|
6207
|
+
console.error('[MessengerWidget] Failed to fetch help articles:', error);
|
|
6208
|
+
return [];
|
|
6209
|
+
}
|
|
6210
|
+
}
|
|
6096
6211
|
|
|
6097
6212
|
async fetchMessages(conversationId) {
|
|
6098
6213
|
try {
|
|
@@ -6217,89 +6332,109 @@
|
|
|
6217
6332
|
}
|
|
6218
6333
|
}
|
|
6219
6334
|
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6335
|
+
async _fetchChangelog() {
|
|
6336
|
+
if (this.apiService?.mock) {
|
|
6337
|
+
return {
|
|
6338
|
+
homeItems: [
|
|
6339
|
+
{
|
|
6340
|
+
id: 'changelog_5',
|
|
6341
|
+
title: 'New integrations available',
|
|
6342
|
+
description:
|
|
6343
|
+
'Connect with more tools you love and streamline your workflow.',
|
|
6344
|
+
tags: ['Integration'],
|
|
6345
|
+
coverImage:
|
|
6346
|
+
'https://images.unsplash.com/photo-1674027444485-cec3da58eef4?w=500&auto=format&fit=crop&q=60',
|
|
6347
|
+
publishedAt: new Date(
|
|
6348
|
+
Date.now() - 14 * 24 * 60 * 60 * 1000
|
|
6349
|
+
).toISOString(),
|
|
6350
|
+
url: '#',
|
|
6351
|
+
},
|
|
6352
|
+
{
|
|
6353
|
+
id: 'changelog_2',
|
|
6354
|
+
title: 'A new era of Insights has arrived',
|
|
6355
|
+
description:
|
|
6356
|
+
'We announced Fin Insights, a groundbreaking, AI-powered product that gives you complete visibility into every customer conversation.',
|
|
6357
|
+
tags: ['New feature', 'AI'],
|
|
6358
|
+
coverImage:
|
|
6359
|
+
'https://images.unsplash.com/photo-1666875753105-c63a6f3bdc86?w=500&auto=format&fit=crop&q=60',
|
|
6360
|
+
publishedAt: new Date(
|
|
6361
|
+
Date.now() - 5 * 24 * 60 * 60 * 1000
|
|
6362
|
+
).toISOString(),
|
|
6363
|
+
url: '#',
|
|
6364
|
+
},
|
|
6365
|
+
{
|
|
6366
|
+
id: 'changelog_1',
|
|
6367
|
+
title: 'The 2025 Customer Service Transformation Report',
|
|
6368
|
+
description:
|
|
6369
|
+
'Learn how AI has transformed customer service from the ground up—rewriting its economics and reshaping expectations.',
|
|
6370
|
+
tags: ['Report'],
|
|
6371
|
+
coverImage:
|
|
6372
|
+
'https://images.unsplash.com/photo-1762330467475-a565d04e1808?w=500&auto=format&fit=crop&q=60',
|
|
6373
|
+
publishedAt: new Date(
|
|
6374
|
+
Date.now() - 2 * 24 * 60 * 60 * 1000
|
|
6375
|
+
).toISOString(),
|
|
6376
|
+
url: '#',
|
|
6377
|
+
},
|
|
6378
|
+
],
|
|
6379
|
+
changelogItems: [
|
|
6380
|
+
{
|
|
6381
|
+
id: 'changelog_4',
|
|
6382
|
+
title: 'Enhanced conversation analytics',
|
|
6383
|
+
description:
|
|
6384
|
+
'Get deeper insights into your customer conversations with our new analytics dashboard.',
|
|
6385
|
+
tags: ['Analytics'],
|
|
6386
|
+
coverImage:
|
|
6387
|
+
'https://images.unsplash.com/photo-1523961131990-5ea7c61b2107?w=500&auto=format&fit=crop&q=60',
|
|
6388
|
+
publishedAt: new Date(
|
|
6389
|
+
Date.now() - 10 * 24 * 60 * 60 * 1000
|
|
6390
|
+
).toISOString(),
|
|
6391
|
+
url: '#',
|
|
6392
|
+
},
|
|
6393
|
+
{
|
|
6394
|
+
id: 'changelog_3',
|
|
6395
|
+
title: 'Escalation guidance for complex issues',
|
|
6396
|
+
description:
|
|
6397
|
+
'New AI-powered escalation guidance helps your team handle complex customer issues more effectively.',
|
|
6398
|
+
tags: ['New feature', 'AI'],
|
|
6399
|
+
coverImage:
|
|
6400
|
+
'https://images.unsplash.com/photo-1764773516703-b246ac2ad5ef?w=500&auto=format&fit=crop&q=60',
|
|
6401
|
+
publishedAt: new Date(
|
|
6402
|
+
Date.now() - 7 * 24 * 60 * 60 * 1000
|
|
6403
|
+
).toISOString(),
|
|
6404
|
+
url: '#',
|
|
6405
|
+
},
|
|
6406
|
+
],
|
|
6407
|
+
};
|
|
6408
|
+
}
|
|
6409
|
+
|
|
6410
|
+
try {
|
|
6411
|
+
const response = await this.apiService.getChangelogs({ limit: 20 });
|
|
6412
|
+
|
|
6413
|
+
if (response.success && response.data) {
|
|
6414
|
+
const changelogs = Array.isArray(response.data) ? response.data : [];
|
|
6415
|
+
|
|
6416
|
+
const mappedItems = changelogs.map((item) => ({
|
|
6417
|
+
id: item.id,
|
|
6418
|
+
title: item.title,
|
|
6419
|
+
description: item.excerpt || item.description || '',
|
|
6420
|
+
tags: item.labels ? item.labels.map((label) => label.name) : [],
|
|
6421
|
+
coverImage: item.cover_image || null,
|
|
6422
|
+
publishedAt: item.published_at,
|
|
6423
|
+
url: item.slug ? `/changelog/${item.slug}` : null,
|
|
6424
|
+
}));
|
|
6425
|
+
|
|
6426
|
+
return {
|
|
6427
|
+
homeItems: mappedItems.slice(0, 3),
|
|
6428
|
+
changelogItems: mappedItems,
|
|
6429
|
+
};
|
|
6430
|
+
}
|
|
6431
|
+
|
|
6432
|
+
return { homeItems: [], changelogItems: [] };
|
|
6433
|
+
} catch (error) {
|
|
6434
|
+
console.error('[MessengerWidget] Failed to fetch changelog:', error);
|
|
6435
|
+
return { homeItems: [], changelogItems: [] };
|
|
6436
|
+
}
|
|
6437
|
+
}
|
|
6303
6438
|
|
|
6304
6439
|
async onMount() {
|
|
6305
6440
|
this.loadInitialData();
|
|
@@ -6333,6 +6468,8 @@
|
|
|
6333
6468
|
}
|
|
6334
6469
|
|
|
6335
6470
|
destroy() {
|
|
6471
|
+
removeMessengerCustomStyles();
|
|
6472
|
+
|
|
6336
6473
|
if (this.launcher) {
|
|
6337
6474
|
this.launcher.destroy();
|
|
6338
6475
|
}
|