@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
package/dist/squatch.js
CHANGED
|
@@ -1115,7 +1115,7 @@ class Widgets {
|
|
|
1115
1115
|
return {
|
|
1116
1116
|
widget: this._renderWidget(response, clean, {
|
|
1117
1117
|
type: "upsert",
|
|
1118
|
-
user: clean.user
|
|
1118
|
+
user: clean.user,
|
|
1119
1119
|
engagementMedium: config.engagementMedium,
|
|
1120
1120
|
container: config.container,
|
|
1121
1121
|
trigger: config.trigger
|
|
@@ -1247,9 +1247,15 @@ class Widgets {
|
|
|
1247
1247
|
if (opts.widgetUrlMappings) {
|
|
1248
1248
|
opts.widgetUrlMappings.forEach(rule => {
|
|
1249
1249
|
if (Widgets._matchesUrl(rule.url)) {
|
|
1250
|
-
var _response$user, _response$
|
|
1250
|
+
var _response$user, _response$user$referr;
|
|
1251
1251
|
|
|
1252
|
-
|
|
1252
|
+
console.log({
|
|
1253
|
+
response,
|
|
1254
|
+
rule
|
|
1255
|
+
});
|
|
1256
|
+
|
|
1257
|
+
if (rule.widgetType !== "CONVERSION_WIDGET" || (_response$user = response.user) != null && (_response$user$referr = _response$user.referredBy) != null && _response$user$referr.code) {
|
|
1258
|
+
console.log("HERE");
|
|
1253
1259
|
displayOnLoad = rule.displayOnLoad;
|
|
1254
1260
|
|
|
1255
1261
|
_log$4("Display " + rule.widgetType + " on " + rule.url);
|
|
@@ -1270,15 +1276,17 @@ class Widgets {
|
|
|
1270
1276
|
} = _ref;
|
|
1271
1277
|
|
|
1272
1278
|
if (Widgets._matchesUrl(url)) {
|
|
1273
|
-
var _response$
|
|
1279
|
+
var _response$user2, _response$user2$refer;
|
|
1274
1280
|
|
|
1275
1281
|
_log$4("Fuel Tank URL matches");
|
|
1276
1282
|
|
|
1277
|
-
if ((_response$
|
|
1283
|
+
if ((_response$user2 = response.user) != null && (_response$user2$refer = _response$user2.referredBy) != null && _response$user2$refer.code) {
|
|
1278
1284
|
var formAutofill = document.querySelector(formSelector);
|
|
1279
1285
|
|
|
1280
1286
|
if (formAutofill) {
|
|
1281
|
-
|
|
1287
|
+
var _response$user$referr2;
|
|
1288
|
+
|
|
1289
|
+
formAutofill.value = ((_response$user$referr2 = response.user.referredBy.referredReward) == null ? void 0 : _response$user$referr2.fuelTankCode) || "";
|
|
1282
1290
|
} else {
|
|
1283
1291
|
_log$4(new Error("Element with id/class " + formSelector + " was not found."));
|
|
1284
1292
|
}
|
|
@@ -1310,7 +1318,7 @@ class Widgets {
|
|
|
1310
1318
|
}
|
|
1311
1319
|
|
|
1312
1320
|
_renderEmbedWidget(params, container) {
|
|
1313
|
-
var widget = new EmbedWidget(params);
|
|
1321
|
+
var widget = new EmbedWidget(params, container);
|
|
1314
1322
|
widget.load();
|
|
1315
1323
|
return widget;
|
|
1316
1324
|
}
|
|
@@ -1667,6 +1675,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1667
1675
|
this.token = void 0;
|
|
1668
1676
|
this.tenant = void 0;
|
|
1669
1677
|
this.widgetType = void 0;
|
|
1678
|
+
this.locale = void 0;
|
|
1670
1679
|
this.widgetApi = void 0;
|
|
1671
1680
|
this.analyticsApi = void 0;
|
|
1672
1681
|
this.type = void 0;
|
|
@@ -1729,6 +1738,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1729
1738
|
this.token = window.squatchToken;
|
|
1730
1739
|
this.tenant = window.squatchTenant;
|
|
1731
1740
|
this.container = this;
|
|
1741
|
+
this.locale = validateLocale(navigator.language.replace(/\-/g, "_"));
|
|
1732
1742
|
}
|
|
1733
1743
|
|
|
1734
1744
|
_setupApis(config) {
|
|
@@ -1745,7 +1755,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1745
1755
|
}
|
|
1746
1756
|
|
|
1747
1757
|
async renderPasswordlessVariant() {
|
|
1748
|
-
var _configs$widgetConfig, _configs$widgetConfig2;
|
|
1758
|
+
var _configs$widgetConfig, _configs$widgetConfig2, _configs$widgetConfig3;
|
|
1749
1759
|
|
|
1750
1760
|
var configs = _getAutoConfig();
|
|
1751
1761
|
|
|
@@ -1753,7 +1763,8 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1753
1763
|
|
|
1754
1764
|
return await this.widgetApi.render({
|
|
1755
1765
|
engagementMedium: (configs == null ? void 0 : (_configs$widgetConfig = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig.engagementMedium) || this.type,
|
|
1756
|
-
widgetType: (configs == null ? void 0 : (_configs$widgetConfig2 = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig2.widgetType) || this.widgetType
|
|
1766
|
+
widgetType: (configs == null ? void 0 : (_configs$widgetConfig2 = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig2.widgetType) || this.widgetType,
|
|
1767
|
+
locale: (configs == null ? void 0 : (_configs$widgetConfig3 = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig3.locale) || this.locale
|
|
1757
1768
|
}).then(res => this._setWidget(res.template, {
|
|
1758
1769
|
type: "passwordless"
|
|
1759
1770
|
})).catch(this.setErrorWidget);
|
|
@@ -1778,6 +1789,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1778
1789
|
async getWidgetInstance() {
|
|
1779
1790
|
var widgetInstance;
|
|
1780
1791
|
this.widgetType = this.getAttribute("widget") || undefined;
|
|
1792
|
+
this.locale = this.getAttribute("locale") || this.locale;
|
|
1781
1793
|
if (!this.widgetType) throw new Error("No widget has been specified");
|
|
1782
1794
|
|
|
1783
1795
|
if (!this.token) {
|
|
@@ -1813,22 +1825,22 @@ class DeclarativeEmbedWidget extends DeclarativeWidget {
|
|
|
1813
1825
|
}
|
|
1814
1826
|
|
|
1815
1827
|
static get observedAttributes() {
|
|
1816
|
-
return ["widget", "
|
|
1828
|
+
return ["widget", "locale"];
|
|
1817
1829
|
}
|
|
1818
1830
|
|
|
1819
1831
|
attributeChangedCallback(attr, oldVal, newVal) {
|
|
1820
1832
|
if (oldVal === newVal || !oldVal) return; // nothing to do
|
|
1821
1833
|
|
|
1822
1834
|
switch (attr) {
|
|
1835
|
+
case "locale":
|
|
1823
1836
|
case "widget":
|
|
1824
1837
|
this.connectedCallback();
|
|
1825
1838
|
break;
|
|
1826
|
-
// Specific to embed widgets
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
break;
|
|
1839
|
+
// // Specific to embed widgets
|
|
1840
|
+
// case "container":
|
|
1841
|
+
// if (this.widgetInstance._findElement()) this.close();
|
|
1842
|
+
// this.connectedCallback();
|
|
1843
|
+
// break;
|
|
1832
1844
|
}
|
|
1833
1845
|
}
|
|
1834
1846
|
|
|
@@ -1854,7 +1866,7 @@ class DeclarativePopupWidget extends DeclarativeWidget {
|
|
|
1854
1866
|
}
|
|
1855
1867
|
|
|
1856
1868
|
static get observedAttributes() {
|
|
1857
|
-
return ["widget", "id", "open"];
|
|
1869
|
+
return ["widget", "id", "open", "locale"];
|
|
1858
1870
|
}
|
|
1859
1871
|
|
|
1860
1872
|
attributeChangedCallback(attr, oldVal, newVal) {
|
|
@@ -1862,6 +1874,7 @@ class DeclarativePopupWidget extends DeclarativeWidget {
|
|
|
1862
1874
|
|
|
1863
1875
|
switch (attr) {
|
|
1864
1876
|
case "open":
|
|
1877
|
+
case "locale":
|
|
1865
1878
|
case "widget":
|
|
1866
1879
|
this.connectedCallback();
|
|
1867
1880
|
break;
|
|
@@ -1906,7 +1919,7 @@ var _events = null;
|
|
|
1906
1919
|
*/
|
|
1907
1920
|
|
|
1908
1921
|
function api() {
|
|
1909
|
-
if (!_api)
|
|
1922
|
+
if (!_api) init({});
|
|
1910
1923
|
return _api;
|
|
1911
1924
|
}
|
|
1912
1925
|
/**
|
|
@@ -1918,7 +1931,7 @@ function api() {
|
|
|
1918
1931
|
*/
|
|
1919
1932
|
|
|
1920
1933
|
function widgets() {
|
|
1921
|
-
if (!_widgets)
|
|
1934
|
+
if (!_widgets) init({});
|
|
1922
1935
|
return _widgets;
|
|
1923
1936
|
}
|
|
1924
1937
|
/**
|
|
@@ -1930,7 +1943,7 @@ function widgets() {
|
|
|
1930
1943
|
*/
|
|
1931
1944
|
|
|
1932
1945
|
function events() {
|
|
1933
|
-
if (!_events)
|
|
1946
|
+
if (!_events) init({});
|
|
1934
1947
|
return _events;
|
|
1935
1948
|
}
|
|
1936
1949
|
/**
|
|
@@ -2002,7 +2015,7 @@ function init(configIn) {
|
|
|
2002
2015
|
* @example
|
|
2003
2016
|
* squatch.ready(function() {
|
|
2004
2017
|
* console.log("ready!");
|
|
2005
|
-
* squatch.api().upsertUser();
|
|
2018
|
+
* squatch.api().upsertUser({ ... });
|
|
2006
2019
|
* });
|
|
2007
2020
|
*/
|
|
2008
2021
|
|