@product7/feedback-sdk 1.4.2 → 1.4.4

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.
@@ -3398,6 +3398,13 @@
3398
3398
  this.isLoading = false;
3399
3399
  this.isLoadingMessages = false;
3400
3400
 
3401
+ this.urls = options.urls || {
3402
+ feedback: null,
3403
+ changelog: null,
3404
+ help: null,
3405
+ roadmap: null,
3406
+ };
3407
+
3401
3408
  this._listeners = new Set();
3402
3409
  }
3403
3410
 
@@ -3981,14 +3988,14 @@
3981
3988
 
3982
3989
  _updateContent() {
3983
3990
  this.element.innerHTML = `
3984
- <div class="messenger-changelog-header">
3985
- <h2>Latest Updates</h2>
3986
- </div>
3991
+ <div class="messenger-changelog-header">
3992
+ <h2>Latest Updates</h2>
3993
+ </div>
3987
3994
 
3988
- <div class="messenger-changelog-body">
3989
- <div class="messenger-changelog-list"></div>
3990
- </div>
3991
- `;
3995
+ <div class="messenger-changelog-body">
3996
+ <div class="messenger-changelog-list"></div>
3997
+ </div>
3998
+ `;
3992
3999
 
3993
4000
  this._updateChangelogList();
3994
4001
  this._attachEvents();
@@ -4984,30 +4991,29 @@
4984
4991
 
4985
4992
  _updateContent() {
4986
4993
  const searchQuery = this.state.helpSearchQuery || '';
4987
- this.state.helpArticles || [];
4988
4994
 
4989
4995
  this.element.innerHTML = `
4990
- <div class="messenger-help-header">
4991
- <div class="messenger-help-header-top">
4992
- <h2>Help</h2>
4993
- <button class="sdk-close-btn" aria-label="Close">
4994
- <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 256 256">
4995
- <path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>
4996
- </svg>
4997
- </button>
4998
- </div>
4999
- <input
5000
- type="text"
5001
- class="messenger-help-search-input"
5002
- placeholder="Search for help..."
5003
- value="${searchQuery}"
5004
- />
5005
- </div>
4996
+ <div class="messenger-help-header">
4997
+ <div class="messenger-help-header-top">
4998
+ <h2>Help</h2>
4999
+ <button class="sdk-close-btn" aria-label="Close">
5000
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 256 256">
5001
+ <path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>
5002
+ </svg>
5003
+ </button>
5004
+ </div>
5005
+ <input
5006
+ type="text"
5007
+ class="messenger-help-search-input"
5008
+ placeholder="Search for help..."
5009
+ value="${searchQuery}"
5010
+ />
5011
+ </div>
5006
5012
 
5007
- <div class="messenger-help-body">
5008
- <div class="messenger-help-collections"></div>
5009
- </div>
5010
- `;
5013
+ <div class="messenger-help-body">
5014
+ <div class="messenger-help-collections"></div>
5015
+ </div>
5016
+ `;
5011
5017
 
5012
5018
  this._updateCollectionsList();
5013
5019
  this._attachEvents();
@@ -5273,11 +5279,6 @@
5273
5279
  `;
5274
5280
 
5275
5281
  if (openConversation) {
5276
- openConversation.lastMessage
5277
- ? openConversation.lastMessage.length > 40
5278
- ? openConversation.lastMessage.substring(0, 40) + '...'
5279
- : openConversation.lastMessage
5280
- : 'Continue your conversation';
5281
5282
  return `
5282
5283
  <button class="messenger-home-message-btn messenger-home-continue-btn" data-conversation-id="${openConversation.id}">
5283
5284
  <div class="messenger-home-continue-info">
@@ -5285,18 +5286,19 @@
5285
5286
  </div>
5286
5287
  ${sendIcon}
5287
5288
  </button>
5288
- <button class="messenger-home-message-btn" data-action="feedback">
5289
+ <button class="messenger-home-message-btn messenger-feedback-btn" data-action="feedback">
5289
5290
  <span class="messenger-home-continue-label">Leave us feedback</span>
5290
5291
  ${caretIcon}
5291
5292
  </button>
5292
5293
  `;
5293
5294
  }
5295
+
5294
5296
  return `
5295
5297
  <button class="messenger-home-message-btn">
5296
5298
  <span>Start a conversation</span>
5297
5299
  ${sendIcon}
5298
5300
  </button>
5299
- <button class="messenger-home-message-btn" data-action="feedback">
5301
+ <button class="messenger-home-message-btn messenger-feedback-btn" data-action="feedback">
5300
5302
  <span>Leave us feedback</span>
5301
5303
  ${caretIcon}
5302
5304
  </button>
@@ -5378,7 +5380,9 @@
5378
5380
  this.state.setOpen(false);
5379
5381
  });
5380
5382
 
5381
- const msgBtn = this.element.querySelector('.messenger-home-message-btn');
5383
+ const msgBtn = this.element.querySelector(
5384
+ '.messenger-home-message-btn:not(.messenger-feedback-btn)'
5385
+ );
5382
5386
  if (msgBtn) {
5383
5387
  msgBtn.addEventListener('click', () => {
5384
5388
  const convId = msgBtn.dataset.conversationId;
@@ -5395,11 +5399,35 @@
5395
5399
  });
5396
5400
  }
5397
5401
 
