@saasquatch/squatch-js 2.6.0-3 → 2.6.0-4
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/.github/workflows/static.yml +89 -0
- package/coverage/clover.xml +64 -3
- package/coverage/coverage-final.json +2 -1
- package/coverage/lcov-report/DeclarativeWidget.ts.html +610 -0
- package/coverage/lcov-report/Widgets.ts.html +1057 -0
- package/coverage/lcov-report/api/AnalyticsApi.ts.html +46 -46
- package/coverage/lcov-report/api/WidgetApi.ts.html +11 -11
- 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 +1 -1
- package/coverage/lcov-report/widgets/Widgets.ts.html +57 -60
- package/coverage/lcov.info +133 -0
- package/dist/squatch.esm.js +32 -21
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +32 -21
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +1 -1
- package/dist/widgets/EmbedWidget.d.ts +3 -0
- package/dist/widgets/declarative/DeclarativeWidget.d.ts +9 -1
- package/package.json +2 -2
package/dist/squatch.js
CHANGED
|
@@ -238,6 +238,7 @@ class WidgetApi {
|
|
|
238
238
|
widgetType,
|
|
239
239
|
engagementMedium = "POPUP",
|
|
240
240
|
jwt,
|
|
241
|
+
locale,
|
|
241
242
|
user
|
|
242
243
|
} = clean;
|
|
243
244
|
var tenantAlias = encodeURIComponent(this.tenantAlias);
|
|
@@ -246,7 +247,8 @@ class WidgetApi {
|
|
|
246
247
|
|
|
247
248
|
var optionalParams = _buildParams({
|
|
248
249
|
widgetType,
|
|
249
|
-
engagementMedium
|
|
250
|
+
engagementMedium,
|
|
251
|
+
locale
|
|
250
252
|
});
|
|
251
253
|
|
|
252
254
|
var path = "/api/v1/" + tenantAlias + "/widget/account/" + accountId + "/user/" + userId + "/upsert" + optionalParams;
|
|
@@ -331,12 +333,15 @@ class WidgetApi {
|
|
|
331
333
|
function _buildParams(_ref) {
|
|
332
334
|
var {
|
|
333
335
|
widgetType,
|
|
334
|
-
engagementMedium
|
|
336
|
+
engagementMedium,
|
|
337
|
+
locale
|
|
335
338
|
} = _ref;
|
|
336
|
-
var
|
|
337
|
-
var
|
|
338
|
-
var
|
|
339
|
-
|
|
339
|
+
var engagementMediumP = "engagementMedium=" + encodeURIComponent(engagementMedium);
|
|
340
|
+
var widgetTypeP = widgetType && "widgetType=" + encodeURIComponent(widgetType);
|
|
341
|
+
var localeP = locale && "locale=" + encodeURIComponent(locale);
|
|
342
|
+
var params = [engagementMediumP, widgetTypeP, localeP].filter(x => !!x);
|
|
343
|
+
var queryString = "?" + params.join("&");
|
|
344
|
+
return queryString;
|
|
340
345
|
}
|
|
341
346
|
|
|
342
347
|
// @ts-check
|
|
@@ -788,7 +793,10 @@ class EmbedWidget extends Widget {
|
|
|
788
793
|
_log$6("loaded");
|
|
789
794
|
}
|
|
790
795
|
});
|
|
791
|
-
}
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Un-hide if element is available and refresh data
|
|
799
|
+
*/
|
|
792
800
|
|
|
793
801
|
|
|
794
802
|
open() {
|
|
@@ -1249,13 +1257,7 @@ class Widgets {
|
|
|
1249
1257
|
if (Widgets._matchesUrl(rule.url)) {
|
|
1250
1258
|
var _response$user, _response$user$referr;
|
|
1251
1259
|
|
|
1252
|
-
console.log({
|
|
1253
|
-
response,
|
|
1254
|
-
rule
|
|
1255
|
-
});
|
|
1256
|
-
|
|
1257
1260
|
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");
|
|
1259
1261
|
displayOnLoad = rule.displayOnLoad;
|
|
1260
1262
|
|
|
1261
1263
|
_log$4("Display " + rule.widgetType + " on " + rule.url);
|
|
@@ -1373,6 +1375,9 @@ class Widgets {
|
|
|
1373
1375
|
|
|
1374
1376
|
static _matchesUrl(rule) {
|
|
1375
1377
|
// If there were no matches, null is returned.
|
|
1378
|
+
console.log({
|
|
1379
|
+
href: window.location.href
|
|
1380
|
+
});
|
|
1376
1381
|
return window.location.href.match(new RegExp(rule)) ? true : false;
|
|
1377
1382
|
}
|
|
1378
1383
|
|
|
@@ -1682,7 +1687,6 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1682
1687
|
this.widgetInstance = void 0;
|
|
1683
1688
|
this.container = void 0;
|
|
1684
1689
|
this.element = void 0;
|
|
1685
|
-
this._hasChildren = void 0;
|
|
1686
1690
|
|
|
1687
1691
|
this._setWidget = (template, config) => {
|
|
1688
1692
|
var _this$config;
|
|
@@ -1729,6 +1733,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1729
1733
|
}
|
|
1730
1734
|
};
|
|
1731
1735
|
|
|
1736
|
+
this.reload = this.renderWidget;
|
|
1732
1737
|
this.show = this.open;
|
|
1733
1738
|
this.hide = this.close;
|
|
1734
1739
|
this.attachShadow({
|
|
@@ -1777,6 +1782,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1777
1782
|
if (!userObj) throw new Error("Could not load user information from jwt");
|
|
1778
1783
|
var widgetInstance = await this.widgetApi.upsertUser({
|
|
1779
1784
|
user: userObj,
|
|
1785
|
+
locale: this.locale,
|
|
1780
1786
|
engagementMedium: this.type,
|
|
1781
1787
|
widgetType: this.widgetType,
|
|
1782
1788
|
jwt: this.token
|
|
@@ -1808,11 +1814,22 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1808
1814
|
await this.widgetInstance.load();
|
|
1809
1815
|
}
|
|
1810
1816
|
|
|
1817
|
+
/**
|
|
1818
|
+
* Calls `open` method of `widgetInstance`
|
|
1819
|
+
* @throws Throws an Error if called before the widget has loaded
|
|
1820
|
+
*/
|
|
1811
1821
|
open() {
|
|
1822
|
+
if (!this.widgetInstance) throw new Error("Widget has not loaded yet");
|
|
1812
1823
|
this.widgetInstance.open();
|
|
1813
1824
|
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Calls `close` method of `widgetInstance`
|
|
1827
|
+
* @throws Throws an Error if called before the widget has loaded
|
|
1828
|
+
*/
|
|
1829
|
+
|
|
1814
1830
|
|
|
1815
1831
|
close() {
|
|
1832
|
+
if (!this.widgetInstance) throw new Error("Widget has not loaded yet");
|
|
1816
1833
|
this.widgetInstance.close();
|
|
1817
1834
|
}
|
|
1818
1835
|
|
|
@@ -1836,11 +1853,6 @@ class DeclarativeEmbedWidget extends DeclarativeWidget {
|
|
|
1836
1853
|
case "widget":
|
|
1837
1854
|
this.connectedCallback();
|
|
1838
1855
|
break;
|
|
1839
|
-
// // Specific to embed widgets
|
|
1840
|
-
// case "container":
|
|
1841
|
-
// if (this.widgetInstance._findElement()) this.close();
|
|
1842
|
-
// this.connectedCallback();
|
|
1843
|
-
// break;
|
|
1844
1856
|
}
|
|
1845
1857
|
}
|
|
1846
1858
|
|
|
@@ -1866,14 +1878,13 @@ class DeclarativePopupWidget extends DeclarativeWidget {
|
|
|
1866
1878
|
}
|
|
1867
1879
|
|
|
1868
1880
|
static get observedAttributes() {
|
|
1869
|
-
return ["widget", "
|
|
1881
|
+
return ["widget", "locale"];
|
|
1870
1882
|
}
|
|
1871
1883
|
|
|
1872
1884
|
attributeChangedCallback(attr, oldVal, newVal) {
|
|
1873
1885
|
if (oldVal === newVal || !oldVal) return; // nothing to do
|
|
1874
1886
|
|
|
1875
1887
|
switch (attr) {
|
|
1876
|
-
case "open":
|
|
1877
1888
|
case "locale":
|
|
1878
1889
|
case "widget":
|
|
1879
1890
|
this.connectedCallback();
|