@blotoutio/providers-shop-gpt-sdk 1.10.1 → 1.10.3
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/index.cjs.js +45 -10
- package/index.js +45 -10
- package/index.mjs +45 -10
- package/package.json +1 -1
package/index.cjs.js
CHANGED
@@ -408,6 +408,7 @@ const createExperiment = (props) => {
|
|
408
408
|
}
|
409
409
|
};
|
410
410
|
|
411
|
+
/** Action length should not exceed 42 */
|
411
412
|
const uiActions = new Set([
|
412
413
|
'shopGPTInitialized',
|
413
414
|
'chatbotOpened',
|
@@ -415,6 +416,7 @@ const uiActions = new Set([
|
|
415
416
|
'promptClicked',
|
416
417
|
'productRecommendationClicked',
|
417
418
|
]);
|
419
|
+
/** Action length should not exceed 42 */
|
418
420
|
new Set([
|
419
421
|
...uiActions,
|
420
422
|
'pageView',
|
@@ -823,8 +825,8 @@ const init = (params) => {
|
|
823
825
|
// exit if not in top window
|
824
826
|
return;
|
825
827
|
}
|
826
|
-
const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, botIconUrl, css, nudge,
|
827
|
-
setShopGPTLoaded(params.baseUrl, (_d = params.session) === null || _d === void 0 ? void 0 : _d.sessionId, !
|
828
|
+
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 : {};
|
829
|
+
setShopGPTLoaded(params.baseUrl, (_d = params.session) === null || _d === void 0 ? void 0 : _d.sessionId, !loadUIManually);
|
828
830
|
const experiment = createExperiment({
|
829
831
|
name: getExperimentName(mode),
|
830
832
|
userId: params.userId,
|
@@ -864,8 +866,9 @@ const init = (params) => {
|
|
864
866
|
css,
|
865
867
|
nudge,
|
866
868
|
sessionId: (_f = params.session) === null || _f === void 0 ? void 0 : _f.sessionId,
|
869
|
+
loadUIManually,
|
867
870
|
});
|
868
|
-
if (!
|
871
|
+
if (!loadUIManually) {
|
869
872
|
uiImplementation.loadUI();
|
870
873
|
}
|
871
874
|
}
|
@@ -4104,17 +4107,21 @@ class ChatSection extends r$2 {
|
|
4104
4107
|
}
|
4105
4108
|
return x ` <div class="message user">${message.message}</div> `;
|
4106
4109
|
})}
|
4110
|
+
${!this.fromAd || !this.thread
|
4111
|
+
? x `
|
4107
4112
|
<div class="message bot">
|
4108
4113
|
<div>${this.renderBotIcon()}</div>
|
4109
4114
|
<div>
|
4110
4115
|
<p>
|
4111
4116
|
Hi,
|
4112
4117
|
${this.brandName ? x `Welcome to ${this.brandName}.` : E}
|
4113
|
-
I'm here to help you find the perfect product
|
4114
|
-
|
4118
|
+
I'm here to help you find the perfect product. Pick a suggested
|
4119
|
+
prompt from below, or enter your own query.
|
4115
4120
|
</p>
|
4116
4121
|
</div>
|
4117
4122
|
</div>
|
4123
|
+
</div>`
|
4124
|
+
: E}
|
4118
4125
|
</div>
|
4119
4126
|
`;
|
4120
4127
|
}
|
@@ -4590,6 +4597,10 @@ __decorate([
|
|
4590
4597
|
n({ type: String }),
|
4591
4598
|
__metadata("design:type", String)
|
4592
4599
|
], ChatSection.prototype, "css", void 0);
|
4600
|
+
__decorate([
|
4601
|
+
n({ type: Boolean }),
|
4602
|
+
__metadata("design:type", Boolean)
|
4603
|
+
], ChatSection.prototype, "fromAd", void 0);
|
4593
4604
|
if (!customElements.get('chat-section')) {
|
4594
4605
|
customElements.define('chat-section', ChatSection);
|
4595
4606
|
}
|
@@ -4686,6 +4697,16 @@ class ShopGPT extends r$2 {
|
|
4686
4697
|
this.modalState = 'close';
|
4687
4698
|
(_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
|
4688
4699
|
};
|
4700
|
+
this.isFromAd = () => {
|
4701
|
+
var _a;
|
4702
|
+
if (this.devMode) {
|
4703
|
+
const thread = this.chatThreads.get(this.selectedThreadId);
|
4704
|
+
return thread ? !!((_a = thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle) : false;
|
4705
|
+
}
|
4706
|
+
const searchParams = new URLSearchParams(window.location.search);
|
4707
|
+
return ((isFromAd(searchParams) || searchParams.get('shopGPT') === '1') &&
|
4708
|
+
!!this.storeAPI.getCurrentProductHandle());
|
4709
|
+
};
|
4689
4710
|
this.submitQuery = (message) => {
|
4690
4711
|
if (!message) {
|
4691
4712
|
return;
|
@@ -4717,7 +4738,9 @@ class ShopGPT extends r$2 {
|
|
4717
4738
|
this.startNudgeTimer();
|
4718
4739
|
}
|
4719
4740
|
disconnectedCallback() {
|
4720
|
-
|
4741
|
+
if (!this.loadUIManually) {
|
4742
|
+
window.removeEventListener('edgetag-initialized', this.loadData);
|
4743
|
+
}
|
4721
4744
|
window.removeEventListener('popstate', this.onPopState);
|
4722
4745
|
if (this.nudgeTimer) {
|
4723
4746
|
window.clearTimeout(this.nudgeTimer);
|
@@ -4725,7 +4748,14 @@ class ShopGPT extends r$2 {
|
|
4725
4748
|
super.disconnectedCallback();
|
4726
4749
|
}
|
4727
4750
|
init() {
|
4728
|
-
|
4751
|
+
if (this.loadUIManually) {
|
4752
|
+
// this is because edgetag-initialized will already be
|
4753
|
+
// triggered before the loadUI function is called to load the UI
|
4754
|
+
this.loadData();
|
4755
|
+
}
|
4756
|
+
else {
|
4757
|
+
window.addEventListener('edgetag-initialized', this.loadData);
|
4758
|
+
}
|
4729
4759
|
window.addEventListener('popstate', this.onPopState);
|
4730
4760
|
this.shopGPTAPI.sendEvent('shopGPTInitialized', this.getSiteCurrency().currency);
|
4731
4761
|
if (!this.view || this.view === 'overlay') {
|
@@ -4769,13 +4799,15 @@ class ShopGPT extends r$2 {
|
|
4769
4799
|
if (!thread) {
|
4770
4800
|
return;
|
4771
4801
|
}
|
4772
|
-
const
|
4773
|
-
const fromAd = isFromAd(searchParams) || searchParams.get('shopGPT') === '1';
|
4802
|
+
const fromAd = this.isFromAd();
|
4774
4803
|
const productHandle = this.devMode
|
4775
4804
|
? (_a = thread === null || thread === void 0 ? void 0 : thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle
|
4776
4805
|
: fromAd
|
4777
4806
|
? this.storeAPI.getCurrentProductHandle()
|
4778
4807
|
: undefined;
|
4808
|
+
if (!fromAd) {
|
4809
|
+
return;
|
4810
|
+
}
|
4779
4811
|
try {
|
4780
4812
|
this.isTyping = true;
|
4781
4813
|
const response = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
|
@@ -4813,7 +4845,7 @@ class ShopGPT extends r$2 {
|
|
4813
4845
|
if (latestThread) {
|
4814
4846
|
this.setSelectedThreadId(latestThread.threadId);
|
4815
4847
|
}
|
4816
|
-
else if (!this.devMode) {
|
4848
|
+
else if (!this.devMode && this.isFromAd()) {
|
4817
4849
|
this.createChatThread({ title: '' }, true);
|
4818
4850
|
}
|
4819
4851
|
}
|
@@ -5112,6 +5144,7 @@ class ShopGPT extends r$2 {
|
|
5112
5144
|
.customPrompts=${this.customPrompts}
|
5113
5145
|
.botIconUrl=${this.botIconUrl}
|
5114
5146
|
.css=${this.css}
|
5147
|
+
.fromAd=${this.isFromAd()}
|
5115
5148
|
></chat-section>
|
5116
5149
|
</div>
|
5117
5150
|
</dialog>
|
@@ -5185,6 +5218,7 @@ class ShopGPT extends r$2 {
|
|
5185
5218
|
.customPrompts=${this.customPrompts}
|
5186
5219
|
.botIconUrl=${this.botIconUrl}
|
5187
5220
|
.css=${this.css}
|
5221
|
+
.fromAd=${this.isFromAd()}
|
5188
5222
|
></chat-section>
|
5189
5223
|
</div>
|
5190
5224
|
`;
|
@@ -5321,6 +5355,7 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
|
|
5321
5355
|
shopGPT.css = params.css;
|
5322
5356
|
shopGPT.nudge = params.nudge;
|
5323
5357
|
shopGPT.sessionId = params.sessionId;
|
5358
|
+
shopGPT.loadUIManually = params.loadUIManually;
|
5324
5359
|
},
|
5325
5360
|
loadUI() {
|
5326
5361
|
if (!shopGPT) {
|
package/index.js
CHANGED
@@ -409,6 +409,7 @@ var ProvidersShopGptSdk = (function () {
|
|
409
409
|
}
|
410
410
|
};
|
411
411
|
|
412
|
+
/** Action length should not exceed 42 */
|
412
413
|
const uiActions = new Set([
|
413
414
|
'shopGPTInitialized',
|
414
415
|
'chatbotOpened',
|
@@ -416,6 +417,7 @@ var ProvidersShopGptSdk = (function () {
|
|
416
417
|
'promptClicked',
|
417
418
|
'productRecommendationClicked',
|
418
419
|
]);
|
420
|
+
/** Action length should not exceed 42 */
|
419
421
|
new Set([
|
420
422
|
...uiActions,
|
421
423
|
'pageView',
|
@@ -824,8 +826,8 @@ var ProvidersShopGptSdk = (function () {
|
|
824
826
|
// exit if not in top window
|
825
827
|
return;
|
826
828
|
}
|
827
|
-
const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, botIconUrl, css, nudge,
|
828
|
-
setShopGPTLoaded(params.baseUrl, (_d = params.session) === null || _d === void 0 ? void 0 : _d.sessionId, !
|
829
|
+
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 : {};
|
830
|
+
setShopGPTLoaded(params.baseUrl, (_d = params.session) === null || _d === void 0 ? void 0 : _d.sessionId, !loadUIManually);
|
829
831
|
const experiment = createExperiment({
|
830
832
|
name: getExperimentName(mode),
|
831
833
|
userId: params.userId,
|
@@ -865,8 +867,9 @@ var ProvidersShopGptSdk = (function () {
|
|
865
867
|
css,
|
866
868
|
nudge,
|
867
869
|
sessionId: (_f = params.session) === null || _f === void 0 ? void 0 : _f.sessionId,
|
870
|
+
loadUIManually,
|
868
871
|
});
|
869
|
-
if (!
|
872
|
+
if (!loadUIManually) {
|
870
873
|
uiImplementation.loadUI();
|
871
874
|
}
|
872
875
|
}
|
@@ -4105,17 +4108,21 @@ ${this.comment ? this.comment : E}</textarea
|
|
4105
4108
|
}
|
4106
4109
|
return x ` <div class="message user">${message.message}</div> `;
|
4107
4110
|
})}
|
4111
|
+
${!this.fromAd || !this.thread
|
4112
|
+
? x `
|
4108
4113
|
<div class="message bot">
|
4109
4114
|
<div>${this.renderBotIcon()}</div>
|
4110
4115
|
<div>
|
4111
4116
|
<p>
|
4112
4117
|
Hi,
|
4113
4118
|
${this.brandName ? x `Welcome to ${this.brandName}.` : E}
|
4114
|
-
I'm here to help you find the perfect product
|
4115
|
-
|
4119
|
+
I'm here to help you find the perfect product. Pick a suggested
|
4120
|
+
prompt from below, or enter your own query.
|
4116
4121
|
</p>
|
4117
4122
|
</div>
|
4118
4123
|
</div>
|
4124
|
+
</div>`
|
4125
|
+
: E}
|
4119
4126
|
</div>
|
4120
4127
|
`;
|
4121
4128
|
}
|
@@ -4591,6 +4598,10 @@ ${this.comment ? this.comment : E}</textarea
|
|
4591
4598
|
n({ type: String }),
|
4592
4599
|
__metadata("design:type", String)
|
4593
4600
|
], ChatSection.prototype, "css", void 0);
|
4601
|
+
__decorate([
|
4602
|
+
n({ type: Boolean }),
|
4603
|
+
__metadata("design:type", Boolean)
|
4604
|
+
], ChatSection.prototype, "fromAd", void 0);
|
4594
4605
|
if (!customElements.get('chat-section')) {
|
4595
4606
|
customElements.define('chat-section', ChatSection);
|
4596
4607
|
}
|
@@ -4687,6 +4698,16 @@ ${this.comment ? this.comment : E}</textarea
|
|
4687
4698
|
this.modalState = 'close';
|
4688
4699
|
(_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
|
4689
4700
|
};
|
4701
|
+
this.isFromAd = () => {
|
4702
|
+
var _a;
|
4703
|
+
if (this.devMode) {
|
4704
|
+
const thread = this.chatThreads.get(this.selectedThreadId);
|
4705
|
+
return thread ? !!((_a = thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle) : false;
|
4706
|
+
}
|
4707
|
+
const searchParams = new URLSearchParams(window.location.search);
|
4708
|
+
return ((isFromAd(searchParams) || searchParams.get('shopGPT') === '1') &&
|
4709
|
+
!!this.storeAPI.getCurrentProductHandle());
|
4710
|
+
};
|
4690
4711
|
this.submitQuery = (message) => {
|
4691
4712
|
if (!message) {
|
4692
4713
|
return;
|
@@ -4718,7 +4739,9 @@ ${this.comment ? this.comment : E}</textarea
|
|
4718
4739
|
this.startNudgeTimer();
|
4719
4740
|
}
|
4720
4741
|
disconnectedCallback() {
|
4721
|
-
|
4742
|
+
if (!this.loadUIManually) {
|
4743
|
+
window.removeEventListener('edgetag-initialized', this.loadData);
|
4744
|
+
}
|
4722
4745
|
window.removeEventListener('popstate', this.onPopState);
|
4723
4746
|
if (this.nudgeTimer) {
|
4724
4747
|
window.clearTimeout(this.nudgeTimer);
|
@@ -4726,7 +4749,14 @@ ${this.comment ? this.comment : E}</textarea
|
|
4726
4749
|
super.disconnectedCallback();
|
4727
4750
|
}
|
4728
4751
|
init() {
|
4729
|
-
|
4752
|
+
if (this.loadUIManually) {
|
4753
|
+
// this is because edgetag-initialized will already be
|
4754
|
+
// triggered before the loadUI function is called to load the UI
|
4755
|
+
this.loadData();
|
4756
|
+
}
|
4757
|
+
else {
|
4758
|
+
window.addEventListener('edgetag-initialized', this.loadData);
|
4759
|
+
}
|
4730
4760
|
window.addEventListener('popstate', this.onPopState);
|
4731
4761
|
this.shopGPTAPI.sendEvent('shopGPTInitialized', this.getSiteCurrency().currency);
|
4732
4762
|
if (!this.view || this.view === 'overlay') {
|
@@ -4770,13 +4800,15 @@ ${this.comment ? this.comment : E}</textarea
|
|
4770
4800
|
if (!thread) {
|
4771
4801
|
return;
|
4772
4802
|
}
|
4773
|
-
const
|
4774
|
-
const fromAd = isFromAd(searchParams) || searchParams.get('shopGPT') === '1';
|
4803
|
+
const fromAd = this.isFromAd();
|
4775
4804
|
const productHandle = this.devMode
|
4776
4805
|
? (_a = thread === null || thread === void 0 ? void 0 : thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle
|
4777
4806
|
: fromAd
|
4778
4807
|
? this.storeAPI.getCurrentProductHandle()
|
4779
4808
|
: undefined;
|
4809
|
+
if (!fromAd) {
|
4810
|
+
return;
|
4811
|
+
}
|
4780
4812
|
try {
|
4781
4813
|
this.isTyping = true;
|
4782
4814
|
const response = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
|
@@ -4814,7 +4846,7 @@ ${this.comment ? this.comment : E}</textarea
|
|
4814
4846
|
if (latestThread) {
|
4815
4847
|
this.setSelectedThreadId(latestThread.threadId);
|
4816
4848
|
}
|
4817
|
-
else if (!this.devMode) {
|
4849
|
+
else if (!this.devMode && this.isFromAd()) {
|
4818
4850
|
this.createChatThread({ title: '' }, true);
|
4819
4851
|
}
|
4820
4852
|
}
|
@@ -5113,6 +5145,7 @@ ${this.comment ? this.comment : E}</textarea
|
|
5113
5145
|
.customPrompts=${this.customPrompts}
|
5114
5146
|
.botIconUrl=${this.botIconUrl}
|
5115
5147
|
.css=${this.css}
|
5148
|
+
.fromAd=${this.isFromAd()}
|
5116
5149
|
></chat-section>
|
5117
5150
|
</div>
|
5118
5151
|
</dialog>
|
@@ -5186,6 +5219,7 @@ ${this.comment ? this.comment : E}</textarea
|
|
5186
5219
|
.customPrompts=${this.customPrompts}
|
5187
5220
|
.botIconUrl=${this.botIconUrl}
|
5188
5221
|
.css=${this.css}
|
5222
|
+
.fromAd=${this.isFromAd()}
|
5189
5223
|
></chat-section>
|
5190
5224
|
</div>
|
5191
5225
|
`;
|
@@ -5322,6 +5356,7 @@ ${this.comment ? this.comment : E}</textarea
|
|
5322
5356
|
shopGPT.css = params.css;
|
5323
5357
|
shopGPT.nudge = params.nudge;
|
5324
5358
|
shopGPT.sessionId = params.sessionId;
|
5359
|
+
shopGPT.loadUIManually = params.loadUIManually;
|
5325
5360
|
},
|
5326
5361
|
loadUI() {
|
5327
5362
|
if (!shopGPT) {
|
package/index.mjs
CHANGED
@@ -406,6 +406,7 @@ 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,6 +414,7 @@ const uiActions = new Set([
|
|
413
414
|
'promptClicked',
|
414
415
|
'productRecommendationClicked',
|
415
416
|
]);
|
417
|
+
/** Action length should not exceed 42 */
|
416
418
|
new Set([
|
417
419
|
...uiActions,
|
418
420
|
'pageView',
|
@@ -821,8 +823,8 @@ const init = (params) => {
|
|
821
823
|
// exit if not in top window
|
822
824
|
return;
|
823
825
|
}
|
824
|
-
const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, merchantImage, latestThreadLoad, botIconUrl, css, nudge,
|
825
|
-
setShopGPTLoaded(params.baseUrl, (_d = params.session) === null || _d === void 0 ? void 0 : _d.sessionId, !
|
826
|
+
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 : {};
|
827
|
+
setShopGPTLoaded(params.baseUrl, (_d = params.session) === null || _d === void 0 ? void 0 : _d.sessionId, !loadUIManually);
|
826
828
|
const experiment = createExperiment({
|
827
829
|
name: getExperimentName(mode),
|
828
830
|
userId: params.userId,
|
@@ -862,8 +864,9 @@ const init = (params) => {
|
|
862
864
|
css,
|
863
865
|
nudge,
|
864
866
|
sessionId: (_f = params.session) === null || _f === void 0 ? void 0 : _f.sessionId,
|
867
|
+
loadUIManually,
|
865
868
|
});
|
866
|
-
if (!
|
869
|
+
if (!loadUIManually) {
|
867
870
|
uiImplementation.loadUI();
|
868
871
|
}
|
869
872
|
}
|
@@ -4102,17 +4105,21 @@ class ChatSection extends r$2 {
|
|
4102
4105
|
}
|
4103
4106
|
return x ` <div class="message user">${message.message}</div> `;
|
4104
4107
|
})}
|
4108
|
+
${!this.fromAd || !this.thread
|
4109
|
+
? x `
|
4105
4110
|
<div class="message bot">
|
4106
4111
|
<div>${this.renderBotIcon()}</div>
|
4107
4112
|
<div>
|
4108
4113
|
<p>
|
4109
4114
|
Hi,
|
4110
4115
|
${this.brandName ? x `Welcome to ${this.brandName}.` : E}
|
4111
|
-
I'm here to help you find the perfect product
|
4112
|
-
|
4116
|
+
I'm here to help you find the perfect product. Pick a suggested
|
4117
|
+
prompt from below, or enter your own query.
|
4113
4118
|
</p>
|
4114
4119
|
</div>
|
4115
4120
|
</div>
|
4121
|
+
</div>`
|
4122
|
+
: E}
|
4116
4123
|
</div>
|
4117
4124
|
`;
|
4118
4125
|
}
|
@@ -4588,6 +4595,10 @@ __decorate([
|
|
4588
4595
|
n({ type: String }),
|
4589
4596
|
__metadata("design:type", String)
|
4590
4597
|
], ChatSection.prototype, "css", void 0);
|
4598
|
+
__decorate([
|
4599
|
+
n({ type: Boolean }),
|
4600
|
+
__metadata("design:type", Boolean)
|
4601
|
+
], ChatSection.prototype, "fromAd", void 0);
|
4591
4602
|
if (!customElements.get('chat-section')) {
|
4592
4603
|
customElements.define('chat-section', ChatSection);
|
4593
4604
|
}
|
@@ -4684,6 +4695,16 @@ class ShopGPT extends r$2 {
|
|
4684
4695
|
this.modalState = 'close';
|
4685
4696
|
(_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
|
4686
4697
|
};
|
4698
|
+
this.isFromAd = () => {
|
4699
|
+
var _a;
|
4700
|
+
if (this.devMode) {
|
4701
|
+
const thread = this.chatThreads.get(this.selectedThreadId);
|
4702
|
+
return thread ? !!((_a = thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle) : false;
|
4703
|
+
}
|
4704
|
+
const searchParams = new URLSearchParams(window.location.search);
|
4705
|
+
return ((isFromAd(searchParams) || searchParams.get('shopGPT') === '1') &&
|
4706
|
+
!!this.storeAPI.getCurrentProductHandle());
|
4707
|
+
};
|
4687
4708
|
this.submitQuery = (message) => {
|
4688
4709
|
if (!message) {
|
4689
4710
|
return;
|
@@ -4715,7 +4736,9 @@ class ShopGPT extends r$2 {
|
|
4715
4736
|
this.startNudgeTimer();
|
4716
4737
|
}
|
4717
4738
|
disconnectedCallback() {
|
4718
|
-
|
4739
|
+
if (!this.loadUIManually) {
|
4740
|
+
window.removeEventListener('edgetag-initialized', this.loadData);
|
4741
|
+
}
|
4719
4742
|
window.removeEventListener('popstate', this.onPopState);
|
4720
4743
|
if (this.nudgeTimer) {
|
4721
4744
|
window.clearTimeout(this.nudgeTimer);
|
@@ -4723,7 +4746,14 @@ class ShopGPT extends r$2 {
|
|
4723
4746
|
super.disconnectedCallback();
|
4724
4747
|
}
|
4725
4748
|
init() {
|
4726
|
-
|
4749
|
+
if (this.loadUIManually) {
|
4750
|
+
// this is because edgetag-initialized will already be
|
4751
|
+
// triggered before the loadUI function is called to load the UI
|
4752
|
+
this.loadData();
|
4753
|
+
}
|
4754
|
+
else {
|
4755
|
+
window.addEventListener('edgetag-initialized', this.loadData);
|
4756
|
+
}
|
4727
4757
|
window.addEventListener('popstate', this.onPopState);
|
4728
4758
|
this.shopGPTAPI.sendEvent('shopGPTInitialized', this.getSiteCurrency().currency);
|
4729
4759
|
if (!this.view || this.view === 'overlay') {
|
@@ -4767,13 +4797,15 @@ class ShopGPT extends r$2 {
|
|
4767
4797
|
if (!thread) {
|
4768
4798
|
return;
|
4769
4799
|
}
|
4770
|
-
const
|
4771
|
-
const fromAd = isFromAd(searchParams) || searchParams.get('shopGPT') === '1';
|
4800
|
+
const fromAd = this.isFromAd();
|
4772
4801
|
const productHandle = this.devMode
|
4773
4802
|
? (_a = thread === null || thread === void 0 ? void 0 : thread.devContext) === null || _a === void 0 ? void 0 : _a.productHandle
|
4774
4803
|
: fromAd
|
4775
4804
|
? this.storeAPI.getCurrentProductHandle()
|
4776
4805
|
: undefined;
|
4806
|
+
if (!fromAd) {
|
4807
|
+
return;
|
4808
|
+
}
|
4777
4809
|
try {
|
4778
4810
|
this.isTyping = true;
|
4779
4811
|
const response = await this.shopGPTAPI.processQuery('', thread.threadId, productHandle);
|
@@ -4811,7 +4843,7 @@ class ShopGPT extends r$2 {
|
|
4811
4843
|
if (latestThread) {
|
4812
4844
|
this.setSelectedThreadId(latestThread.threadId);
|
4813
4845
|
}
|
4814
|
-
else if (!this.devMode) {
|
4846
|
+
else if (!this.devMode && this.isFromAd()) {
|
4815
4847
|
this.createChatThread({ title: '' }, true);
|
4816
4848
|
}
|
4817
4849
|
}
|
@@ -5110,6 +5142,7 @@ class ShopGPT extends r$2 {
|
|
5110
5142
|
.customPrompts=${this.customPrompts}
|
5111
5143
|
.botIconUrl=${this.botIconUrl}
|
5112
5144
|
.css=${this.css}
|
5145
|
+
.fromAd=${this.isFromAd()}
|
5113
5146
|
></chat-section>
|
5114
5147
|
</div>
|
5115
5148
|
</dialog>
|
@@ -5183,6 +5216,7 @@ class ShopGPT extends r$2 {
|
|
5183
5216
|
.customPrompts=${this.customPrompts}
|
5184
5217
|
.botIconUrl=${this.botIconUrl}
|
5185
5218
|
.css=${this.css}
|
5219
|
+
.fromAd=${this.isFromAd()}
|
5186
5220
|
></chat-section>
|
5187
5221
|
</div>
|
5188
5222
|
`;
|
@@ -5319,6 +5353,7 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
|
|
5319
5353
|
shopGPT.css = params.css;
|
5320
5354
|
shopGPT.nudge = params.nudge;
|
5321
5355
|
shopGPT.sessionId = params.sessionId;
|
5356
|
+
shopGPT.loadUIManually = params.loadUIManually;
|
5322
5357
|
},
|
5323
5358
|
loadUI() {
|
5324
5359
|
if (!shopGPT) {
|