@saasquatch/squatch-js 2.6.0-1 → 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 +79 -79
- package/dist/squatch.d.ts +1 -16
- package/dist/squatch.esm.js +43 -42
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +42 -42
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +1 -1
- package/dist/widgets/declarative/DeclarativeWidget.d.ts +1 -0
- package/jest.config.ts +1 -3
- 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
|
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
</div>
|
|
62
62
|
</template>
|
|
63
63
|
</div>
|
|
64
|
-
<div class='status-line
|
|
64
|
+
<div class='status-line high'></div>
|
|
65
65
|
<pre><table class="coverage">
|
|
66
66
|
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
67
|
<a name='L2'></a><a href='#L2'>2</a>
|
|
@@ -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>
|
|
@@ -580,15 +580,14 @@
|
|
|
580
580
|
<span class="cline-any cline-neutral"> </span>
|
|
581
581
|
<span class="cline-any cline-neutral"> </span>
|
|
582
582
|
<span class="cline-any cline-neutral"> </span>
|
|
583
|
-
<span class="cline-any cline-yes">
|
|
584
|
-
<span class="cline-any cline-yes">
|
|
583
|
+
<span class="cline-any cline-yes">13x</span>
|
|
584
|
+
<span class="cline-any cline-yes">13x</span>
|
|
585
585
|
<span class="cline-any cline-neutral"> </span>
|
|
586
586
|
<span class="cline-any cline-neutral"> </span>
|
|
587
|
-
<span class="cline-any cline-yes">
|
|
588
|
-
<span class="cline-any cline-yes">
|
|
589
|
-
<span class="cline-any cline-yes">5x</span>
|
|
587
|
+
<span class="cline-any cline-yes">12x</span>
|
|
588
|
+
<span class="cline-any cline-yes">12x</span>
|
|
590
589
|
<span class="cline-any cline-neutral"> </span>
|
|
591
|
-
<span class="cline-any cline-yes">
|
|
590
|
+
<span class="cline-any cline-yes">12x</span>
|
|
592
591
|
<span class="cline-any cline-neutral"> </span>
|
|
593
592
|
<span class="cline-any cline-neutral"> </span>
|
|
594
593
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -597,18 +596,19 @@
|
|
|
597
596
|
<span class="cline-any cline-neutral"> </span>
|
|
598
597
|
<span class="cline-any cline-neutral"> </span>
|
|
599
598
|
<span class="cline-any cline-neutral"> </span>
|
|
600
|
-
<span class="cline-any cline-yes">
|
|
601
|
-
<span class="cline-any cline-
|
|
602
|
-
<span class="cline-any cline-
|
|
603
|
-
<span class="cline-any cline-
|
|
599
|
+
<span class="cline-any cline-yes">12x</span>
|
|
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-
|
|
608
|
-
<span class="cline-any cline-
|
|
609
|
-
<span class="cline-any cline-
|
|
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>
|
|
@@ -616,7 +616,7 @@
|
|
|
616
616
|
<span class="cline-any cline-neutral"> </span>
|
|
617
617
|
<span class="cline-any cline-neutral"> </span>
|
|
618
618
|
<span class="cline-any cline-neutral"> </span>
|
|
619
|
-
<span class="cline-any cline-yes">
|
|
619
|
+
<span class="cline-any cline-yes">12x</span>
|
|
620
620
|
<span class="cline-any cline-no"> </span>
|
|
621
621
|
<span class="cline-any cline-neutral"> </span>
|
|
622
622
|
<span class="cline-any cline-no"> </span>
|
|
@@ -640,26 +640,26 @@
|
|
|
640
640
|
<span class="cline-any cline-neutral"> </span>
|
|
641
641
|
<span class="cline-any cline-neutral"> </span>
|
|
642
642
|
<span class="cline-any cline-neutral"> </span>
|
|
643
|
-
<span class="cline-any cline-yes">
|
|
644
|
-
<span class="cline-any cline-yes">2x</span>
|
|
645
|
-
<span class="cline-any cline-yes">3x</span>
|
|
646
|
-
<span class="cline-any cline-yes">2x</span>
|
|
643
|
+
<span class="cline-any cline-yes">12x</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
|
-
<span class="cline-any cline-yes">
|
|
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>
|
|
@@ -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>
|
|
@@ -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,30 +910,30 @@ export default class Widgets {
|
|
|
910
910
|
|
|
911
911
|
let widget;
|
|
912
912
|
let displayOnLoad = !!config.displayOnLoad;
|
|
913
|
-
|
|
914
|
-
const opts = response.jsOptions || "";
|
|
913
|
+
const opts = response.jsOptions || {};
|
|
915
914
|
|
|
916
915
|
const params = {
|
|
917
916
|
content: response.template,
|
|
918
|
-
type: config.widgetType ||
|
|
917
|
+
type: config.widgetType || opts.widget?.defaultWidgetType,
|
|
919
918
|
api: this.api,
|
|
920
919
|
domain: this.domain,
|
|
921
920
|
npmCdn: this.npmCdn,
|
|
922
921
|
context: context,
|
|
923
922
|
};
|
|
924
923
|
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
924
|
+
if (opts.widgetUrlMappings) {
|
|
925
|
+
opts.widgetUrlMappings.forEach((rule) => {
|
|
926
|
+
if (Widgets._matchesUrl(rule.url)) {
|
|
927
|
+
console.log({ response, rule });
|
|
928
|
+
if (
|
|
929
929
|
rule.widgetType !== "CONVERSION_WIDGET" ||
|
|
930
|
-
|
|
930
|
+
response.user?.referredBy?.code
|
|
931
931
|
) {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
932
|
+
console.log("HERE");
|
|
933
|
+
displayOnLoad = rule.displayOnLoad;
|
|
934
|
+
_log(`Display ${rule.widgetType} on ${rule.url}`);
|
|
935
935
|
} else {
|
|
936
|
-
|
|
936
|
+
_log(
|
|
937
937
|
`Don't display ${rule.widgetType} when no referral on widget rule match ${rule.url}`
|
|
938
938
|
);
|
|
939
939
|
}
|
|
@@ -947,7 +947,7 @@ export default class Widgets {
|
|
|
947
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
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
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
|
|
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();
|
|
@@ -974,7 +974,7 @@ export default class Widgets {
|
|
|
974
974
|
_log("display popup on load");
|
|
975
975
|
widget = new PopupWidget(params);
|
|
976
976
|
widget.load();
|
|
977
|
-
|
|
977
|
+
if (displayOnLoad) widget.open();
|
|
978
978
|
}
|
|
979
979
|
|
|
980
980
|
return widget;
|
|
@@ -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
|
|
|
@@ -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;
|
|
@@ -74,21 +74,6 @@ export declare function ready(fn: () => any): void;
|
|
|
74
74
|
* @returns {void}
|
|
75
75
|
*/
|
|
76
76
|
export declare function autofill(selector: string): void;
|
|
77
|
-
/**
|
|
78
|
-
* Overrides the default function that submits the user email. If you have
|
|
79
|
-
* Security enabled, the email needs to be signed before it's submitted.
|
|
80
|
-
*
|
|
81
|
-
* @param {function} fn Callback function for the 'submit_email' event.
|
|
82
|
-
* @returns {void}
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* squatch.submitEmail(function(target, widget, email) {
|
|
86
|
-
* // Sign email and generate jwt token
|
|
87
|
-
* var jwt = 'token';
|
|
88
|
-
* widget.reload(email, jwt);
|
|
89
|
-
* });
|
|
90
|
-
*/
|
|
91
|
-
export declare function submitEmail(fn: (target: any, widget: any, email: any) => any): void;
|
|
92
77
|
/**
|
|
93
78
|
* Manually set the _saasquatch cookie as a 1st party cookie if available as a URL parameter on the current page.
|
|
94
79
|
* This runs automatically immediately when squatch-js is loaded, except when window.SaaSquatchDoNotAutoDrop is true.
|
package/dist/squatch.esm.js
CHANGED
|
@@ -678,6 +678,7 @@ class Widget {
|
|
|
678
678
|
function delay(duration) {
|
|
679
679
|
return new Promise(function (resolve, reject) {
|
|
680
680
|
setTimeout(function () {
|
|
681
|
+
/* istanbul ignore next */
|
|
681
682
|
resolve(() => {});
|
|
682
683
|
}, duration);
|
|
683
684
|
});
|
|
@@ -1109,7 +1110,7 @@ class Widgets {
|
|
|
1109
1110
|
return {
|
|
1110
1111
|
widget: this._renderWidget(response, clean, {
|
|
1111
1112
|
type: "upsert",
|
|
1112
|
-
user: clean.user
|
|
1113
|
+
user: clean.user,
|
|
1113
1114
|
engagementMedium: config.engagementMedium,
|
|
1114
1115
|
container: config.container,
|
|
1115
1116
|
trigger: config.trigger
|
|
@@ -1221,15 +1222,17 @@ class Widgets {
|
|
|
1221
1222
|
|
|
1222
1223
|
|
|
1223
1224
|
_renderWidget(response, config, context) {
|
|
1225
|
+
var _opts$widget;
|
|
1226
|
+
|
|
1224
1227
|
_log$4("Rendering Widget...");
|
|
1225
1228
|
|
|
1226
1229
|
if (!response) throw new Error("Unable to get a response");
|
|
1227
1230
|
var widget;
|
|
1228
1231
|
var displayOnLoad = !!config.displayOnLoad;
|
|
1229
|
-
var opts = response.jsOptions ||
|
|
1232
|
+
var opts = response.jsOptions || {};
|
|
1230
1233
|
var params = {
|
|
1231
1234
|
content: response.template,
|
|
1232
|
-
type: config.widgetType || opts.widget.defaultWidgetType,
|
|
1235
|
+
type: config.widgetType || ((_opts$widget = opts.widget) == null ? void 0 : _opts$widget.defaultWidgetType),
|
|
1233
1236
|
api: this.api,
|
|
1234
1237
|
domain: this.domain,
|
|
1235
1238
|
npmCdn: this.npmCdn,
|
|
@@ -1239,7 +1242,15 @@ class Widgets {
|
|
|
1239
1242
|
if (opts.widgetUrlMappings) {
|
|
1240
1243
|
opts.widgetUrlMappings.forEach(rule => {
|
|
1241
1244
|
if (Widgets._matchesUrl(rule.url)) {
|
|
1242
|
-
|
|
1245
|
+
var _response$user, _response$user$referr;
|
|
1246
|
+
|
|
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");
|
|
1243
1254
|
displayOnLoad = rule.displayOnLoad;
|
|
1244
1255
|
|
|
1245
1256
|
_log$4("Display " + rule.widgetType + " on " + rule.url);
|
|
@@ -1260,13 +1271,17 @@ class Widgets {
|
|
|
1260
1271
|
} = _ref;
|
|
1261
1272
|
|
|
1262
1273
|
if (Widgets._matchesUrl(url)) {
|
|
1274
|
+
var _response$user2, _response$user2$refer;
|
|
1275
|
+
|
|
1263
1276
|
_log$4("Fuel Tank URL matches");
|
|
1264
1277
|
|
|
1265
|
-
if (response.user.referredBy &&
|
|
1278
|
+
if ((_response$user2 = response.user) != null && (_response$user2$refer = _response$user2.referredBy) != null && _response$user2$refer.code) {
|
|
1266
1279
|
var formAutofill = document.querySelector(formSelector);
|
|
1267
1280
|
|
|
1268
1281
|
if (formAutofill) {
|
|
1269
|
-
|
|
1282
|
+
var _response$user$referr2;
|
|
1283
|
+
|
|
1284
|
+
formAutofill.value = ((_response$user$referr2 = response.user.referredBy.referredReward) == null ? void 0 : _response$user$referr2.fuelTankCode) || "";
|
|
1270
1285
|
} else {
|
|
1271
1286
|
_log$4(new Error("Element with id/class " + formSelector + " was not found."));
|
|
1272
1287
|
}
|
|
@@ -1276,7 +1291,7 @@ class Widgets {
|
|
|
1276
1291
|
}
|
|
1277
1292
|
|
|
1278
1293
|
if (config.engagementMedium === "EMBED") {
|
|
1279
|
-
this._renderEmbedWidget(params, params.context.container);
|
|
1294
|
+
widget = this._renderEmbedWidget(params, params.context.container);
|
|
1280
1295
|
} else if (config.engagementMedium === "POPUP") {
|
|
1281
1296
|
widget = this._renderPopupWidget(params);
|
|
1282
1297
|
if (displayOnLoad) widget.open();
|
|
@@ -1298,7 +1313,7 @@ class Widgets {
|
|
|
1298
1313
|
}
|
|
1299
1314
|
|
|
1300
1315
|
_renderEmbedWidget(params, container) {
|
|
1301
|
-
var widget = new EmbedWidget(params);
|
|
1316
|
+
var widget = new EmbedWidget(params, container);
|
|
1302
1317
|
widget.load();
|
|
1303
1318
|
return widget;
|
|
1304
1319
|
}
|
|
@@ -1655,6 +1670,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1655
1670
|
this.token = void 0;
|
|
1656
1671
|
this.tenant = void 0;
|
|
1657
1672
|
this.widgetType = void 0;
|
|
1673
|
+
this.locale = void 0;
|
|
1658
1674
|
this.widgetApi = void 0;
|
|
1659
1675
|
this.analyticsApi = void 0;
|
|
1660
1676
|
this.type = void 0;
|
|
@@ -1717,6 +1733,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1717
1733
|
this.token = window.squatchToken;
|
|
1718
1734
|
this.tenant = window.squatchTenant;
|
|
1719
1735
|
this.container = this;
|
|
1736
|
+
this.locale = validateLocale(navigator.language.replace(/\-/g, "_"));
|
|
1720
1737
|
}
|
|
1721
1738
|
|
|
1722
1739
|
_setupApis(config) {
|
|
@@ -1733,7 +1750,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1733
1750
|
}
|
|
1734
1751
|
|
|
1735
1752
|
async renderPasswordlessVariant() {
|
|
1736
|
-
var _configs$widgetConfig, _configs$widgetConfig2;
|
|
1753
|
+
var _configs$widgetConfig, _configs$widgetConfig2, _configs$widgetConfig3;
|
|
1737
1754
|
|
|
1738
1755
|
var configs = _getAutoConfig();
|
|
1739
1756
|
|
|
@@ -1741,7 +1758,8 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1741
1758
|
|
|
1742
1759
|
return await this.widgetApi.render({
|
|
1743
1760
|
engagementMedium: (configs == null ? void 0 : (_configs$widgetConfig = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig.engagementMedium) || this.type,
|
|
1744
|
-
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
|
|
1745
1763
|
}).then(res => this._setWidget(res.template, {
|
|
1746
1764
|
type: "passwordless"
|
|
1747
1765
|
})).catch(this.setErrorWidget);
|
|
@@ -1766,6 +1784,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1766
1784
|
async getWidgetInstance() {
|
|
1767
1785
|
var widgetInstance;
|
|
1768
1786
|
this.widgetType = this.getAttribute("widget") || undefined;
|
|
1787
|
+
this.locale = this.getAttribute("locale") || this.locale;
|
|
1769
1788
|
if (!this.widgetType) throw new Error("No widget has been specified");
|
|
1770
1789
|
|
|
1771
1790
|
if (!this.token) {
|
|
@@ -1801,22 +1820,22 @@ class DeclarativeEmbedWidget extends DeclarativeWidget {
|
|
|
1801
1820
|
}
|
|
1802
1821
|
|
|
1803
1822
|
static get observedAttributes() {
|
|
1804
|
-
return ["widget", "
|
|
1823
|
+
return ["widget", "locale"];
|
|
1805
1824
|
}
|
|
1806
1825
|
|
|
1807
1826
|
attributeChangedCallback(attr, oldVal, newVal) {
|
|
1808
1827
|
if (oldVal === newVal || !oldVal) return; // nothing to do
|
|
1809
1828
|
|
|
1810
1829
|
switch (attr) {
|
|
1830
|
+
case "locale":
|
|
1811
1831
|
case "widget":
|
|
1812
1832
|
this.connectedCallback();
|
|
1813
1833
|
break;
|
|
1814
|
-
// Specific to embed widgets
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
break;
|
|
1834
|
+
// // Specific to embed widgets
|
|
1835
|
+
// case "container":
|
|
1836
|
+
// if (this.widgetInstance._findElement()) this.close();
|
|
1837
|
+
// this.connectedCallback();
|
|
1838
|
+
// break;
|
|
1820
1839
|
}
|
|
1821
1840
|
}
|
|
1822
1841
|
|
|
@@ -1842,7 +1861,7 @@ class DeclarativePopupWidget extends DeclarativeWidget {
|
|
|
1842
1861
|
}
|
|
1843
1862
|
|
|
1844
1863
|
static get observedAttributes() {
|
|
1845
|
-
return ["widget", "id", "open"];
|
|
1864
|
+
return ["widget", "id", "open", "locale"];
|
|
1846
1865
|
}
|
|
1847
1866
|
|
|
1848
1867
|
attributeChangedCallback(attr, oldVal, newVal) {
|
|
@@ -1850,6 +1869,7 @@ class DeclarativePopupWidget extends DeclarativeWidget {
|
|
|
1850
1869
|
|
|
1851
1870
|
switch (attr) {
|
|
1852
1871
|
case "open":
|
|
1872
|
+
case "locale":
|
|
1853
1873
|
case "widget":
|
|
1854
1874
|
this.connectedCallback();
|
|
1855
1875
|
break;
|
|
@@ -1894,7 +1914,7 @@ var _events = null;
|
|
|
1894
1914
|
*/
|
|
1895
1915
|
|
|
1896
1916
|
function api() {
|
|
1897
|
-
if (!_api)
|
|
1917
|
+
if (!_api) init({});
|
|
1898
1918
|
return _api;
|
|
1899
1919
|
}
|
|
1900
1920
|
/**
|
|
@@ -1906,7 +1926,7 @@ function api() {
|
|
|
1906
1926
|
*/
|
|
1907
1927
|
|
|
1908
1928
|
function widgets() {
|
|
1909
|
-
if (!_widgets)
|
|
1929
|
+
if (!_widgets) init({});
|
|
1910
1930
|
return _widgets;
|
|
1911
1931
|
}
|
|
1912
1932
|
/**
|
|
@@ -1918,7 +1938,7 @@ function widgets() {
|
|
|
1918
1938
|
*/
|
|
1919
1939
|
|
|
1920
1940
|
function events() {
|
|
1921
|
-
if (!_events)
|
|
1941
|
+
if (!_events) init({});
|
|
1922
1942
|
return _events;
|
|
1923
1943
|
}
|
|
1924
1944
|
/**
|
|
@@ -1990,7 +2010,7 @@ function init(configIn) {
|
|
|
1990
2010
|
* @example
|
|
1991
2011
|
* squatch.ready(function() {
|
|
1992
2012
|
* console.log("ready!");
|
|
1993
|
-
* squatch.api().upsertUser();
|
|
2013
|
+
* squatch.api().upsertUser({ ... });
|
|
1994
2014
|
* });
|
|
1995
2015
|
*/
|
|
1996
2016
|
|
|
@@ -2009,25 +2029,6 @@ function autofill(selector) {
|
|
|
2009
2029
|
// @ts-ignore -- will throw occasionally throw a null pointer exception at runtime
|
|
2010
2030
|
widgets().autofill(selector);
|
|
2011
2031
|
}
|
|
2012
|
-
/**
|
|
2013
|
-
* Overrides the default function that submits the user email. If you have
|
|
2014
|
-
* Security enabled, the email needs to be signed before it's submitted.
|
|
2015
|
-
*
|
|
2016
|
-
* @param {function} fn Callback function for the 'submit_email' event.
|
|
2017
|
-
* @returns {void}
|
|
2018
|
-
*
|
|
2019
|
-
* @example
|
|
2020
|
-
* squatch.submitEmail(function(target, widget, email) {
|
|
2021
|
-
* // Sign email and generate jwt token
|
|
2022
|
-
* var jwt = 'token';
|
|
2023
|
-
* widget.reload(email, jwt);
|
|
2024
|
-
* });
|
|
2025
|
-
*/
|
|
2026
|
-
|
|
2027
|
-
function submitEmail(fn) {
|
|
2028
|
-
// @ts-ignore -- will throw occasionally throw a null pointer exception at runtime
|
|
2029
|
-
widgets().submitEmail(fn);
|
|
2030
|
-
}
|
|
2031
2032
|
/**
|
|
2032
2033
|
* Manually set the _saasquatch cookie as a 1st party cookie if available as a URL parameter on the current page.
|
|
2033
2034
|
* This runs automatically immediately when squatch-js is loaded, except when window.SaaSquatchDoNotAutoDrop is true.
|
|
@@ -2052,5 +2053,5 @@ if (typeof document !== "undefined" && !window.SaaSquatchDoNotAutoDrop) {
|
|
|
2052
2053
|
|
|
2053
2054
|
if (typeof document !== "undefined") asyncLoad();
|
|
2054
2055
|
|
|
2055
|
-
export { DeclarativeEmbedWidget, DeclarativePopupWidget, EmbedWidget, PopupWidget, WidgetApi, Widgets, _auto, api, autofill, events, help, init, pushCookie, ready,
|
|
2056
|
+
export { DeclarativeEmbedWidget, DeclarativePopupWidget, EmbedWidget, PopupWidget, WidgetApi, Widgets, _auto, api, autofill, events, help, init, pushCookie, ready, widget, widgets };
|
|
2056
2057
|
//# sourceMappingURL=squatch.esm.js.map
|