@product7/feedback-sdk 1.3.9 → 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 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: '#1c1c1e',
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 | '#1c1c1e' | Primary accent color |
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: '#1c1c1e',
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 | '#1c1c1e' | Primary accent color |
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 |
@@ -1282,6 +1282,10 @@
1282
1282
  return this.help.searchHelpArticles(query, options);
1283
1283
  }
1284
1284
 
1285
+ async getChangelogs(options) {
1286
+ return this.changelog.getChangelogs(options);
1287
+ }
1288
+
1285
1289
  _loadStoredSession() {
1286
1290
  if (typeof localStorage === 'undefined') return false;
1287
1291
 
@@ -3252,6 +3256,112 @@
3252
3256
  }
3253
3257
  }
3254
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
+
3255
3365
  class MessengerState {
3256
3366
  constructor(options = {}) {
3257
3367
  this.currentView = 'home';
@@ -5561,14 +5671,16 @@
5561
5671
  this.messengerOptions = {
5562
5672
  position: options.position || 'bottom-right',
5563
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',
5564
5678
  teamName: options.teamName || 'Support',
5565
5679
  teamAvatars: options.teamAvatars || [],
5566
5680
  welcomeMessage: options.welcomeMessage || 'How can we help?',
5567
5681
  enableHelp: options.enableHelp !== false,
5568
5682
  enableChangelog: options.enableChangelog !== false,
5569
- logoUrl: options.logoUrl || 'https://product7.io/p7logo.svg',
5570
5683
  featuredContent: options.featuredContent || null,
5571
- primaryColor: options.primaryColor || '#1c1c1e',
5572
5684
  onSendMessage: options.onSendMessage || null,
5573
5685
  onArticleClick: options.onArticleClick || null,
5574
5686
  onChangelogClick: options.onChangelogClick || null,
@@ -5600,6 +5712,13 @@
5600
5712
  container.className = `messenger-widget theme-${this.messengerOptions.theme}`;
5601
5713
  container.style.zIndex = '999999';
5602
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
+
5603
5722
  this.launcher = new MessengerLauncher(this.messengerState, {
5604
5723
  position: this.messengerOptions.position,
5605
5724
  primaryColor: this.messengerOptions.primaryColor,
@@ -6073,15 +6192,14 @@
6073
6192
  async _fetchHelpArticles() {
6074
6193
  try {
6075
6194
  const response = await this.apiService.getHelpCollections();
6076
- if (response.status && response.data) {
6077
- return response.data.map((collection) => ({
6195
+ if (response.success && response.data) {
6196
+ const collections = response.data.collections || response.data;
6197
+ return collections.map((collection) => ({
6078
6198
  id: collection.id,
6079
- title: collection.title || collection.name,
6199
+ title: collection.title,
6080
6200
  description: collection.description || '',
6081
- articleCount:
6082
- collection.article_count || collection.articleCount || 0,
6083
- icon: collection.icon || 'ph-book-open',
6084
- url: collection.url || `#/help/${collection.slug || collection.id}`,
6201
+ articleCount: collection.article_count || 0,
6202
+ url: collection.url_slug ? `/help/${collection.url_slug}` : null,
6085
6203
  }));
6086
6204
  }
6087
6205
  return [];
@@ -6225,8 +6343,7 @@
6225
6343
  'Connect with more tools you love and streamline your workflow.',
6226
6344
  tags: ['Integration'],
6227
6345
  coverImage:
6228
- 'https://images.unsplash.com/photo-1674027444485-cec3da58eef4?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8M3x8YWl8ZW58MHx8MHx8fDA%3D',
6229
- coverText: null,
6346
+ 'https://images.unsplash.com/photo-1674027444485-cec3da58eef4?w=500&auto=format&fit=crop&q=60',
6230
6347
  publishedAt: new Date(
6231
6348
  Date.now() - 14 * 24 * 60 * 60 * 1000
6232
6349
  ).toISOString(),
@@ -6239,8 +6356,7 @@
6239
6356
  'We announced Fin Insights, a groundbreaking, AI-powered product that gives you complete visibility into every customer conversation.',
6240
6357
  tags: ['New feature', 'AI'],
6241
6358
  coverImage:
6242
- 'https://images.unsplash.com/photo-1666875753105-c63a6f3bdc86?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTJ8fGluc2lnaHRzfGVufDB8fDB8fHww',
6243
- coverText: 'Watch our major product launch on-demand',
6359
+ 'https://images.unsplash.com/photo-1666875753105-c63a6f3bdc86?w=500&auto=format&fit=crop&q=60',
6244
6360
  publishedAt: new Date(
6245
6361
  Date.now() - 5 * 24 * 60 * 60 * 1000
6246
6362
  ).toISOString(),
@@ -6253,8 +6369,7 @@
6253
6369
  'Learn how AI has transformed customer service from the ground up—rewriting its economics and reshaping expectations.',
6254
6370
  tags: ['Report'],
6255
6371
  coverImage:
6256
- 'https://images.unsplash.com/photo-1762330467475-a565d04e1808?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8N3x8YWklMjBjdXN0b21lciUyMHNlcnZpY2V8ZW58MHx8MHx8fDA%3D',
6257
- coverText: 'Customer service trends as we know them are dead.',
6372
+ 'https://images.unsplash.com/photo-1762330467475-a565d04e1808?w=500&auto=format&fit=crop&q=60',
6258
6373
  publishedAt: new Date(
6259
6374
  Date.now() - 2 * 24 * 60 * 60 * 1000
6260
6375
  ).toISOString(),
@@ -6269,8 +6384,7 @@
6269
6384
  'Get deeper insights into your customer conversations with our new analytics dashboard.',
6270
6385
  tags: ['Analytics'],
6271
6386
  coverImage:
6272
- 'https://images.unsplash.com/photo-1523961131990-5ea7c61b2107?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTJ8fGFuYWx5dGljc3xlbnwwfHwwfHx8MA%3D%3D',
6273
- coverText: null,
6387
+ 'https://images.unsplash.com/photo-1523961131990-5ea7c61b2107?w=500&auto=format&fit=crop&q=60',
6274
6388
  publishedAt: new Date(
6275
6389
  Date.now() - 10 * 24 * 60 * 60 * 1000
6276
6390
  ).toISOString(),
@@ -6283,8 +6397,7 @@
6283
6397
  'New AI-powered escalation guidance helps your team handle complex customer issues more effectively.',
6284
6398
  tags: ['New feature', 'AI'],
6285
6399
  coverImage:
6286
- 'https://images.unsplash.com/photo-1764773516703-b246ac2ad5ef?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8M3x8Y29tcGxleCUyMGlzc3Vlc3xlbnwwfHwwfHx8MA%3D%3D',
6287
- coverText: null,
6400
+ 'https://images.unsplash.com/photo-1764773516703-b246ac2ad5ef?w=500&auto=format&fit=crop&q=60',
6288
6401
  publishedAt: new Date(
6289
6402
  Date.now() - 7 * 24 * 60 * 60 * 1000
6290
6403
  ).toISOString(),
@@ -6294,24 +6407,33 @@
6294
6407
  };
6295
6408
  }
6296
6409
 
6297
- const response = await this.apiService.getChangelogs({ limit: 20 });
6298
- const changelogs = response.data || [];
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
+ }));
6299
6425
 
6300
- const mappedItems = changelogs.map((item) => ({
6301
- id: item.id,
6302
- title: item.title,
6303
- description: item.excerpt || item.description || '',
6304
- tags: item.labels ? item.labels.map((label) => label.name) : [],
6305
- coverImage: item.cover_image || null,
6306
- coverText: null,
6307
- publishedAt: item.published_at,
6308
- url: item.slug ? `/changelog/${item.slug}` : '#',
6309
- }));
6426
+ return {
6427
+ homeItems: mappedItems.slice(0, 3),
6428
+ changelogItems: mappedItems,
6429
+ };
6430
+ }
6310
6431
 
6311
- return {
6312
- homeItems: mappedItems.slice(0, 3),
6313
- changelogItems: mappedItems,
6314
- };
6432
+ return { homeItems: [], changelogItems: [] };
6433
+ } catch (error) {
6434
+ console.error('[MessengerWidget] Failed to fetch changelog:', error);
6435
+ return { homeItems: [], changelogItems: [] };
6436
+ }
6315
6437
  }
6316
6438
 
6317
6439
  async onMount() {
@@ -6346,6 +6468,8 @@
6346
6468
  }
6347
6469
 
6348
6470
  destroy() {
6471
+ removeMessengerCustomStyles();
6472
+
6349
6473
  if (this.launcher) {
6350
6474
  this.launcher.destroy();
6351
6475
  }
@@ -8806,6 +8930,7 @@
8806
8930
  transform: translateX(calc(100% + 24px));
8807
8931
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
8808
8932
  font-family: inherit;
8933
+ box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px;
8809
8934
  }
8810
8935
 
8811
8936
  .feedback-panel.open {
@@ -8818,7 +8943,6 @@
8818
8943
  display: flex;
8819
8944
  flex-direction: column;
8820
8945
  border-radius: var(--radius-2xl);
8821
- box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px;
8822
8946
  }
8823
8947
 
8824
8948
  .feedback-panel-header {
@@ -10460,7 +10584,7 @@
10460
10584
  z-index: var(--z-modal);
10461
10585
  background: var(--color-white);
10462
10586
  border-radius: var(--radius-2xl);
10463
- box-shadow: var(--shadow-2xl);
10587
+ box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px;
10464
10588
  padding: var(--spacing-6);
10465
10589
  min-width: 320px;
10466
10590
  max-width: 400px;