@saasquatch/squatch-js 2.6.0-2 → 2.6.0-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/coverage/clover.xml +2 -2
- package/coverage/lcov-report/WidgetApi.ts.html +85 -85
- package/coverage/lcov-report/api/AnalyticsApi.ts.html +1 -1
- package/coverage/lcov-report/api/WidgetApi.ts.html +6 -6
- package/coverage/lcov-report/api/graphql.ts.html +1 -1
- package/coverage/lcov-report/utils/domready.ts.html +1 -1
- package/coverage/lcov-report/utils/io.ts.html +1 -1
- package/coverage/lcov-report/utils/validate.ts.html +9 -9
- package/coverage/lcov-report/widgets/EmbedWidget.ts.html +1 -1
- package/coverage/lcov-report/widgets/PopupWidget.ts.html +1 -1
- package/coverage/lcov-report/widgets/Widget.ts.html +12 -9
- package/coverage/lcov-report/widgets/Widgets.ts.html +77 -77
- package/dist/squatch.d.ts +1 -1
- package/dist/squatch.esm.js +34 -21
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +34 -21
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +1 -1
- package/dist/widgets/declarative/DeclarativeWidget.d.ts +1 -0
- package/package.json +1 -1
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">90.09% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>91/101</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">71.05% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>27/38</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">81.81% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>9/11</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">89.79% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>88/98</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -438,11 +438,11 @@
|
|
|
438
438
|
<span class="cline-any cline-neutral"> </span>
|
|
439
439
|
<span class="cline-any cline-neutral"> </span>
|
|
440
440
|
<span class="cline-any cline-neutral"> </span>
|
|
441
|
-
<span class="cline-any cline-yes">
|
|
442
|
-
<span class="cline-any cline-yes">
|
|
443
|
-
<span class="cline-any cline-yes">
|
|
444
|
-
<span class="cline-any cline-yes">
|
|
445
|
-
<span class="cline-any cline-yes">
|
|
441
|
+
<span class="cline-any cline-yes">32x</span>
|
|
442
|
+
<span class="cline-any cline-yes">32x</span>
|
|
443
|
+
<span class="cline-any cline-yes">32x</span>
|
|
444
|
+
<span class="cline-any cline-yes">32x</span>
|
|
445
|
+
<span class="cline-any cline-yes">32x</span>
|
|
446
446
|
<span class="cline-any cline-neutral"> </span>
|
|
447
447
|
<span class="cline-any cline-neutral"> </span>
|
|
448
448
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -586,7 +586,6 @@
|
|
|
586
586
|
<span class="cline-any cline-neutral"> </span>
|
|
587
587
|
<span class="cline-any cline-yes">12x</span>
|
|
588
588
|
<span class="cline-any cline-yes">12x</span>
|
|
589
|
-
<span class="cline-any cline-yes">12x</span>
|
|
590
589
|
<span class="cline-any cline-neutral"> </span>
|
|
591
590
|
<span class="cline-any cline-yes">12x</span>
|
|
592
591
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -598,17 +597,18 @@
|
|
|
598
597
|
<span class="cline-any cline-neutral"> </span>
|
|
599
598
|
<span class="cline-any cline-neutral"> </span>
|
|
600
599
|
<span class="cline-any cline-yes">12x</span>
|
|
601
|
-
<span class="cline-any cline-yes">
|
|
602
|
-
<span class="cline-any cline-yes">
|
|
603
|
-
<span class="cline-any cline-yes">
|
|
600
|
+
<span class="cline-any cline-yes">4x</span>
|
|
601
|
+
<span class="cline-any cline-yes">4x</span>
|
|
602
|
+
<span class="cline-any cline-yes">3x</span>
|
|
603
|
+
<span class="cline-any cline-yes">3x</span>
|
|
604
604
|
<span class="cline-any cline-neutral"> </span>
|
|
605
605
|
<span class="cline-any cline-neutral"> </span>
|
|
606
606
|
<span class="cline-any cline-neutral"> </span>
|
|
607
|
-
<span class="cline-any cline-yes">
|
|
608
|
-
<span class="cline-any cline-yes">
|
|
609
|
-
<span class="cline-any cline-yes">
|
|
607
|
+
<span class="cline-any cline-yes">1x</span>
|
|
608
|
+
<span class="cline-any cline-yes">1x</span>
|
|
609
|
+
<span class="cline-any cline-yes">1x</span>
|
|
610
610
|
<span class="cline-any cline-neutral"> </span>
|
|
611
|
-
<span class="cline-any cline-
|
|
611
|
+
<span class="cline-any cline-yes">2x</span>
|
|
612
612
|
<span class="cline-any cline-neutral"> </span>
|
|
613
613
|
<span class="cline-any cline-neutral"> </span>
|
|
614
614
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -617,12 +617,12 @@
|
|
|
617
617
|
<span class="cline-any cline-neutral"> </span>
|
|
618
618
|
<span class="cline-any cline-neutral"> </span>
|
|
619
619
|
<span class="cline-any cline-yes">12x</span>
|
|
620
|
-
<span class="cline-any cline-
|
|
620
|
+
<span class="cline-any cline-no"> </span>
|
|
621
621
|
<span class="cline-any cline-neutral"> </span>
|
|
622
|
-
<span class="cline-any cline-
|
|
623
|
-
<span class="cline-any cline-
|
|
624
|
-
<span class="cline-any cline-
|
|
625
|
-
<span class="cline-any cline-
|
|
622
|
+
<span class="cline-any cline-no"> </span>
|
|
623
|
+
<span class="cline-any cline-no"> </span>
|
|
624
|
+
<span class="cline-any cline-no"> </span>
|
|
625
|
+
<span class="cline-any cline-no"> </span>
|
|
626
626
|
<span class="cline-any cline-no"> </span>
|
|
627
627
|
<span class="cline-any cline-neutral"> </span>
|
|
628
628
|
<span class="cline-any cline-no"> </span>
|
|
@@ -641,32 +641,32 @@
|
|
|
641
641
|
<span class="cline-any cline-neutral"> </span>
|
|
642
642
|
<span class="cline-any cline-neutral"> </span>
|
|
643
643
|
<span class="cline-any cline-yes">12x</span>
|
|
644
|
-
<span class="cline-any cline-yes">3x</span>
|
|
645
|
-
<span class="cline-any cline-yes">9x</span>
|
|
646
|
-
<span class="cline-any cline-yes">2x</span>
|
|
647
644
|
<span class="cline-any cline-yes">2x</span>
|
|
645
|
+
<span class="cline-any cline-yes">10x</span>
|
|
646
|
+
<span class="cline-any cline-yes">5x</span>
|
|
647
|
+
<span class="cline-any cline-yes">5x</span>
|
|
648
648
|
<span class="cline-any cline-neutral"> </span>
|
|
649
|
-
<span class="cline-any cline-yes">
|
|
650
|
-
<span class="cline-any cline-yes">
|
|
651
|
-
<span class="cline-any cline-yes">
|
|
652
|
-
<span class="cline-any cline-yes">
|
|
649
|
+
<span class="cline-any cline-yes">5x</span>
|
|
650
|
+
<span class="cline-any cline-yes">5x</span>
|
|
651
|
+
<span class="cline-any cline-yes">5x</span>
|
|
652
|
+
<span class="cline-any cline-yes">5x</span>
|
|
653
653
|
<span class="cline-any cline-neutral"> </span>
|
|
654
654
|
<span class="cline-any cline-neutral"> </span>
|
|
655
655
|
<span class="cline-any cline-yes">12x</span>
|
|
656
656
|
<span class="cline-any cline-neutral"> </span>
|
|
657
657
|
<span class="cline-any cline-neutral"> </span>
|
|
658
658
|
<span class="cline-any cline-neutral"> </span>
|
|
659
|
-
<span class="cline-any cline-yes">
|
|
660
|
-
<span class="cline-any cline-yes">
|
|
659
|
+
<span class="cline-any cline-yes">5x</span>
|
|
660
|
+
<span class="cline-any cline-yes">5x</span>
|
|
661
661
|
<span class="cline-any cline-neutral"> </span>
|
|
662
|
-
<span class="cline-any cline-yes">
|
|
662
|
+
<span class="cline-any cline-yes">5x</span>
|
|
663
663
|
<span class="cline-any cline-neutral"> </span>
|
|
664
664
|
<span class="cline-any cline-neutral"> </span>
|
|
665
665
|
<span class="cline-any cline-neutral"> </span>
|
|
666
|
-
<span class="cline-any cline-yes">
|
|
667
|
-
<span class="cline-any cline-yes">
|
|
666
|
+
<span class="cline-any cline-yes">2x</span>
|
|
667
|
+
<span class="cline-any cline-yes">2x</span>
|
|
668
668
|
<span class="cline-any cline-neutral"> </span>
|
|
669
|
-
<span class="cline-any cline-yes">
|
|
669
|
+
<span class="cline-any cline-yes">2x</span>
|
|
670
670
|
<span class="cline-any cline-neutral"> </span>
|
|
671
671
|
<span class="cline-any cline-neutral"> </span>
|
|
672
672
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -679,10 +679,10 @@
|
|
|
679
679
|
<span class="cline-any cline-neutral"> </span>
|
|
680
680
|
<span class="cline-any cline-neutral"> </span>
|
|
681
681
|
<span class="cline-any cline-neutral"> </span>
|
|
682
|
-
<span class="cline-any cline-
|
|
683
|
-
<span class="cline-any cline-
|
|
682
|
+
<span class="cline-any cline-yes">4x</span>
|
|
683
|
+
<span class="cline-any cline-yes">4x</span>
|
|
684
684
|
<span class="cline-any cline-neutral"> </span>
|
|
685
|
-
<span class="cline-any cline-
|
|
685
|
+
<span class="cline-any cline-yes">4x</span>
|
|
686
686
|
<span class="cline-any cline-neutral"> </span>
|
|
687
687
|
<span class="cline-any cline-neutral"> </span>
|
|
688
688
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -694,12 +694,12 @@
|
|
|
694
694
|
<span class="cline-any cline-neutral"> </span>
|
|
695
695
|
<span class="cline-any cline-neutral"> </span>
|
|
696
696
|
<span class="cline-any cline-neutral"> </span>
|
|
697
|
-
<span class="cline-any cline-
|
|
698
|
-
<span class="cline-any cline-
|
|
699
|
-
<span class="cline-any cline-
|
|
700
|
-
<span class="cline-any cline-
|
|
701
|
-
<span class="cline-any cline-
|
|
702
|
-
<span class="cline-any cline-
|
|
697
|
+
<span class="cline-any cline-yes">4x</span>
|
|
698
|
+
<span class="cline-any cline-yes">1x</span>
|
|
699
|
+
<span class="cline-any cline-yes">1x</span>
|
|
700
|
+
<span class="cline-any cline-yes">3x</span>
|
|
701
|
+
<span class="cline-any cline-yes">2x</span>
|
|
702
|
+
<span class="cline-any cline-yes">2x</span>
|
|
703
703
|
<span class="cline-any cline-neutral"> </span>
|
|
704
704
|
<span class="cline-any cline-neutral"> </span>
|
|
705
705
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -710,7 +710,7 @@
|
|
|
710
710
|
<span class="cline-any cline-neutral"> </span>
|
|
711
711
|
<span class="cline-any cline-neutral"> </span>
|
|
712
712
|
<span class="cline-any cline-neutral"> </span>
|
|
713
|
-
<span class="cline-any cline-
|
|
713
|
+
<span class="cline-any cline-no"> </span>
|
|
714
714
|
<span class="cline-any cline-neutral"> </span>
|
|
715
715
|
<span class="cline-any cline-neutral"> </span>
|
|
716
716
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { debug } from "debug";
|
|
@@ -798,7 +798,7 @@ export default class Widgets {
|
|
|
798
798
|
return {
|
|
799
799
|
widget: this._renderWidget(response, clean, {
|
|
800
800
|
type: "upsert",
|
|
801
|
-
user: clean.user
|
|
801
|
+
user: clean.user,
|
|
802
802
|
engagementMedium: config.engagementMedium,
|
|
803
803
|
container: config.container,
|
|
804
804
|
trigger: config.trigger,
|
|
@@ -910,7 +910,6 @@ export default class Widgets {
|
|
|
910
910
|
|
|
911
911
|
let widget;
|
|
912
912
|
let displayOnLoad = !!config.displayOnLoad;
|
|
913
|
-
let displayCTA = false;
|
|
914
913
|
const opts = response.jsOptions || {};
|
|
915
914
|
|
|
916
915
|
const params = {
|
|
@@ -925,15 +924,16 @@ export default class Widgets {
|
|
|
925
924
|
if (opts.widgetUrlMappings) {
|
|
926
925
|
opts.widgetUrlMappings.forEach((rule) => {
|
|
927
926
|
if (Widgets._matchesUrl(rule.url)) {
|
|
927
|
+
console.log({ response, rule });
|
|
928
928
|
if (
|
|
929
929
|
rule.widgetType !== "CONVERSION_WIDGET" ||
|
|
930
|
-
|
|
930
|
+
response.user?.referredBy?.code
|
|
931
931
|
) {
|
|
932
|
+
console.log("HERE");
|
|
932
933
|
displayOnLoad = rule.displayOnLoad;
|
|
933
|
-
displayCTA = rule.showAsCTA;
|
|
934
934
|
_log(`Display ${rule.widgetType} on ${rule.url}`);
|
|
935
|
-
} else
|
|
936
|
-
|
|
935
|
+
} else {
|
|
936
|
+
_log(
|
|
937
937
|
`Don't display ${rule.widgetType} when no referral on widget rule match ${rule.url}`
|
|
938
938
|
);
|
|
939
939
|
}
|
|
@@ -941,13 +941,13 @@ export default class Widgets {
|
|
|
941
941
|
});
|
|
942
942
|
}
|
|
943
943
|
|
|
944
|
-
if (opts.fuelTankAutofillUrls) {
|
|
945
|
-
_log("We found a fuel tank autofill!")
|
|
944
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (opts.fuelTankAutofillUrls) {
|
|
945
|
+
<span class="cstat-no" title="statement not covered" > _log("We found a fuel tank autofill!");</span>
|
|
946
946
|
|
|
947
|
-
opts.fuelTankAutofillUrls.forEach(({ url, formSelector }) => {
|
|
948
|
-
if (Widgets._matchesUrl(url)) {
|
|
949
|
-
_log("Fuel Tank URL matches")
|
|
950
|
-
<span class="missing-if-branch" title="if path not taken" >I</span>if (response.user?.referredBy &&
|
|
947
|
+
<span class="cstat-no" title="statement not covered" > opts.fuelTankAutofillUrls.forEach(<span class="fstat-no" title="function not covered" >({</span> url, formSelector }) => {</span>
|
|
948
|
+
<span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (Widgets._matchesUrl(url)) {</span>
|
|
949
|
+
<span class="cstat-no" title="statement not covered" > _log("Fuel Tank URL matches");</span>
|
|
950
|
+
<span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (response.user?.referredBy && response.user?.referredBy?.code) {</span>
|
|
951
951
|
const formAutofill = <span class="cstat-no" title="statement not covered" >document.querySelector(formSelector);</span>
|
|
952
952
|
|
|
953
953
|
<span class="cstat-no" title="statement not covered" > if (formAutofill) {</span>
|
|
@@ -966,7 +966,7 @@ export default class Widgets {
|
|
|
966
966
|
}
|
|
967
967
|
|
|
968
968
|
if (config.engagementMedium === "EMBED") {
|
|
969
|
-
this._renderEmbedWidget(params, params.context.container);
|
|
969
|
+
widget = this._renderEmbedWidget(params, params.context.container);
|
|
970
970
|
} else if (config.engagementMedium === "POPUP") {
|
|
971
971
|
widget = this._renderPopupWidget(params);
|
|
972
972
|
if (displayOnLoad) widget.open();
|
|
@@ -988,7 +988,7 @@ export default class Widgets {
|
|
|
988
988
|
}
|
|
989
989
|
|
|
990
990
|
private _renderEmbedWidget(params, container) {
|
|
991
|
-
const widget = new EmbedWidget(params);
|
|
991
|
+
const widget = new EmbedWidget(params, container);
|
|
992
992
|
widget.load();
|
|
993
993
|
|
|
994
994
|
return widget;
|
|
@@ -1000,14 +1000,14 @@ export default class Widgets {
|
|
|
1000
1000
|
* @param {string} em The engagementMedium
|
|
1001
1001
|
* @returns {void}
|
|
1002
1002
|
*/
|
|
1003
|
-
private
|
|
1003
|
+
private _renderErrorWidget(
|
|
1004
1004
|
props: { apiErrorCode: string; rsCode: string; message: string },
|
|
1005
|
-
em: EngagementMedium =
|
|
1005
|
+
em: EngagementMedium = "POPUP"
|
|
1006
1006
|
) {
|
|
1007
|
-
const { apiErrorCode, rsCode, message } =
|
|
1008
|
-
|
|
1007
|
+
const { apiErrorCode, rsCode, message } = props;
|
|
1008
|
+
_log(new Error(`${apiErrorCode} (${rsCode}) ${message}`));
|
|
1009
1009
|
|
|
1010
|
-
const params: Params =
|
|
1010
|
+
const params: Params = {
|
|
1011
1011
|
content: "error",
|
|
1012
1012
|
rsCode,
|
|
1013
1013
|
api: this.api,
|
|
@@ -1019,12 +1019,12 @@ export default class Widgets {
|
|
|
1019
1019
|
|
|
1020
1020
|
let widget: Widget;
|
|
1021
1021
|
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
} else
|
|
1026
|
-
|
|
1027
|
-
|
|
1022
|
+
if (em === "EMBED") {
|
|
1023
|
+
widget = new EmbedWidget(params);
|
|
1024
|
+
widget.load();
|
|
1025
|
+
} else if (em === "POPUP") {
|
|
1026
|
+
widget = new PopupWidget(params);
|
|
1027
|
+
widget.load();
|
|
1028
1028
|
}
|
|
1029
1029
|
}
|
|
1030
1030
|
|
|
@@ -1033,9 +1033,9 @@ export default class Widgets {
|
|
|
1033
1033
|
* @param {string} rule A regular expression
|
|
1034
1034
|
* @returns {boolean} true if rule matches Url, false otherwise
|
|
1035
1035
|
*/
|
|
1036
|
-
private static _matchesUrl(rule) {
|
|
1036
|
+
private <span class="fstat-no" title="function not covered" >static </span>_matchesUrl(rule) {
|
|
1037
1037
|
// If there were no matches, null is returned.
|
|
1038
|
-
return window.location.href.match(new RegExp(rule)) ? true :
|
|
1038
|
+
<span class="cstat-no" title="statement not covered" > return window.location.href.match(new RegExp(rule)) ? true : false;</span>
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
1041
|
</pre></td></tr></table></pre>
|
|
@@ -1045,7 +1045,7 @@ export default class Widgets {
|
|
|
1045
1045
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
1046
1046
|
Code coverage generated by
|
|
1047
1047
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
1048
|
-
at 2023-07-
|
|
1048
|
+
at 2023-07-19T17:47:30.555Z
|
|
1049
1049
|
</div>
|
|
1050
1050
|
<script src="../prettify.js"></script>
|
|
1051
1051
|
<script>
|
package/dist/squatch.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export declare function init(configIn: ConfigOptions): void;
|
|
|
62
62
|
* @example
|
|
63
63
|
* squatch.ready(function() {
|
|
64
64
|
* console.log("ready!");
|
|
65
|
-
* squatch.api().upsertUser();
|
|
65
|
+
* squatch.api().upsertUser({ ... });
|
|
66
66
|
* });
|
|
67
67
|
*/
|
|
68
68
|
export declare function ready(fn: () => any): void;
|
package/dist/squatch.esm.js
CHANGED
|
@@ -1110,7 +1110,7 @@ class Widgets {
|
|
|
1110
1110
|
return {
|
|
1111
1111
|
widget: this._renderWidget(response, clean, {
|
|
1112
1112
|
type: "upsert",
|
|
1113
|
-
user: clean.user
|
|
1113
|
+
user: clean.user,
|
|
1114
1114
|
engagementMedium: config.engagementMedium,
|
|
1115
1115
|
container: config.container,
|
|
1116
1116
|
trigger: config.trigger
|
|
@@ -1242,9 +1242,15 @@ class Widgets {
|
|
|
1242
1242
|
if (opts.widgetUrlMappings) {
|
|
1243
1243
|
opts.widgetUrlMappings.forEach(rule => {
|
|
1244
1244
|
if (Widgets._matchesUrl(rule.url)) {
|
|
1245
|
-
var _response$user, _response$
|
|
1245
|
+
var _response$user, _response$user$referr;
|
|
1246
1246
|
|
|
1247
|
-
|
|
1247
|
+
console.log({
|
|
1248
|
+
response,
|
|
1249
|
+
rule
|
|
1250
|
+
});
|
|
1251
|
+
|
|
1252
|
+
if (rule.widgetType !== "CONVERSION_WIDGET" || (_response$user = response.user) != null && (_response$user$referr = _response$user.referredBy) != null && _response$user$referr.code) {
|
|
1253
|
+
console.log("HERE");
|
|
1248
1254
|
displayOnLoad = rule.displayOnLoad;
|
|
1249
1255
|
|
|
1250
1256
|
_log$4("Display " + rule.widgetType + " on " + rule.url);
|
|
@@ -1265,15 +1271,17 @@ class Widgets {
|
|
|
1265
1271
|
} = _ref;
|
|
1266
1272
|
|
|
1267
1273
|
if (Widgets._matchesUrl(url)) {
|
|
1268
|
-
var _response$
|
|
1274
|
+
var _response$user2, _response$user2$refer;
|
|
1269
1275
|
|
|
1270
1276
|
_log$4("Fuel Tank URL matches");
|
|
1271
1277
|
|
|
1272
|
-
if ((_response$
|
|
1278
|
+
if ((_response$user2 = response.user) != null && (_response$user2$refer = _response$user2.referredBy) != null && _response$user2$refer.code) {
|
|
1273
1279
|
var formAutofill = document.querySelector(formSelector);
|
|
1274
1280
|
|
|
1275
1281
|
if (formAutofill) {
|
|
1276
|
-
|
|
1282
|
+
var _response$user$referr2;
|
|
1283
|
+
|
|
1284
|
+
formAutofill.value = ((_response$user$referr2 = response.user.referredBy.referredReward) == null ? void 0 : _response$user$referr2.fuelTankCode) || "";
|
|
1277
1285
|
} else {
|
|
1278
1286
|
_log$4(new Error("Element with id/class " + formSelector + " was not found."));
|
|
1279
1287
|
}
|
|
@@ -1305,7 +1313,7 @@ class Widgets {
|
|
|
1305
1313
|
}
|
|
1306
1314
|
|
|
1307
1315
|
_renderEmbedWidget(params, container) {
|
|
1308
|
-
var widget = new EmbedWidget(params);
|
|
1316
|
+
var widget = new EmbedWidget(params, container);
|
|
1309
1317
|
widget.load();
|
|
1310
1318
|
return widget;
|
|
1311
1319
|
}
|
|
@@ -1662,6 +1670,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1662
1670
|
this.token = void 0;
|
|
1663
1671
|
this.tenant = void 0;
|
|
1664
1672
|
this.widgetType = void 0;
|
|
1673
|
+
this.locale = void 0;
|
|
1665
1674
|
this.widgetApi = void 0;
|
|
1666
1675
|
this.analyticsApi = void 0;
|
|
1667
1676
|
this.type = void 0;
|
|
@@ -1724,6 +1733,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1724
1733
|
this.token = window.squatchToken;
|
|
1725
1734
|
this.tenant = window.squatchTenant;
|
|
1726
1735
|
this.container = this;
|
|
1736
|
+
this.locale = validateLocale(navigator.language.replace(/\-/g, "_"));
|
|
1727
1737
|
}
|
|
1728
1738
|
|
|
1729
1739
|
_setupApis(config) {
|
|
@@ -1740,7 +1750,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1740
1750
|
}
|
|
1741
1751
|
|
|
1742
1752
|
async renderPasswordlessVariant() {
|
|
1743
|
-
var _configs$widgetConfig, _configs$widgetConfig2;
|
|
1753
|
+
var _configs$widgetConfig, _configs$widgetConfig2, _configs$widgetConfig3;
|
|
1744
1754
|
|
|
1745
1755
|
var configs = _getAutoConfig();
|
|
1746
1756
|
|
|
@@ -1748,7 +1758,8 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1748
1758
|
|
|
1749
1759
|
return await this.widgetApi.render({
|
|
1750
1760
|
engagementMedium: (configs == null ? void 0 : (_configs$widgetConfig = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig.engagementMedium) || this.type,
|
|
1751
|
-
widgetType: (configs == null ? void 0 : (_configs$widgetConfig2 = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig2.widgetType) || this.widgetType
|
|
1761
|
+
widgetType: (configs == null ? void 0 : (_configs$widgetConfig2 = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig2.widgetType) || this.widgetType,
|
|
1762
|
+
locale: (configs == null ? void 0 : (_configs$widgetConfig3 = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig3.locale) || this.locale
|
|
1752
1763
|
}).then(res => this._setWidget(res.template, {
|
|
1753
1764
|
type: "passwordless"
|
|
1754
1765
|
})).catch(this.setErrorWidget);
|
|
@@ -1773,6 +1784,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1773
1784
|
async getWidgetInstance() {
|
|
1774
1785
|
var widgetInstance;
|
|
1775
1786
|
this.widgetType = this.getAttribute("widget") || undefined;
|
|
1787
|
+
this.locale = this.getAttribute("locale") || this.locale;
|
|
1776
1788
|
if (!this.widgetType) throw new Error("No widget has been specified");
|
|
1777
1789
|
|
|
1778
1790
|
if (!this.token) {
|
|
@@ -1808,22 +1820,22 @@ class DeclarativeEmbedWidget extends DeclarativeWidget {
|
|
|
1808
1820
|
}
|
|
1809
1821
|
|
|
1810
1822
|
static get observedAttributes() {
|
|
1811
|
-
return ["widget", "
|
|
1823
|
+
return ["widget", "locale"];
|
|
1812
1824
|
}
|
|
1813
1825
|
|
|
1814
1826
|
attributeChangedCallback(attr, oldVal, newVal) {
|
|
1815
1827
|
if (oldVal === newVal || !oldVal) return; // nothing to do
|
|
1816
1828
|
|
|
1817
1829
|
switch (attr) {
|
|
1830
|
+
case "locale":
|
|
1818
1831
|
case "widget":
|
|
1819
1832
|
this.connectedCallback();
|
|
1820
1833
|
break;
|
|
1821
|
-
// Specific to embed widgets
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
break;
|
|
1834
|
+
// // Specific to embed widgets
|
|
1835
|
+
// case "container":
|
|
1836
|
+
// if (this.widgetInstance._findElement()) this.close();
|
|
1837
|
+
// this.connectedCallback();
|
|
1838
|
+
// break;
|
|
1827
1839
|
}
|
|
1828
1840
|
}
|
|
1829
1841
|
|
|
@@ -1849,7 +1861,7 @@ class DeclarativePopupWidget extends DeclarativeWidget {
|
|
|
1849
1861
|
}
|
|
1850
1862
|
|
|
1851
1863
|
static get observedAttributes() {
|
|
1852
|
-
return ["widget", "id", "open"];
|
|
1864
|
+
return ["widget", "id", "open", "locale"];
|
|
1853
1865
|
}
|
|
1854
1866
|
|
|
1855
1867
|
attributeChangedCallback(attr, oldVal, newVal) {
|
|
@@ -1857,6 +1869,7 @@ class DeclarativePopupWidget extends DeclarativeWidget {
|
|
|
1857
1869
|
|
|
1858
1870
|
switch (attr) {
|
|
1859
1871
|
case "open":
|
|
1872
|
+
case "locale":
|
|
1860
1873
|
case "widget":
|
|
1861
1874
|
this.connectedCallback();
|
|
1862
1875
|
break;
|
|
@@ -1901,7 +1914,7 @@ var _events = null;
|
|
|
1901
1914
|
*/
|
|
1902
1915
|
|
|
1903
1916
|
function api() {
|
|
1904
|
-
if (!_api)
|
|
1917
|
+
if (!_api) init({});
|
|
1905
1918
|
return _api;
|
|
1906
1919
|
}
|
|
1907
1920
|
/**
|
|
@@ -1913,7 +1926,7 @@ function api() {
|
|
|
1913
1926
|
*/
|
|
1914
1927
|
|
|
1915
1928
|
function widgets() {
|
|
1916
|
-
if (!_widgets)
|
|
1929
|
+
if (!_widgets) init({});
|
|
1917
1930
|
return _widgets;
|
|
1918
1931
|
}
|
|
1919
1932
|
/**
|
|
@@ -1925,7 +1938,7 @@ function widgets() {
|
|
|
1925
1938
|
*/
|
|
1926
1939
|
|
|
1927
1940
|
function events() {
|
|
1928
|
-
if (!_events)
|
|
1941
|
+
if (!_events) init({});
|
|
1929
1942
|
return _events;
|
|
1930
1943
|
}
|
|
1931
1944
|
/**
|
|
@@ -1997,7 +2010,7 @@ function init(configIn) {
|
|
|
1997
2010
|
* @example
|
|
1998
2011
|
* squatch.ready(function() {
|
|
1999
2012
|
* console.log("ready!");
|
|
2000
|
-
* squatch.api().upsertUser();
|
|
2013
|
+
* squatch.api().upsertUser({ ... });
|
|
2001
2014
|
* });
|
|
2002
2015
|
*/
|
|
2003
2016
|
|