@blotoutio/providers-shop-gpt-sdk 1.10.2 → 1.11.0

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.
Files changed (4) hide show
  1. package/index.cjs.js +152 -39
  2. package/index.js +152 -39
  3. package/index.mjs +152 -39
  4. package/package.json +1 -1
package/index.mjs CHANGED
@@ -406,13 +406,24 @@ const createExperiment = (props) => {
406
406
  }
407
407
  };
408
408
 
409
+ /** Action length should not exceed 42 */
409
410
  const uiActions = new Set([
410
411
  'shopGPTInitialized',
411
412
  'chatbotOpened',
413
+ 'chatbotClosed',
414
+ 'singleThreadDelete',
415
+ 'allThreadsDelete',
416
+ 'switchThread',
417
+ 'newSearch',
418
+ 'thumbsUp',
419
+ 'thumbsDown',
420
+ 'showThreads',
412
421
  'queryInteractions',
413
422
  'promptClicked',
414
423
  'productRecommendationClicked',
424
+ 'blotoutLinkClicked',
415
425
  ]);
426
+ /** Action length should not exceed 42 */
416
427
  new Set([
417
428
  ...uiActions,
418
429
  'pageView',
@@ -765,10 +776,11 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
765
776
  const data = (await response.json());
766
777
  return data.customPrompts;
767
778
  };
768
- const sendEvent = async (action, currency, actionData) => {
779
+ const sendEvent = (action, currency, actionData) => {
769
780
  var _a;
770
781
  const storageData = (_a = getProductActions(baseURL, sessionId)) !== null && _a !== void 0 ? _a : {};
771
- const response = await fetchImpl(getURL('/user/event'), {
782
+ // This endpoint sends user events to the server, we don't need to wait for the response
783
+ fetchImpl(getURL('/user/event'), {
772
784
  method: 'POST',
773
785
  headers: getHeaders(true),
774
786
  body: JSON.stringify({
@@ -782,10 +794,13 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
782
794
  },
783
795
  }),
784
796
  credentials: 'include',
785
- });
786
- if (!response.ok) {
787
- throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
788
- }
797
+ })
798
+ .then(async (response) => {
799
+ if (!response.ok) {
800
+ throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
801
+ }
802
+ })
803
+ .catch(logger.error);
789
804
  };
790
805
  return {
791
806
  processQuery,
@@ -821,8 +836,8 @@ const init = (params) => {
821
836
  // exit if not in top window
822
837
  return;
823
838
  }
824
- const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUiManually, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
825
- setShopGPTLoaded(params.baseUrl, (_d = params.session) === null || _d === void 0 ? void 0 : _d.sessionId, !loadUiManually);
839
+ const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
840
+ setShopGPTLoaded(params.baseUrl, (_d = params.session) === null || _d === void 0 ? void 0 : _d.sessionId, !loadUIManually);
826
841
  const experiment = createExperiment({
827
842
  name: getExperimentName(mode),
828
843
  userId: params.userId,
@@ -862,8 +877,9 @@ const init = (params) => {
862
877
  css,
863
878
  nudge,
864
879
  sessionId: (_f = params.session) === null || _f === void 0 ? void 0 : _f.sessionId,
880
+ loadUIManually,
865
881
  });
866
- if (!loadUiManually) {
882
+ if (!loadUIManually) {
867
883
  uiImplementation.loadUI();
868
884
  }
869
885
  }
@@ -1086,6 +1102,7 @@ const shopGPTStyles = i$4 `
1086
1102
  height: 56px;
1087
1103
  background-color: var(--shopgpt-primary);
1088
1104
  border-radius: 50%;
1105
+ display: flex;
1089
1106
  justify-content: center;
1090
1107
  align-items: center;
1091
1108
  box-shadow: 0 0 4px 1px var(--shopgpt-white);
@@ -1518,6 +1535,13 @@ class ChatThreads extends r$2 {
1518
1535
  }
1519
1536
  return `https://${this.merchantUrl}`;
1520
1537
  }
1538
+ sendEvent(action, actionData) {
1539
+ this.dispatchEvent(new CustomEvent('send-event', {
1540
+ detail: { action, actionData },
1541
+ composed: true,
1542
+ bubbles: true,
1543
+ }));
1544
+ }
1521
1545
  handleThreadDelete() {
1522
1546
  if (this.deleteAllThreads) {
1523
1547
  this.dispatchEvent(new CustomEvent('delete-all-threads', {
@@ -1552,7 +1576,7 @@ class ChatThreads extends r$2 {
1552
1576
  ? x `<div
1553
1577
  class="trash-icon"
1554
1578
  @click=${() => {
1555
- if (this.isLoading || this.isTyping) {
1579
+ if (this.isLoading || this.isStreaming) {
1556
1580
  return;
1557
1581
  }
1558
1582
  this.deleteAllThreads = true;
@@ -1569,13 +1593,15 @@ class ChatThreads extends r$2 {
1569
1593
  class=${e$1({
1570
1594
  'thread-wrapper': true,
1571
1595
  active: this.selectedThreadId === thread.threadId,
1572
- disabled: this.isTyping,
1596
+ disabled: this.isStreaming,
1573
1597
  })}
1574
1598
  >
1575
1599
  <div
1576
1600
  class="thread-title"
1577
1601
  @click=${async () => {
1578
- if (this.isLoading || this.isTyping) {
1602
+ if (this.isLoading ||
1603
+ this.isStreaming ||
1604
+ this.selectedThreadId === thread.threadId) {
1579
1605
  return;
1580
1606
  }
1581
1607
  await this.setSelectedThreadId(thread.threadId);
@@ -1586,7 +1612,7 @@ class ChatThreads extends r$2 {
1586
1612
  <div
1587
1613
  class="trash-icon"
1588
1614
  @click=${() => {
1589
- if (this.isLoading || this.isTyping) {
1615
+ if (this.isLoading || this.isStreaming) {
1590
1616
  return;
1591
1617
  }
1592
1618
  this.deleteThreadId = thread.threadId;
@@ -1607,8 +1633,13 @@ class ChatThreads extends r$2 {
1607
1633
  <span class="line"></span>
1608
1634
  <button
1609
1635
  class="btn-new-search"
1610
- ?disabled=${this.isLoading || this.isTyping}
1611
- @click=${() => this.setSelectedThreadId('')}
1636
+ ?disabled=${this.isLoading || this.isStreaming}
1637
+ @click=${() => {
1638
+ if (this.selectedThreadId) {
1639
+ this.sendEvent('newSearch');
1640
+ }
1641
+ this.setSelectedThreadId('');
1642
+ }}
1612
1643
  >
1613
1644
  New Search
1614
1645
  </button>
@@ -1665,7 +1696,7 @@ __decorate([
1665
1696
  __decorate([
1666
1697
  n({ type: Boolean }),
1667
1698
  __metadata("design:type", Boolean)
1668
- ], ChatThreads.prototype, "isTyping", void 0);
1699
+ ], ChatThreads.prototype, "isStreaming", void 0);
1669
1700
  __decorate([
1670
1701
  n({ type: String }),
1671
1702
  __metadata("design:type", String)
@@ -2336,6 +2367,12 @@ const chatSectionStyles = i$4 `
2336
2367
  background: #2b65cf;
2337
2368
  opacity: 1;
2338
2369
  }
2370
+
2371
+ .new-search-btn:disabled {
2372
+ background: #808080;
2373
+ cursor: not-allowed;
2374
+ opacity: 0.5;
2375
+ }
2339
2376
  }
2340
2377
  }
2341
2378
 
@@ -2368,6 +2405,7 @@ const chatSectionStyles = i$4 `
2368
2405
  line-height: 150%;
2369
2406
  letter-spacing: -0.32px;
2370
2407
 
2408
+ box-sizing: border-box;
2371
2409
  background: #fff;
2372
2410
  border-radius: 10px;
2373
2411
  border: 1px solid #dbe2eb;
@@ -2486,6 +2524,11 @@ const chatSectionStyles = i$4 `
2486
2524
  color: rgb(140, 137, 156);
2487
2525
  border-radius: 50%;
2488
2526
 
2527
+ & > svg {
2528
+ height: 22px;
2529
+ width: 22px;
2530
+ }
2531
+
2489
2532
  &:hover {
2490
2533
  background-color: rgba(47, 43, 61, 0.08);
2491
2534
  }
@@ -3979,6 +4022,7 @@ class ChatSection extends r$2 {
3979
4022
  handleFeedback(rating, messageId, comment) {
3980
4023
  var _a, _b;
3981
4024
  if (rating === 'bad') {
4025
+ this.sendEvent('thumbsDown');
3982
4026
  this.feedbackDetails = {
3983
4027
  messageId,
3984
4028
  threadId: ((_a = this.thread) === null || _a === void 0 ? void 0 : _a.threadId) || '',
@@ -3986,6 +4030,7 @@ class ChatSection extends r$2 {
3986
4030
  };
3987
4031
  return;
3988
4032
  }
4033
+ this.sendEvent('thumbsUp');
3989
4034
  this.dispatchEvent(new CustomEvent('submit-feedback', {
3990
4035
  detail: {
3991
4036
  messageId: messageId,
@@ -4102,22 +4147,26 @@ class ChatSection extends r$2 {
4102
4147
  }
4103
4148
  return x ` <div class="message user">${message.message}</div> `;
4104
4149
  })}
4150
+ ${!this.fromAd || !this.thread
4151
+ ? x `
4105
4152
  <div class="message bot">
4106
4153
  <div>${this.renderBotIcon()}</div>
4107
4154
  <div>
4108
4155
  <p>
4109
4156
  Hi,
4110
4157
  ${this.brandName ? x `Welcome to ${this.brandName}.` : E}
4111
- I'm here to help you find the perfect product? What are you
4112
- looking to resolve today?
4158
+ I'm here to help you find the perfect product. Pick a suggested
4159
+ prompt from below, or enter your own query.
4113
4160
  </p>
4114
4161
  </div>
4115
4162
  </div>
4163
+ </div>`
4164
+ : E}
4116
4165
  </div>
4117
4166
  `;
4118
4167
  }
4119
4168
  renderPrompts() {
4120
- if (this.isLoadingHistory || this.isTyping || this.isLoadingThreads) {
4169
+ if (this.isLoadingHistory || this.isStreaming || this.isLoadingThreads) {
4121
4170
  return E;
4122
4171
  }
4123
4172
  const isWelcomeMessage = this.messages.length === 1 && this.messages[0].sender === 'bot';
@@ -4248,10 +4297,14 @@ class ChatSection extends r$2 {
4248
4297
  <button
4249
4298
  class="btn btn-icon new-search-btn"
4250
4299
  @click=${(e) => {
4251
- var _a;
4300
+ var _a, _b;
4252
4301
  e.preventDefault();
4253
- (_a = this.setSelectedThreadId) === null || _a === void 0 ? void 0 : _a.call(this, '');
4302
+ if ((_a = this.thread) === null || _a === void 0 ? void 0 : _a.threadId) {
4303
+ this.sendEvent('newSearch');
4304
+ }
4305
+ (_b = this.setSelectedThreadId) === null || _b === void 0 ? void 0 : _b.call(this, '');
4254
4306
  }}
4307
+ ?disabled=${this.isStreaming}
4255
4308
  >
4256
4309
  ${plusBtn}
4257
4310
  </button>
@@ -4270,6 +4323,9 @@ class ChatSection extends r$2 {
4270
4323
  @click=${(e) => {
4271
4324
  e.preventDefault();
4272
4325
  this.showChatThreads = !this.showChatThreads;
4326
+ if (this.showChatThreads) {
4327
+ this.sendEvent('showThreads');
4328
+ }
4273
4329
  }}
4274
4330
  >
4275
4331
  ${timerBtn}
@@ -4339,7 +4395,7 @@ class ChatSection extends r$2 {
4339
4395
  ? x `<div
4340
4396
  class="trash-icon"
4341
4397
  @click=${() => {
4342
- if (this.isTyping) {
4398
+ if (this.isStreaming) {
4343
4399
  return;
4344
4400
  }
4345
4401
  this.deleteAllThreads = true;
@@ -4355,17 +4411,18 @@ class ChatSection extends r$2 {
4355
4411
  <div
4356
4412
  class=${e$1({
4357
4413
  'thread-title': true,
4358
- disabled: this.isTyping,
4414
+ disabled: this.isStreaming,
4359
4415
  })}
4360
4416
  >
4361
4417
  <p
4362
4418
  @click=${() => {
4363
- var _a;
4364
- if (this.isTyping) {
4419
+ var _a, _b;
4420
+ if (this.isStreaming ||
4421
+ ((_a = this.thread) === null || _a === void 0 ? void 0 : _a.threadId) === thread.threadId) {
4365
4422
  return;
4366
4423
  }
4367
4424
  this.showChatThreads = false;
4368
- (_a = this.setSelectedThreadId) === null || _a === void 0 ? void 0 : _a.call(this, thread.threadId);
4425
+ (_b = this.setSelectedThreadId) === null || _b === void 0 ? void 0 : _b.call(this, thread.threadId);
4369
4426
  }}
4370
4427
  >
4371
4428
  ${thread.title || 'New Search'}
@@ -4373,7 +4430,7 @@ class ChatSection extends r$2 {
4373
4430
  <div
4374
4431
  class="trash-icon"
4375
4432
  @click=${() => {
4376
- if (this.isTyping) {
4433
+ if (this.isStreaming) {
4377
4434
  return;
4378
4435
  }
4379
4436
  this.deleteThreadId = thread.threadId;
@@ -4422,7 +4479,7 @@ class ChatSection extends r$2 {
4422
4479
  modal: this.viewType === 'modal',
4423
4480
  })}
4424
4481
  type="submit"
4425
- ?disabled=${this.isTyping || this.isLoadingHistory}
4482
+ ?disabled=${this.isStreaming || this.isLoadingHistory}
4426
4483
  >
4427
4484
  ${sendFilledIcon}
4428
4485
  </button>
@@ -4430,9 +4487,15 @@ class ChatSection extends r$2 {
4430
4487
  ${this.viewType === 'modal'
4431
4488
  ? x ` <footer>
4432
4489
  Powered by
4433
- <a target="_blank" href="https://shopgpt.edgeagents.ai"
4434
- >Blotout</a
4490
+ <a
4491
+ target="_blank"
4492
+ href="https://shopgpt.edgeagents.ai"
4493
+ @click=${() => {
4494
+ this.sendEvent('blotoutLinkClicked');
4495
+ }}
4435
4496
  >
4497
+ Blotout
4498
+ </a>
4436
4499
  </footer>`
4437
4500
  : E}
4438
4501
  </div>
@@ -4536,6 +4599,10 @@ __decorate([
4536
4599
  n({ type: Boolean }),
4537
4600
  __metadata("design:type", Boolean)
4538
4601
  ], ChatSection.prototype, "isTyping", void 0);
4602
+ __decorate([
4603
+ n({ type: Boolean }),
4604
+ __metadata("design:type", Boolean)
4605
+ ], ChatSection.prototype, "isStreaming", void 0);
4539
4606
  __decorate([
4540
4607
  n({ type: Boolean }),
4541
4608
  __metadata("design:type", Boolean)
@@ -4588,6 +4655,10 @@ __decorate([
4588
4655
  n({ type: String }),
4589
4656
  __metadata("design:type", String)
4590
4657
  ], ChatSection.prototype, "css", void 0);
4658
+ __decorate([
4659
+ n({ type: Boolean }),
4660
+ __metadata("design:type", Boolean)
4661
+ ], ChatSection.prototype, "fromAd", void 0);
4591
4662
  if (!customElements.get('chat-section')) {
4592
4663
  customElements.define('chat-section', ChatSection);
4593
4664
  }
@@ -4664,6 +4735,7 @@ class ShopGPT extends r$2 {
4664
4735
  this.isLoadingHistory = false;
4665
4736
  this.isLoadingThreads = false;
4666
4737
  this.isTyping = false;
4738
+ this.isStreaming = false;
4667
4739
  this.isFailed = false;
4668
4740
  this.selectedThreadId = '';
4669
4741
  this.products = [];
@@ -4684,6 +4756,16 @@ class ShopGPT extends r$2 {
4684
4756
  this.modalState = 'close';
4685
4757
  (_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
4686
4758
  };
4759
+ this.isFromAd = () => {
4760
+ var _a;
4761
+ if (this.devMode) {
4762
+ const thread = this.chatThreads.get(this.selectedThreadId);
4763
+ return thread ? !!((_a = thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle) : false;
4764
+ }
4765
+ const searchParams = new URLSearchParams(window.location.search);
4766
+ return ((isFromAd(searchParams) || searchParams.get('shopGPT') === '1') &&
4767
+ !!this.storeAPI.getCurrentProductHandle());
4768
+ };
4687
4769
  this.submitQuery = (message) => {
4688
4770
  if (!message) {
4689
4771
  return;
@@ -4715,7 +4797,9 @@ class ShopGPT extends r$2 {
4715
4797
  this.startNudgeTimer();
4716
4798
  }
4717
4799
  disconnectedCallback() {
4718
- window.removeEventListener('edgetag-initialized', this.loadData);
4800
+ if (!this.loadUIManually) {
4801
+ window.removeEventListener('edgetag-initialized', this.loadData);
4802
+ }
4719
4803
  window.removeEventListener('popstate', this.onPopState);
4720
4804
  if (this.nudgeTimer) {
4721
4805
  window.clearTimeout(this.nudgeTimer);
@@ -4723,7 +4807,14 @@ class ShopGPT extends r$2 {
4723
4807
  super.disconnectedCallback();
4724
4808
  }
4725
4809
  init() {
4726
- window.addEventListener('edgetag-initialized', this.loadData);
4810
+ if (this.loadUIManually) {
4811
+ // this is because edgetag-initialized will already be
4812
+ // triggered before the loadUI function is called to load the UI
4813
+ this.loadData();
4814
+ }
4815
+ else {
4816
+ window.addEventListener('edgetag-initialized', this.loadData);
4817
+ }
4727
4818
  window.addEventListener('popstate', this.onPopState);
4728
4819
  this.shopGPTAPI.sendEvent('shopGPTInitialized', this.getSiteCurrency().currency);
4729
4820
  if (!this.view || this.view === 'overlay') {
@@ -4767,15 +4858,18 @@ class ShopGPT extends r$2 {
4767
4858
  if (!thread) {
4768
4859
  return;
4769
4860
  }
4770
- const searchParams = new URLSearchParams(window.location.search);
4771
- const fromAd = isFromAd(searchParams) || searchParams.get('shopGPT') === '1';
4861
+ const fromAd = this.isFromAd();
4772
4862
  const productHandle = this.devMode
4773
4863
  ? (_a = thread === null || thread === void 0 ? void 0 : thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle
4774
4864
  : fromAd
4775
4865
  ? this.storeAPI.getCurrentProductHandle()
4776
4866
  : undefined;
4867
+ if (!fromAd) {
4868
+ return;
4869
+ }
4777
4870
  try {
4778
4871
  this.isTyping = true;
4872
+ this.isStreaming = true;
4779
4873
  const response = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
4780
4874
  this.processMessageResponse(response);
4781
4875
  }
@@ -4783,6 +4877,7 @@ class ShopGPT extends r$2 {
4783
4877
  logger.error(error);
4784
4878
  this.isFailed = true;
4785
4879
  this.isTyping = false;
4880
+ this.isStreaming = false;
4786
4881
  }
4787
4882
  }
4788
4883
  async loadChatThreads() {
@@ -4809,9 +4904,9 @@ class ShopGPT extends r$2 {
4809
4904
  }
4810
4905
  }
4811
4906
  if (latestThread) {
4812
- this.setSelectedThreadId(latestThread.threadId);
4907
+ this.setSelectedThreadId(latestThread.threadId, true);
4813
4908
  }
4814
- else if (!this.devMode) {
4909
+ else if (!this.devMode && this.isFromAd()) {
4815
4910
  this.createChatThread({ title: '' }, true);
4816
4911
  }
4817
4912
  }
@@ -4864,9 +4959,12 @@ class ShopGPT extends r$2 {
4864
4959
  logger.error(e);
4865
4960
  }
4866
4961
  }
4867
- async setSelectedThreadId(threadId) {
4962
+ async setSelectedThreadId(threadId, silent) {
4868
4963
  this.isFailed = false;
4869
4964
  this.selectedThreadId = threadId;
4965
+ if (threadId && !silent) {
4966
+ this.shopGPTAPI.sendEvent('switchThread');
4967
+ }
4870
4968
  await Promise.all([
4871
4969
  this.loadHistory(threadId),
4872
4970
  this.loadCustomPrompts(threadId),
@@ -4898,6 +4996,7 @@ class ShopGPT extends r$2 {
4898
4996
  logger.error('ThreadId is missing to delete the thread!');
4899
4997
  return;
4900
4998
  }
4999
+ this.shopGPTAPI.sendEvent('singleThreadDelete');
4901
5000
  this.shopGPTAPI
4902
5001
  .deleteSingleThread(threadId)
4903
5002
  .then(this.loadChatThreads.bind(this))
@@ -4912,6 +5011,7 @@ class ShopGPT extends r$2 {
4912
5011
  handleAllThreadsDelete(e) {
4913
5012
  e.stopPropagation();
4914
5013
  this.isLoadingThreads = true;
5014
+ this.shopGPTAPI.sendEvent('allThreadsDelete');
4915
5015
  this.shopGPTAPI
4916
5016
  .deleteAllThreads()
4917
5017
  .then(this.loadChatThreads.bind(this))
@@ -4989,6 +5089,7 @@ class ShopGPT extends r$2 {
4989
5089
  }
4990
5090
  else if (eventName === 'MessageComplete') {
4991
5091
  isMessageCompleted = true;
5092
+ this.isStreaming = false;
4992
5093
  this.handleProductsComplete(products, isMessageCompleted);
4993
5094
  this.handleCompleteMessage(data);
4994
5095
  }
@@ -5008,7 +5109,7 @@ class ShopGPT extends r$2 {
5008
5109
  async sendMessageToServer(e, message, isPrompt = false) {
5009
5110
  e.preventDefault();
5010
5111
  e.stopPropagation();
5011
- if (!message || this.isTyping || this.isLoadingHistory) {
5112
+ if (!message || this.isStreaming || this.isLoadingHistory) {
5012
5113
  return;
5013
5114
  }
5014
5115
  this.isFailed = false;
@@ -5019,6 +5120,7 @@ class ShopGPT extends r$2 {
5019
5120
  }
5020
5121
  this.messages = [{ sender: 'user', message }, ...this.messages];
5021
5122
  this.isTyping = true;
5123
+ this.isStreaming = true;
5022
5124
  const response = await this.submitQuery(message);
5023
5125
  this.processMessageResponse(response);
5024
5126
  }
@@ -5026,6 +5128,7 @@ class ShopGPT extends r$2 {
5026
5128
  logger.error(err);
5027
5129
  this.isFailed = true;
5028
5130
  this.isTyping = false;
5131
+ this.isStreaming = false;
5029
5132
  }
5030
5133
  }
5031
5134
  submitFeedback(e) {
@@ -5079,7 +5182,7 @@ class ShopGPT extends r$2 {
5079
5182
  .selectedThreadId=${this.selectedThreadId}
5080
5183
  .setSelectedThreadId=${this.setSelectedThreadId.bind(this)}
5081
5184
  .isLoading=${this.isLoadingThreads}
5082
- .isTyping=${this.isTyping}
5185
+ .isStreaming=${this.isStreaming}
5083
5186
  .merchantUrl=${this.merchantUrl}
5084
5187
  .css=${this.css}
5085
5188
  ></chat-threads>
@@ -5097,6 +5200,7 @@ class ShopGPT extends r$2 {
5097
5200
  .isFailed=${this.isFailed}
5098
5201
  .isLoadingHistory=${this.isLoadingHistory}
5099
5202
  .isTyping=${this.isTyping}
5203
+ .isStreaming=${this.isStreaming}
5100
5204
  .messages=${this.messages}
5101
5205
  .siteCurrency=${this.getSiteCurrency()}
5102
5206
  .sendMessageToServer=${this.sendMessageToServer.bind(this)}
@@ -5110,6 +5214,7 @@ class ShopGPT extends r$2 {
5110
5214
  .customPrompts=${this.customPrompts}
5111
5215
  .botIconUrl=${this.botIconUrl}
5112
5216
  .css=${this.css}
5217
+ .fromAd=${this.isFromAd()}
5113
5218
  ></chat-section>
5114
5219
  </div>
5115
5220
  </dialog>
@@ -5120,6 +5225,7 @@ class ShopGPT extends r$2 {
5120
5225
  const thread = this.chatThreads.get(this.selectedThreadId);
5121
5226
  const closeModal = () => {
5122
5227
  this.modalState = 'close';
5228
+ this.shopGPTAPI.sendEvent('chatbotClosed');
5123
5229
  };
5124
5230
  if (this.modalState === 'close') {
5125
5231
  return x ` <div class="chatbot-widget">
@@ -5166,6 +5272,7 @@ class ShopGPT extends r$2 {
5166
5272
  .isFailed=${this.isFailed}
5167
5273
  .isLoadingHistory=${this.isLoadingHistory}
5168
5274
  .isTyping=${this.isTyping}
5275
+ .isStreaming=${this.isStreaming}
5169
5276
  .messages=${this.messages}
5170
5277
  .siteCurrency=${this.getSiteCurrency()}
5171
5278
  .sendMessageToServer=${this.sendMessageToServer.bind(this)}
@@ -5183,6 +5290,7 @@ class ShopGPT extends r$2 {
5183
5290
  .customPrompts=${this.customPrompts}
5184
5291
  .botIconUrl=${this.botIconUrl}
5185
5292
  .css=${this.css}
5293
+ .fromAd=${this.isFromAd()}
5186
5294
  ></chat-section>
5187
5295
  </div>
5188
5296
  `;
@@ -5255,6 +5363,10 @@ __decorate([
5255
5363
  n({ type: Boolean }),
5256
5364
  __metadata("design:type", Object)
5257
5365
  ], ShopGPT.prototype, "isTyping", void 0);
5366
+ __decorate([
5367
+ n({ type: Boolean }),
5368
+ __metadata("design:type", Object)
5369
+ ], ShopGPT.prototype, "isStreaming", void 0);
5258
5370
  __decorate([
5259
5371
  n({ type: Boolean }),
5260
5372
  __metadata("design:type", Object)
@@ -5319,6 +5431,7 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
5319
5431
  shopGPT.css = params.css;
5320
5432
  shopGPT.nudge = params.nudge;
5321
5433
  shopGPT.sessionId = params.sessionId;
5434
+ shopGPT.loadUIManually = params.loadUIManually;
5322
5435
  },
5323
5436
  loadUI() {
5324
5437
  if (!shopGPT) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-shop-gpt-sdk",
3
- "version": "1.10.2",
3
+ "version": "1.11.0",
4
4
  "description": "Shop GPT SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",