@blotoutio/providers-shop-gpt-sdk 1.26.0 → 1.28.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.
- package/index.cjs.js +92 -34
- package/index.js +92 -34
- package/index.mjs +92 -34
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -460,6 +460,8 @@ const uiActions = new Set([
|
|
|
460
460
|
'chatbotOpened-nudge-query',
|
|
461
461
|
'chatbotOpened-nudge-support',
|
|
462
462
|
'chatbotOpened-nudge-other',
|
|
463
|
+
'nudge-shown',
|
|
464
|
+
'nudge-closed',
|
|
463
465
|
]);
|
|
464
466
|
/** Action length should not exceed 42 */
|
|
465
467
|
new Set([
|
|
@@ -637,7 +639,25 @@ const setUserInteracted = (destination) => {
|
|
|
637
639
|
const session = getSessionData(destination);
|
|
638
640
|
saveSessionData(destination, {
|
|
639
641
|
...session,
|
|
640
|
-
chatbot: {
|
|
642
|
+
chatbot: {
|
|
643
|
+
...session === null || session === void 0 ? void 0 : session.chatbot,
|
|
644
|
+
hasUserInteracted: true,
|
|
645
|
+
},
|
|
646
|
+
});
|
|
647
|
+
};
|
|
648
|
+
const isPopupViewMiniMinimised = (destination) => {
|
|
649
|
+
var _a;
|
|
650
|
+
const session = getSessionData(destination);
|
|
651
|
+
return !!((_a = session === null || session === void 0 ? void 0 : session.chatbot) === null || _a === void 0 ? void 0 : _a.hasPopupViewMiniMinimised);
|
|
652
|
+
};
|
|
653
|
+
const setPopupViewMiniMinimised = (destination) => {
|
|
654
|
+
const session = getSessionData(destination);
|
|
655
|
+
saveSessionData(destination, {
|
|
656
|
+
...session,
|
|
657
|
+
chatbot: {
|
|
658
|
+
...session === null || session === void 0 ? void 0 : session.chatbot,
|
|
659
|
+
hasPopupViewMiniMinimised: true,
|
|
660
|
+
},
|
|
641
661
|
});
|
|
642
662
|
};
|
|
643
663
|
const getProductActions = (destination, sessionId) => {
|
|
@@ -974,6 +994,15 @@ const init = (params) => {
|
|
|
974
994
|
// exit if not in top window
|
|
975
995
|
return;
|
|
976
996
|
}
|
|
997
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
998
|
+
if (searchParams.get('evo') === 'preview') {
|
|
999
|
+
try {
|
|
1000
|
+
sessionStorage.setItem('previewShopGPT', '1');
|
|
1001
|
+
}
|
|
1002
|
+
catch {
|
|
1003
|
+
error('Error in setting the sessionStorage for previewShopGPT');
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
977
1006
|
const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, supportPrompts, searchSuggestions, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, metafieldDisplayName, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
|
|
978
1007
|
const experiment = createExperiment({
|
|
979
1008
|
name: getExperimentName(mode),
|
|
@@ -6825,22 +6854,30 @@ const chatSectionStyles$1 = i$4 `
|
|
|
6825
6854
|
const capitalizeEachWord = (str) => {
|
|
6826
6855
|
return str === null || str === void 0 ? void 0 : str.replace(/^\w/, (char) => char.toUpperCase());
|
|
6827
6856
|
};
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6857
|
+
/**
|
|
6858
|
+
* For the time being we are disabling the welcome flow so commenting out this
|
|
6859
|
+
* once we decide to bring back the welcome flow we will uncomment this code
|
|
6860
|
+
*/
|
|
6861
|
+
/**
|
|
6862
|
+
* const adParams = new Set([
|
|
6863
|
+
* 'fbclid',
|
|
6864
|
+
* 'gclid',
|
|
6865
|
+
* 'sccid',
|
|
6866
|
+
* 'ttclid',
|
|
6867
|
+
* 'epik',
|
|
6868
|
+
* 'li_fat_id',
|
|
6869
|
+
* 'twclid',
|
|
6870
|
+
* 'rdt_cid',
|
|
6871
|
+
* 'aleid',
|
|
6872
|
+
* 'tabclid',
|
|
6873
|
+
* 'msclkid',
|
|
6874
|
+
* 'dclid',
|
|
6875
|
+
* 'wbraid',
|
|
6876
|
+
* ])
|
|
6877
|
+
*
|
|
6878
|
+
* export const isFromAd = (params: URLSearchParams) =>
|
|
6879
|
+
* [...params.keys()].some((key) => adParams.has(key.toLowerCase()))
|
|
6880
|
+
*/
|
|
6844
6881
|
|
|
6845
6882
|
const personalizeDialogStyles = i$4 `
|
|
6846
6883
|
:host {
|
|
@@ -10202,6 +10239,8 @@ const popupViewMiniStyles = i$4 `
|
|
|
10202
10239
|
}
|
|
10203
10240
|
|
|
10204
10241
|
.textarea-wrapper {
|
|
10242
|
+
display: flex;
|
|
10243
|
+
align-items: center;
|
|
10205
10244
|
position: relative;
|
|
10206
10245
|
width: 100%;
|
|
10207
10246
|
background: white;
|
|
@@ -10274,7 +10313,8 @@ const popupViewMiniStyles = i$4 `
|
|
|
10274
10313
|
.fake-cursor {
|
|
10275
10314
|
position: absolute;
|
|
10276
10315
|
left: 10px;
|
|
10277
|
-
top:
|
|
10316
|
+
top: 50%;
|
|
10317
|
+
transform: translateY(-50%);
|
|
10278
10318
|
width: 1px;
|
|
10279
10319
|
height: 16px;
|
|
10280
10320
|
background-color: #020617;
|
|
@@ -10927,19 +10967,27 @@ class ShopGPT extends i$1 {
|
|
|
10927
10967
|
(_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
|
|
10928
10968
|
};
|
|
10929
10969
|
this.isWelcomeFlowRequired = () => {
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10970
|
+
/**
|
|
10971
|
+
* if (this.devMode) {
|
|
10972
|
+
* const thread = this.chatThreads.get(this.selectedThreadId)
|
|
10973
|
+
* return thread?.devContext?.email
|
|
10974
|
+
* ? true
|
|
10975
|
+
* : !!thread?.devContext?.productHandle
|
|
10976
|
+
* }
|
|
10977
|
+
*
|
|
10978
|
+
* const searchParams = new URLSearchParams(window.location.search)
|
|
10979
|
+
* const userType = getUserType(this.destination, this.sessionId)
|
|
10980
|
+
* if (userType === 'known') {
|
|
10981
|
+
* return true
|
|
10982
|
+
* }
|
|
10983
|
+
*
|
|
10984
|
+
* return isFromAd(searchParams) || searchParams.get('shopGPT') === '1'
|
|
10985
|
+
*/
|
|
10986
|
+
/**
|
|
10987
|
+
* For the time being we are disabling the welcome flow check
|
|
10988
|
+
* once we have the Updated UI for the chat, we will bring this back
|
|
10989
|
+
*/
|
|
10990
|
+
return false;
|
|
10943
10991
|
};
|
|
10944
10992
|
this.submitQuery = (message) => {
|
|
10945
10993
|
if (!message) {
|
|
@@ -11393,11 +11441,13 @@ class ShopGPT extends i$1 {
|
|
|
11393
11441
|
e.stopPropagation();
|
|
11394
11442
|
setUserInteracted(this.destination);
|
|
11395
11443
|
this.handleUserInteraction();
|
|
11444
|
+
this.shopGPTAPI.sendEvent('nudge-closed');
|
|
11396
11445
|
}
|
|
11397
11446
|
handlePopUpViewMinimised(e) {
|
|
11398
11447
|
e.stopPropagation();
|
|
11399
11448
|
this.miniPopupSeen = true;
|
|
11400
11449
|
this.shopGPTAPI.sendEvent('chatbotClosed-search');
|
|
11450
|
+
setPopupViewMiniMinimised(this.destination);
|
|
11401
11451
|
this.startNudgeTimer();
|
|
11402
11452
|
}
|
|
11403
11453
|
async handleNudgePromptClick(e) {
|
|
@@ -11418,7 +11468,7 @@ class ShopGPT extends i$1 {
|
|
|
11418
11468
|
async handleMiniPopUpPromptClick(e) {
|
|
11419
11469
|
e.stopPropagation();
|
|
11420
11470
|
this.miniPopupSeen = true;
|
|
11421
|
-
let miniPopAction = 'chatbotOpened-
|
|
11471
|
+
let miniPopAction = 'chatbotOpened-search-other';
|
|
11422
11472
|
await this.setSelectedThreadId('');
|
|
11423
11473
|
await this.createChatThread({ title: '' }, false);
|
|
11424
11474
|
if (e.detail.id === 'query') {
|
|
@@ -11574,7 +11624,10 @@ class ShopGPT extends i$1 {
|
|
|
11574
11624
|
></popup-view>
|
|
11575
11625
|
</div>`
|
|
11576
11626
|
: E}
|
|
11577
|
-
${!this.miniPopupSeen &&
|
|
11627
|
+
${!this.miniPopupSeen &&
|
|
11628
|
+
this.modalState !== 'open' &&
|
|
11629
|
+
!isPopupViewMiniMinimised(this.destination) &&
|
|
11630
|
+
!isUserInteracted(this.destination)
|
|
11578
11631
|
? x ` <div
|
|
11579
11632
|
id="shop-gpt-mini-modal"
|
|
11580
11633
|
@minimize-mini=${this.handlePopUpViewMinimised}
|
|
@@ -11588,7 +11641,10 @@ class ShopGPT extends i$1 {
|
|
|
11588
11641
|
></popup-view-mini>
|
|
11589
11642
|
</div>`
|
|
11590
11643
|
: E}
|
|
11591
|
-
${this.miniPopupSeen ||
|
|
11644
|
+
${this.miniPopupSeen ||
|
|
11645
|
+
this.modalState === 'open' ||
|
|
11646
|
+
isPopupViewMiniMinimised(this.destination) ||
|
|
11647
|
+
isUserInteracted(this.destination)
|
|
11592
11648
|
? x ` <div class="chatbot-widget">
|
|
11593
11649
|
<button
|
|
11594
11650
|
@click=${(e) => {
|
|
@@ -11631,6 +11687,7 @@ class ShopGPT extends i$1 {
|
|
|
11631
11687
|
this.nudgeTimer = window.setTimeout(() => {
|
|
11632
11688
|
this.playNudgeSound();
|
|
11633
11689
|
this.showNudge = true;
|
|
11690
|
+
this.shopGPTAPI.sendEvent('nudge-shown');
|
|
11634
11691
|
}, 2000);
|
|
11635
11692
|
return;
|
|
11636
11693
|
}
|
|
@@ -11645,6 +11702,7 @@ class ShopGPT extends i$1 {
|
|
|
11645
11702
|
if (!this.hasUserInteracted) {
|
|
11646
11703
|
this.playNudgeSound();
|
|
11647
11704
|
this.showNudge = true;
|
|
11705
|
+
this.shopGPTAPI.sendEvent('nudge-shown');
|
|
11648
11706
|
}
|
|
11649
11707
|
}, (((_b = this.nudge) === null || _b === void 0 ? void 0 : _b.timeout) || DEFAULT_NUDGE_TIMEOUT) * 1000);
|
|
11650
11708
|
}
|
package/index.js
CHANGED
|
@@ -461,6 +461,8 @@ var ProvidersShopGptSdk = (function () {
|
|
|
461
461
|
'chatbotOpened-nudge-query',
|
|
462
462
|
'chatbotOpened-nudge-support',
|
|
463
463
|
'chatbotOpened-nudge-other',
|
|
464
|
+
'nudge-shown',
|
|
465
|
+
'nudge-closed',
|
|
464
466
|
]);
|
|
465
467
|
/** Action length should not exceed 42 */
|
|
466
468
|
new Set([
|
|
@@ -638,7 +640,25 @@ var ProvidersShopGptSdk = (function () {
|
|
|
638
640
|
const session = getSessionData(destination);
|
|
639
641
|
saveSessionData(destination, {
|
|
640
642
|
...session,
|
|
641
|
-
chatbot: {
|
|
643
|
+
chatbot: {
|
|
644
|
+
...session === null || session === void 0 ? void 0 : session.chatbot,
|
|
645
|
+
hasUserInteracted: true,
|
|
646
|
+
},
|
|
647
|
+
});
|
|
648
|
+
};
|
|
649
|
+
const isPopupViewMiniMinimised = (destination) => {
|
|
650
|
+
var _a;
|
|
651
|
+
const session = getSessionData(destination);
|
|
652
|
+
return !!((_a = session === null || session === void 0 ? void 0 : session.chatbot) === null || _a === void 0 ? void 0 : _a.hasPopupViewMiniMinimised);
|
|
653
|
+
};
|
|
654
|
+
const setPopupViewMiniMinimised = (destination) => {
|
|
655
|
+
const session = getSessionData(destination);
|
|
656
|
+
saveSessionData(destination, {
|
|
657
|
+
...session,
|
|
658
|
+
chatbot: {
|
|
659
|
+
...session === null || session === void 0 ? void 0 : session.chatbot,
|
|
660
|
+
hasPopupViewMiniMinimised: true,
|
|
661
|
+
},
|
|
642
662
|
});
|
|
643
663
|
};
|
|
644
664
|
const getProductActions = (destination, sessionId) => {
|
|
@@ -975,6 +995,15 @@ var ProvidersShopGptSdk = (function () {
|
|
|
975
995
|
// exit if not in top window
|
|
976
996
|
return;
|
|
977
997
|
}
|
|
998
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
999
|
+
if (searchParams.get('evo') === 'preview') {
|
|
1000
|
+
try {
|
|
1001
|
+
sessionStorage.setItem('previewShopGPT', '1');
|
|
1002
|
+
}
|
|
1003
|
+
catch {
|
|
1004
|
+
error('Error in setting the sessionStorage for previewShopGPT');
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
978
1007
|
const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, supportPrompts, searchSuggestions, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, metafieldDisplayName, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
|
|
979
1008
|
const experiment = createExperiment({
|
|
980
1009
|
name: getExperimentName(mode),
|
|
@@ -6826,22 +6855,30 @@ var ProvidersShopGptSdk = (function () {
|
|
|
6826
6855
|
const capitalizeEachWord = (str) => {
|
|
6827
6856
|
return str === null || str === void 0 ? void 0 : str.replace(/^\w/, (char) => char.toUpperCase());
|
|
6828
6857
|
};
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6858
|
+
/**
|
|
6859
|
+
* For the time being we are disabling the welcome flow so commenting out this
|
|
6860
|
+
* once we decide to bring back the welcome flow we will uncomment this code
|
|
6861
|
+
*/
|
|
6862
|
+
/**
|
|
6863
|
+
* const adParams = new Set([
|
|
6864
|
+
* 'fbclid',
|
|
6865
|
+
* 'gclid',
|
|
6866
|
+
* 'sccid',
|
|
6867
|
+
* 'ttclid',
|
|
6868
|
+
* 'epik',
|
|
6869
|
+
* 'li_fat_id',
|
|
6870
|
+
* 'twclid',
|
|
6871
|
+
* 'rdt_cid',
|
|
6872
|
+
* 'aleid',
|
|
6873
|
+
* 'tabclid',
|
|
6874
|
+
* 'msclkid',
|
|
6875
|
+
* 'dclid',
|
|
6876
|
+
* 'wbraid',
|
|
6877
|
+
* ])
|
|
6878
|
+
*
|
|
6879
|
+
* export const isFromAd = (params: URLSearchParams) =>
|
|
6880
|
+
* [...params.keys()].some((key) => adParams.has(key.toLowerCase()))
|
|
6881
|
+
*/
|
|
6845
6882
|
|
|
6846
6883
|
const personalizeDialogStyles = i$4 `
|
|
6847
6884
|
:host {
|
|
@@ -10203,6 +10240,8 @@ ${this.comment ? this.comment : E}</textarea
|
|
|
10203
10240
|
}
|
|
10204
10241
|
|
|
10205
10242
|
.textarea-wrapper {
|
|
10243
|
+
display: flex;
|
|
10244
|
+
align-items: center;
|
|
10206
10245
|
position: relative;
|
|
10207
10246
|
width: 100%;
|
|
10208
10247
|
background: white;
|
|
@@ -10275,7 +10314,8 @@ ${this.comment ? this.comment : E}</textarea
|
|
|
10275
10314
|
.fake-cursor {
|
|
10276
10315
|
position: absolute;
|
|
10277
10316
|
left: 10px;
|
|
10278
|
-
top:
|
|
10317
|
+
top: 50%;
|
|
10318
|
+
transform: translateY(-50%);
|
|
10279
10319
|
width: 1px;
|
|
10280
10320
|
height: 16px;
|
|
10281
10321
|
background-color: #020617;
|
|
@@ -10928,19 +10968,27 @@ ${this.comment ? this.comment : E}</textarea
|
|
|
10928
10968
|
(_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
|
|
10929
10969
|
};
|
|
10930
10970
|
this.isWelcomeFlowRequired = () => {
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
|
|
10971
|
+
/**
|
|
10972
|
+
* if (this.devMode) {
|
|
10973
|
+
* const thread = this.chatThreads.get(this.selectedThreadId)
|
|
10974
|
+
* return thread?.devContext?.email
|
|
10975
|
+
* ? true
|
|
10976
|
+
* : !!thread?.devContext?.productHandle
|
|
10977
|
+
* }
|
|
10978
|
+
*
|
|
10979
|
+
* const searchParams = new URLSearchParams(window.location.search)
|
|
10980
|
+
* const userType = getUserType(this.destination, this.sessionId)
|
|
10981
|
+
* if (userType === 'known') {
|
|
10982
|
+
* return true
|
|
10983
|
+
* }
|
|
10984
|
+
*
|
|
10985
|
+
* return isFromAd(searchParams) || searchParams.get('shopGPT') === '1'
|
|
10986
|
+
*/
|
|
10987
|
+
/**
|
|
10988
|
+
* For the time being we are disabling the welcome flow check
|
|
10989
|
+
* once we have the Updated UI for the chat, we will bring this back
|
|
10990
|
+
*/
|
|
10991
|
+
return false;
|
|
10944
10992
|
};
|
|
10945
10993
|
this.submitQuery = (message) => {
|
|
10946
10994
|
if (!message) {
|
|
@@ -11394,11 +11442,13 @@ ${this.comment ? this.comment : E}</textarea
|
|
|
11394
11442
|
e.stopPropagation();
|
|
11395
11443
|
setUserInteracted(this.destination);
|
|
11396
11444
|
this.handleUserInteraction();
|
|
11445
|
+
this.shopGPTAPI.sendEvent('nudge-closed');
|
|
11397
11446
|
}
|
|
11398
11447
|
handlePopUpViewMinimised(e) {
|
|
11399
11448
|
e.stopPropagation();
|
|
11400
11449
|
this.miniPopupSeen = true;
|
|
11401
11450
|
this.shopGPTAPI.sendEvent('chatbotClosed-search');
|
|
11451
|
+
setPopupViewMiniMinimised(this.destination);
|
|
11402
11452
|
this.startNudgeTimer();
|
|
11403
11453
|
}
|
|
11404
11454
|
async handleNudgePromptClick(e) {
|
|
@@ -11419,7 +11469,7 @@ ${this.comment ? this.comment : E}</textarea
|
|
|
11419
11469
|
async handleMiniPopUpPromptClick(e) {
|
|
11420
11470
|
e.stopPropagation();
|
|
11421
11471
|
this.miniPopupSeen = true;
|
|
11422
|
-
let miniPopAction = 'chatbotOpened-
|
|
11472
|
+
let miniPopAction = 'chatbotOpened-search-other';
|
|
11423
11473
|
await this.setSelectedThreadId('');
|
|
11424
11474
|
await this.createChatThread({ title: '' }, false);
|
|
11425
11475
|
if (e.detail.id === 'query') {
|
|
@@ -11575,7 +11625,10 @@ ${this.comment ? this.comment : E}</textarea
|
|
|
11575
11625
|
></popup-view>
|
|
11576
11626
|
</div>`
|
|
11577
11627
|
: E}
|
|
11578
|
-
${!this.miniPopupSeen &&
|
|
11628
|
+
${!this.miniPopupSeen &&
|
|
11629
|
+
this.modalState !== 'open' &&
|
|
11630
|
+
!isPopupViewMiniMinimised(this.destination) &&
|
|
11631
|
+
!isUserInteracted(this.destination)
|
|
11579
11632
|
? x ` <div
|
|
11580
11633
|
id="shop-gpt-mini-modal"
|
|
11581
11634
|
@minimize-mini=${this.handlePopUpViewMinimised}
|
|
@@ -11589,7 +11642,10 @@ ${this.comment ? this.comment : E}</textarea
|
|
|
11589
11642
|
></popup-view-mini>
|
|
11590
11643
|
</div>`
|
|
11591
11644
|
: E}
|
|
11592
|
-
${this.miniPopupSeen ||
|
|
11645
|
+
${this.miniPopupSeen ||
|
|
11646
|
+
this.modalState === 'open' ||
|
|
11647
|
+
isPopupViewMiniMinimised(this.destination) ||
|
|
11648
|
+
isUserInteracted(this.destination)
|
|
11593
11649
|
? x ` <div class="chatbot-widget">
|
|
11594
11650
|
<button
|
|
11595
11651
|
@click=${(e) => {
|
|
@@ -11632,6 +11688,7 @@ ${this.comment ? this.comment : E}</textarea
|
|
|
11632
11688
|
this.nudgeTimer = window.setTimeout(() => {
|
|
11633
11689
|
this.playNudgeSound();
|
|
11634
11690
|
this.showNudge = true;
|
|
11691
|
+
this.shopGPTAPI.sendEvent('nudge-shown');
|
|
11635
11692
|
}, 2000);
|
|
11636
11693
|
return;
|
|
11637
11694
|
}
|
|
@@ -11646,6 +11703,7 @@ ${this.comment ? this.comment : E}</textarea
|
|
|
11646
11703
|
if (!this.hasUserInteracted) {
|
|
11647
11704
|
this.playNudgeSound();
|
|
11648
11705
|
this.showNudge = true;
|
|
11706
|
+
this.shopGPTAPI.sendEvent('nudge-shown');
|
|
11649
11707
|
}
|
|
11650
11708
|
}, (((_b = this.nudge) === null || _b === void 0 ? void 0 : _b.timeout) || DEFAULT_NUDGE_TIMEOUT) * 1000);
|
|
11651
11709
|
}
|
package/index.mjs
CHANGED
|
@@ -458,6 +458,8 @@ const uiActions = new Set([
|
|
|
458
458
|
'chatbotOpened-nudge-query',
|
|
459
459
|
'chatbotOpened-nudge-support',
|
|
460
460
|
'chatbotOpened-nudge-other',
|
|
461
|
+
'nudge-shown',
|
|
462
|
+
'nudge-closed',
|
|
461
463
|
]);
|
|
462
464
|
/** Action length should not exceed 42 */
|
|
463
465
|
new Set([
|
|
@@ -635,7 +637,25 @@ const setUserInteracted = (destination) => {
|
|
|
635
637
|
const session = getSessionData(destination);
|
|
636
638
|
saveSessionData(destination, {
|
|
637
639
|
...session,
|
|
638
|
-
chatbot: {
|
|
640
|
+
chatbot: {
|
|
641
|
+
...session === null || session === void 0 ? void 0 : session.chatbot,
|
|
642
|
+
hasUserInteracted: true,
|
|
643
|
+
},
|
|
644
|
+
});
|
|
645
|
+
};
|
|
646
|
+
const isPopupViewMiniMinimised = (destination) => {
|
|
647
|
+
var _a;
|
|
648
|
+
const session = getSessionData(destination);
|
|
649
|
+
return !!((_a = session === null || session === void 0 ? void 0 : session.chatbot) === null || _a === void 0 ? void 0 : _a.hasPopupViewMiniMinimised);
|
|
650
|
+
};
|
|
651
|
+
const setPopupViewMiniMinimised = (destination) => {
|
|
652
|
+
const session = getSessionData(destination);
|
|
653
|
+
saveSessionData(destination, {
|
|
654
|
+
...session,
|
|
655
|
+
chatbot: {
|
|
656
|
+
...session === null || session === void 0 ? void 0 : session.chatbot,
|
|
657
|
+
hasPopupViewMiniMinimised: true,
|
|
658
|
+
},
|
|
639
659
|
});
|
|
640
660
|
};
|
|
641
661
|
const getProductActions = (destination, sessionId) => {
|
|
@@ -972,6 +992,15 @@ const init = (params) => {
|
|
|
972
992
|
// exit if not in top window
|
|
973
993
|
return;
|
|
974
994
|
}
|
|
995
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
996
|
+
if (searchParams.get('evo') === 'preview') {
|
|
997
|
+
try {
|
|
998
|
+
sessionStorage.setItem('previewShopGPT', '1');
|
|
999
|
+
}
|
|
1000
|
+
catch {
|
|
1001
|
+
error('Error in setting the sessionStorage for previewShopGPT');
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
975
1004
|
const { enabled, mode, devMode, merchantUrl, profiles, productHandles, targetPath, view, brandName, quickPrompts, supportPrompts, searchSuggestions, merchantImage, latestThreadLoad, botIconUrl, css, nudge, loadUIManually, metafieldDisplayName, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
|
|
976
1005
|
const experiment = createExperiment({
|
|
977
1006
|
name: getExperimentName(mode),
|
|
@@ -6823,22 +6852,30 @@ const chatSectionStyles$1 = i$4 `
|
|
|
6823
6852
|
const capitalizeEachWord = (str) => {
|
|
6824
6853
|
return str === null || str === void 0 ? void 0 : str.replace(/^\w/, (char) => char.toUpperCase());
|
|
6825
6854
|
};
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6855
|
+
/**
|
|
6856
|
+
* For the time being we are disabling the welcome flow so commenting out this
|
|
6857
|
+
* once we decide to bring back the welcome flow we will uncomment this code
|
|
6858
|
+
*/
|
|
6859
|
+
/**
|
|
6860
|
+
* const adParams = new Set([
|
|
6861
|
+
* 'fbclid',
|
|
6862
|
+
* 'gclid',
|
|
6863
|
+
* 'sccid',
|
|
6864
|
+
* 'ttclid',
|
|
6865
|
+
* 'epik',
|
|
6866
|
+
* 'li_fat_id',
|
|
6867
|
+
* 'twclid',
|
|
6868
|
+
* 'rdt_cid',
|
|
6869
|
+
* 'aleid',
|
|
6870
|
+
* 'tabclid',
|
|
6871
|
+
* 'msclkid',
|
|
6872
|
+
* 'dclid',
|
|
6873
|
+
* 'wbraid',
|
|
6874
|
+
* ])
|
|
6875
|
+
*
|
|
6876
|
+
* export const isFromAd = (params: URLSearchParams) =>
|
|
6877
|
+
* [...params.keys()].some((key) => adParams.has(key.toLowerCase()))
|
|
6878
|
+
*/
|
|
6842
6879
|
|
|
6843
6880
|
const personalizeDialogStyles = i$4 `
|
|
6844
6881
|
:host {
|
|
@@ -10200,6 +10237,8 @@ const popupViewMiniStyles = i$4 `
|
|
|
10200
10237
|
}
|
|
10201
10238
|
|
|
10202
10239
|
.textarea-wrapper {
|
|
10240
|
+
display: flex;
|
|
10241
|
+
align-items: center;
|
|
10203
10242
|
position: relative;
|
|
10204
10243
|
width: 100%;
|
|
10205
10244
|
background: white;
|
|
@@ -10272,7 +10311,8 @@ const popupViewMiniStyles = i$4 `
|
|
|
10272
10311
|
.fake-cursor {
|
|
10273
10312
|
position: absolute;
|
|
10274
10313
|
left: 10px;
|
|
10275
|
-
top:
|
|
10314
|
+
top: 50%;
|
|
10315
|
+
transform: translateY(-50%);
|
|
10276
10316
|
width: 1px;
|
|
10277
10317
|
height: 16px;
|
|
10278
10318
|
background-color: #020617;
|
|
@@ -10925,19 +10965,27 @@ class ShopGPT extends i$1 {
|
|
|
10925
10965
|
(_a = this.shopGPTDialog) === null || _a === void 0 ? void 0 : _a.close();
|
|
10926
10966
|
};
|
|
10927
10967
|
this.isWelcomeFlowRequired = () => {
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10968
|
+
/**
|
|
10969
|
+
* if (this.devMode) {
|
|
10970
|
+
* const thread = this.chatThreads.get(this.selectedThreadId)
|
|
10971
|
+
* return thread?.devContext?.email
|
|
10972
|
+
* ? true
|
|
10973
|
+
* : !!thread?.devContext?.productHandle
|
|
10974
|
+
* }
|
|
10975
|
+
*
|
|
10976
|
+
* const searchParams = new URLSearchParams(window.location.search)
|
|
10977
|
+
* const userType = getUserType(this.destination, this.sessionId)
|
|
10978
|
+
* if (userType === 'known') {
|
|
10979
|
+
* return true
|
|
10980
|
+
* }
|
|
10981
|
+
*
|
|
10982
|
+
* return isFromAd(searchParams) || searchParams.get('shopGPT') === '1'
|
|
10983
|
+
*/
|
|
10984
|
+
/**
|
|
10985
|
+
* For the time being we are disabling the welcome flow check
|
|
10986
|
+
* once we have the Updated UI for the chat, we will bring this back
|
|
10987
|
+
*/
|
|
10988
|
+
return false;
|
|
10941
10989
|
};
|
|
10942
10990
|
this.submitQuery = (message) => {
|
|
10943
10991
|
if (!message) {
|
|
@@ -11391,11 +11439,13 @@ class ShopGPT extends i$1 {
|
|
|
11391
11439
|
e.stopPropagation();
|
|
11392
11440
|
setUserInteracted(this.destination);
|
|
11393
11441
|
this.handleUserInteraction();
|
|
11442
|
+
this.shopGPTAPI.sendEvent('nudge-closed');
|
|
11394
11443
|
}
|
|
11395
11444
|
handlePopUpViewMinimised(e) {
|
|
11396
11445
|
e.stopPropagation();
|
|
11397
11446
|
this.miniPopupSeen = true;
|
|
11398
11447
|
this.shopGPTAPI.sendEvent('chatbotClosed-search');
|
|
11448
|
+
setPopupViewMiniMinimised(this.destination);
|
|
11399
11449
|
this.startNudgeTimer();
|
|
11400
11450
|
}
|
|
11401
11451
|
async handleNudgePromptClick(e) {
|
|
@@ -11416,7 +11466,7 @@ class ShopGPT extends i$1 {
|
|
|
11416
11466
|
async handleMiniPopUpPromptClick(e) {
|
|
11417
11467
|
e.stopPropagation();
|
|
11418
11468
|
this.miniPopupSeen = true;
|
|
11419
|
-
let miniPopAction = 'chatbotOpened-
|
|
11469
|
+
let miniPopAction = 'chatbotOpened-search-other';
|
|
11420
11470
|
await this.setSelectedThreadId('');
|
|
11421
11471
|
await this.createChatThread({ title: '' }, false);
|
|
11422
11472
|
if (e.detail.id === 'query') {
|
|
@@ -11572,7 +11622,10 @@ class ShopGPT extends i$1 {
|
|
|
11572
11622
|
></popup-view>
|
|
11573
11623
|
</div>`
|
|
11574
11624
|
: E}
|
|
11575
|
-
${!this.miniPopupSeen &&
|
|
11625
|
+
${!this.miniPopupSeen &&
|
|
11626
|
+
this.modalState !== 'open' &&
|
|
11627
|
+
!isPopupViewMiniMinimised(this.destination) &&
|
|
11628
|
+
!isUserInteracted(this.destination)
|
|
11576
11629
|
? x ` <div
|
|
11577
11630
|
id="shop-gpt-mini-modal"
|
|
11578
11631
|
@minimize-mini=${this.handlePopUpViewMinimised}
|
|
@@ -11586,7 +11639,10 @@ class ShopGPT extends i$1 {
|
|
|
11586
11639
|
></popup-view-mini>
|
|
11587
11640
|
</div>`
|
|
11588
11641
|
: E}
|
|
11589
|
-
${this.miniPopupSeen ||
|
|
11642
|
+
${this.miniPopupSeen ||
|
|
11643
|
+
this.modalState === 'open' ||
|
|
11644
|
+
isPopupViewMiniMinimised(this.destination) ||
|
|
11645
|
+
isUserInteracted(this.destination)
|
|
11590
11646
|
? x ` <div class="chatbot-widget">
|
|
11591
11647
|
<button
|
|
11592
11648
|
@click=${(e) => {
|
|
@@ -11629,6 +11685,7 @@ class ShopGPT extends i$1 {
|
|
|
11629
11685
|
this.nudgeTimer = window.setTimeout(() => {
|
|
11630
11686
|
this.playNudgeSound();
|
|
11631
11687
|
this.showNudge = true;
|
|
11688
|
+
this.shopGPTAPI.sendEvent('nudge-shown');
|
|
11632
11689
|
}, 2000);
|
|
11633
11690
|
return;
|
|
11634
11691
|
}
|
|
@@ -11643,6 +11700,7 @@ class ShopGPT extends i$1 {
|
|
|
11643
11700
|
if (!this.hasUserInteracted) {
|
|
11644
11701
|
this.playNudgeSound();
|
|
11645
11702
|
this.showNudge = true;
|
|
11703
|
+
this.shopGPTAPI.sendEvent('nudge-shown');
|
|
11646
11704
|
}
|
|
11647
11705
|
}, (((_b = this.nudge) === null || _b === void 0 ? void 0 : _b.timeout) || DEFAULT_NUDGE_TIMEOUT) * 1000);
|
|
11648
11706
|
}
|