@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.
@@ -0,0 +1,133 @@
1
+ TN:
2
+ SF:src/widgets/declarative/DeclarativeWidget.ts
3
+ FN:33,(anonymous_0)
4
+ FN:47,(anonymous_1)
5
+ FN:59,(anonymous_2)
6
+ FN:69,(anonymous_3)
7
+ FN:73,(anonymous_4)
8
+ FN:87,(anonymous_5)
9
+ FN:93,(anonymous_6)
10
+ FN:113,(anonymous_7)
11
+ FN:132,(anonymous_8)
12
+ FN:137,(anonymous_9)
13
+ FN:158,(anonymous_10)
14
+ FN:167,(anonymous_11)
15
+ FNF:12
16
+ FNH:12
17
+ FNDA:56,(anonymous_0)
18
+ FNDA:60,(anonymous_1)
19
+ FNDA:44,(anonymous_2)
20
+ FNDA:41,(anonymous_3)
21
+ FNDA:16,(anonymous_4)
22
+ FNDA:12,(anonymous_5)
23
+ FNDA:53,(anonymous_6)
24
+ FNDA:64,(anonymous_7)
25
+ FNDA:64,(anonymous_8)
26
+ FNDA:4,(anonymous_9)
27
+ FNDA:8,(anonymous_10)
28
+ FNDA:4,(anonymous_11)
29
+ DA:1,3
30
+ DA:2,3
31
+ DA:3,3
32
+ DA:5,3
33
+ DA:6,3
34
+ DA:7,3
35
+ DA:12,3
36
+ DA:13,3
37
+ DA:15,3
38
+ DA:17,3
39
+ DA:34,56
40
+ DA:35,56
41
+ DA:39,56
42
+ DA:40,56
43
+ DA:41,56
44
+ DA:42,56
45
+ DA:44,56
46
+ DA:48,60
47
+ DA:50,57
48
+ DA:54,57
49
+ DA:60,44
50
+ DA:61,44
51
+ DA:63,41
52
+ DA:69,41
53
+ DA:74,16
54
+ DA:76,16
55
+ DA:77,16
56
+ DA:79,16
57
+ DA:87,12
58
+ DA:90,16
59
+ DA:93,56
60
+ DA:97,53
61
+ DA:106,53
62
+ DA:107,28
63
+ DA:109,25
64
+ DA:115,64
65
+ DA:116,64
66
+ DA:118,64
67
+ DA:120,60
68
+ DA:121,44
69
+ DA:123,16
70
+ DA:126,57
71
+ DA:128,57
72
+ DA:129,57
73
+ DA:133,64
74
+ DA:134,57
75
+ DA:137,56
76
+ DA:138,4
77
+ DA:147,4
78
+ DA:148,3
79
+ DA:150,1
80
+ DA:159,8
81
+ DA:160,8
82
+ DA:168,4
83
+ DA:169,4
84
+ DA:172,56
85
+ DA:173,56
86
+ DA:174,56
87
+ LF:58
88
+ LH:58
89
+ BRDA:48,0,0,3
90
+ BRDA:51,1,0,57
91
+ BRDA:51,1,1,48
92
+ BRDA:52,2,0,57
93
+ BRDA:52,2,1,48
94
+ BRDA:52,2,2,0
95
+ BRDA:55,3,0,57
96
+ BRDA:55,3,1,48
97
+ BRDA:55,3,2,0
98
+ BRDA:65,4,0,41
99
+ BRDA:65,4,1,32
100
+ BRDA:66,5,0,41
101
+ BRDA:66,5,1,32
102
+ BRDA:67,6,0,41
103
+ BRDA:67,6,1,41
104
+ BRDA:77,7,0,0
105
+ BRDA:102,8,0,53
106
+ BRDA:102,8,1,0
107
+ BRDA:104,9,0,53
108
+ BRDA:104,9,1,0
109
+ BRDA:106,10,0,28
110
+ BRDA:106,10,1,25
111
+ BRDA:109,11,0,4
112
+ BRDA:109,11,1,21
113
+ BRDA:115,12,0,64
114
+ BRDA:115,12,1,4
115
+ BRDA:116,13,0,64
116
+ BRDA:116,13,1,56
117
+ BRDA:118,14,0,4
118
+ BRDA:120,15,0,44
119
+ BRDA:120,15,1,16
120
+ BRDA:126,16,0,0
121
+ BRDA:143,17,0,4
122
+ BRDA:143,17,1,0
123
+ BRDA:145,18,0,4
124
+ BRDA:145,18,1,0
125
+ BRDA:147,19,0,3
126
+ BRDA:147,19,1,1
127
+ BRDA:150,20,0,0
128
+ BRDA:150,20,1,1
129
+ BRDA:159,21,0,0
130
+ BRDA:168,22,0,0
131
+ BRF:42
132
+ BRH:31
133
+ end_of_record
@@ -233,6 +233,7 @@ class WidgetApi {
233
233
  widgetType,
234
234
  engagementMedium = "POPUP",
235
235
  jwt,
236
+ locale,
236
237
  user
237
238
  } = clean;
238
239
  var tenantAlias = encodeURIComponent(this.tenantAlias);