5402
+ const feedbackBtn = this.element.querySelector('.messenger-feedback-btn');
5403
+ if (feedbackBtn) {
5404
+ feedbackBtn.addEventListener('click', () => {
5405
+ const url = this.state.urls?.feedback;
5406
+
5407
+ if (this.options.onFeedbackClick) {
5408
+ this.options.onFeedbackClick();
5409
+ } else if (url) {
5410
+ window.open(url, '_blank');
5411
+ } else {
5412
+ console.warn(
5413
+ '[Messenger] No feedback destination configured. Set `feedbackUrl` in MessengerWidget options.'
5414
+ );
5415
+ }
5416
+ });
5417
+ }
5418
+
5398
5419
  this.element
5399
- .querySelectorAll('.messenger-home-changelog-item')
5400
- .forEach((item) => {
5401
- item.addEventListener('click', () => {
5402
- this.state.setView('changelog');
5420
+ .querySelectorAll('.messenger-home-changelog-card')
5421
+ .forEach((card) => {
5422
+ card.addEventListener('click', () => {
5423
+ const item = this.state.homeChangelogItems.find(
5424
+ (i) => i.id === card.dataset.changelogId
5425
+ );
5426
+ if (item?.url) {
5427
+ window.open(item.url, '_blank');
5428
+ } else {
5429
+ this.state.setView('changelog');
5430
+ }
5403
5431
  });
5404
5432
  });
5405
5433
 
@@ -5681,7 +5709,12 @@
5681
5709
  enableHelp: options.enableHelp !== false,
5682
5710
  enableChangelog: options.enableChangelog !== false,
5683
5711
  featuredContent: options.featuredContent || null,
5712
+ feedbackUrl: options.feedbackUrl || null,
5713
+ changelogUrl: options.changelogUrl || null,
5714
+ helpUrl: options.helpUrl || null,
5715
+ roadmapUrl: options.roadmapUrl || null,
5684
5716
  onSendMessage: options.onSendMessage || null,
5717
+ onFeedbackClick: options.onFeedbackClick || null,
5685
5718
  onArticleClick: options.onArticleClick || null,
5686
5719
  onChangelogClick: options.onChangelogClick || null,
5687
5720
  };
@@ -5693,6 +5726,12 @@
5693
5726
  enableHelp: this.messengerOptions.enableHelp,
5694
5727
  enableChangelog: this.messengerOptions.enableChangelog,
5695
5728
  userContext: this.sdk?.apiService?.getUserContext() || null,
5729
+ urls: {
5730
+ feedback: this.messengerOptions.feedbackUrl,
5731
+ changelog: this.messengerOptions.changelogUrl,
5732
+ help: this.messengerOptions.helpUrl,
5733
+ roadmap: this.messengerOptions.roadmapUrl,
5734
+ },
5696
5735
  });
5697
5736
 
5698
5737
  this.launcher = null;
@@ -5739,6 +5778,7 @@
5739
5778
  onSelectConversation: this._handleSelectConversation.bind(this),
5740
5779
  onStartNewConversation: this._handleNewConversationClick.bind(this),
5741
5780
  onIdentifyContact: this._handleIdentifyContact.bind(this),
5781
+ onFeedbackClick: this.messengerOptions.onFeedbackClick,
5742
5782
  onArticleClick: this.messengerOptions.onArticleClick,
5743
5783
  onChangelogClick: this.messengerOptions.onChangelogClick,
5744
5784
  });
@@ -6194,12 +6234,16 @@
6194
6234
  const response = await this.apiService.getHelpCollections();
6195
6235
  if (response.success && response.data) {
6196
6236
  const collections = response.data.collections || response.data;
6237
+ const helpBase = (this.messengerOptions.helpUrl || '').replace(/\/$/, '');
6238
+
6197
6239
  return collections.map((collection) => ({
6198
6240
  id: collection.id,
6199
6241
  title: collection.title,
6200
6242
  description: collection.description || '',
6201
6243
  articleCount: collection.article_count || 0,
6202
- url: collection.url_slug ? `/help-docs/${collection.url_slug}` : null,
6244
+ url: collection.url_slug && helpBase
6245
+ ? `${helpBase}/collections/${collection.url_slug}`
6246
+ : helpBase || null,
6203
6247
  }));
6204
6248
  }
6205
6249
  return [];
@@ -6304,7 +6348,7 @@
6304
6348
  try {
6305
6349
  await this.apiService.sendTypingIndicator(conversationId, isTyping);
6306
6350
  } catch (error) {
6307
- // Silent fail
6351
+ // silent fail
6308
6352
  }
6309
6353
  }
6310
6354
 
@@ -6412,6 +6456,7 @@
6412
6456
 
6413
6457
  if (response.success && response.data) {
6414
6458
  const changelogs = Array.isArray(response.data) ? response.data : [];
6459
+ const changelogBase = (this.messengerOptions.changelogUrl || '').replace(/\/$/, '');
6415
6460
 
6416
6461
  const mappedItems = changelogs.map((item) => ({
6417
6462
  id: item.id,
@@ -6420,7 +6465,9 @@
6420
6465
  tags: item.labels ? item.labels.map((label) => label.name) : [],
6421
6466
  coverImage: item.cover_image || null,
6422
6467
  publishedAt: item.published_at,
6423
- url: item.slug ? `/changelog/${item.slug}` : null,
6468
+ url: item.slug && changelogBase
6469
+ ? `${changelogBase}/${item.slug}`
6470
+ : changelogBase || null,
6424
6471
  }));
6425
6472
 
6426
6473
  return {