@@ -241,7 +242,8 @@ class WidgetApi {
241
242
 
242
243
  var optionalParams = _buildParams({
243
244
  widgetType,
244
- engagementMedium
245
+ engagementMedium,
246
+ locale
245
247
  });
246
248
 
247
249
  var path = "/api/v1/" + tenantAlias + "/widget/account/" + accountId + "/user/" + userId + "/upsert" + optionalParams;
@@ -326,12 +328,15 @@ class WidgetApi {
326
328
  function _buildParams(_ref) {
327
329
  var {
328
330
  widgetType,
329
- engagementMedium
331
+ engagementMedium,
332
+ locale
330
333
  } = _ref;
331
- var widgetTypeP = widgetType ? "?widgetType=" + encodeURIComponent(widgetType) : "";
332
- var engagementMediumP = (widgetType ? "&" : "?") + "engagementMedium=" + encodeURIComponent(engagementMedium);
333
- var optionalParams = widgetTypeP + engagementMediumP;
334
- return optionalParams;
334
+ var engagementMediumP = "engagementMedium=" + encodeURIComponent(engagementMedium);
335
+ var widgetTypeP = widgetType && "widgetType=" + encodeURIComponent(widgetType);
336
+ var localeP = locale && "locale=" + encodeURIComponent(locale);
337
+ var params = [engagementMediumP, widgetTypeP, localeP].filter(x => !!x);
338
+ var queryString = "?" + params.join("&");
339
+ return queryString;
335
340
  }
336
341
 
337
342
  // @ts-check
@@ -783,7 +788,10 @@ class EmbedWidget extends Widget {
783
788
  _log$6("loaded");
784
789
  }
785
790
  });
786
- } // Un-hide if element is available and refresh data
791
+ }
792
+ /**
793
+ * Un-hide if element is available and refresh data
794
+ */
787
795
 
788
796
 
789
797
  open() {
@@ -1244,13 +1252,7 @@ class Widgets {
1244
1252
  if (Widgets._matchesUrl(rule.url)) {
1245
1253
  var _response$user, _response$user$referr;
1246
1254
 
1247
- console.log({
1248
- response,
1249
- rule
1250
- });
1251
-
1252
1255
  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");
1254
1256
  displayOnLoad = rule.displayOnLoad;
1255
1257
 
1256
1258
  _log$4("Display " + rule.widgetType + " on " + rule.url);
@@ -1368,6 +1370,9 @@ class Widgets {
1368
1370
 
1369
1371
  static _matchesUrl(rule) {
1370
1372
  // If there were no matches, null is returned.
1373
+ console.log({
1374
+ href: window.location.href
1375
+ });
1371
1376
  return window.location.href.match(new RegExp(rule)) ? true : false;
1372
1377
  }
1373
1378
 
@@ -1677,7 +1682,6 @@ class DeclarativeWidget extends HTMLElement {
1677
1682
  this.widgetInstance = void 0;
1678
1683
  this.container = void 0;
1679
1684
  this.element = void 0;
1680
- this._hasChildren = void 0;
1681
1685
 
1682
1686
  this._setWidget = (template, config) => {
1683
1687
  var _this$config;
@@ -1724,6 +1728,7 @@ class DeclarativeWidget extends HTMLElement {
1724
1728
  }
1725
1729
  };
1726
1730
 
1731
+ this.reload = this.renderWidget;
1727
1732
  this.show = this.open;
1728
1733
  this.hide = this.close;
1729
1734
  this.attachShadow({
@@ -1772,6 +1777,7 @@ class DeclarativeWidget extends HTMLElement {
1772
1777
  if (!userObj) throw new Error("Could not load user information from jwt");
1773
1778
  var widgetInstance = await this.widgetApi.upsertUser({
1774
1779
  user: userObj,
1780
+ locale: this.locale,
1775
1781
  engagementMedium: this.type,
1776
1782
  widgetType: this.widgetType,
1777
1783
  jwt: this.token
@@ -1803,11 +1809,22 @@ class DeclarativeWidget extends HTMLElement {
1803
1809
  await this.widgetInstance.load();
1804
1810
  }
1805
1811
 
1812
+ /**
1813
+ * Calls `open` method of `widgetInstance`
1814
+ * @throws Throws an Error if called before the widget has loaded
1815
+ */
1806
1816
  open() {
1817
+ if (!this.widgetInstance) throw new Error("Widget has not loaded yet");
1807
1818
  this.widgetInstance.open();
1808
1819
  }
1820
+ /**
1821
+ * Calls `close` method of `widgetInstance`
1822
+ * @throws Throws an Error if called before the widget has loaded
1823
+ */
1824
+
1809
1825
 
1810
1826
  close() {
1827
+ if (!this.widgetInstance) throw new Error("Widget has not loaded yet");
1811
1828
  this.widgetInstance.close();
1812
1829
  }
1813
1830
 
@@ -1831,11 +1848,6 @@ class DeclarativeEmbedWidget extends DeclarativeWidget {
1831
1848
  case "widget":
1832
1849
  this.connectedCallback();
1833
1850
  break;
1834
- // // Specific to embed widgets
1835
- // case "container":
1836
- // if (this.widgetInstance._findElement()) this.close();
1837
- // this.connectedCallback();
1838
- // break;
1839
1851
  }
1840
1852
  }
1841
1853
 
@@ -1861,14 +1873,13 @@ class DeclarativePopupWidget extends DeclarativeWidget {
1861
1873
  }
1862
1874
 
1863
1875
  static get observedAttributes() {
1864
- return ["widget", "id", "open", "locale"];
1876
+ return ["widget", "locale"];
1865
1877
  }
1866
1878
 
1867
1879
  attributeChangedCallback(attr, oldVal, newVal) {
1868
1880
  if (oldVal === newVal || !oldVal) return; // nothing to do
1869
1881
 
1870
1882
  switch (attr) {
1871
- case "open":
1872
1883
  case "locale":
1873
1884
  case "widget":
1874
1885
  this.connectedCallback();