@saasquatch/squatch-js 2.8.3-4 → 2.8.3-5
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/dist/squatch.cjs.js +1 -1
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +44 -30
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +5 -5
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +1 -1
- package/package.json +1 -1
package/dist/squatch.esm.js
CHANGED
|
@@ -282,8 +282,8 @@ class Z {
|
|
|
282
282
|
widgetType: i,
|
|
283
283
|
engagementMedium: s,
|
|
284
284
|
locale: a
|
|
285
|
-
}),
|
|
286
|
-
return w && (d.cookies = w), qe(
|
|
285
|
+
}), m = `/api/v1/${c}/widget/account/${h}/user/${u}/upsert${p}`, g = this.domain + m, w = (M || window.Cookies).get("_saasquatch");
|
|
286
|
+
return w && (d.cookies = w), qe(g, JSON.stringify(d), r);
|
|
287
287
|
}
|
|
288
288
|
/**
|
|
289
289
|
* Requests widget template
|
|
@@ -299,12 +299,12 @@ class Z {
|
|
|
299
299
|
* @return {Promise} template html if true.
|
|
300
300
|
*/
|
|
301
301
|
render(t) {
|
|
302
|
-
const n = he(t), { widgetType: i, engagementMedium: s = "POPUP", jwt: r, user: a } = n, d = encodeURIComponent(this.tenantAlias), c = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = n.locale ?? Ue(navigator.language.replace(/\-/g, "_")), p = `/api/v1/${d}/graphql`,
|
|
303
|
-
return new Promise(async (
|
|
302
|
+
const n = he(t), { widgetType: i, engagementMedium: s = "POPUP", jwt: r, user: a } = n, d = encodeURIComponent(this.tenantAlias), c = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = n.locale ?? Ue(navigator.language.replace(/\-/g, "_")), p = `/api/v1/${d}/graphql`, m = this.domain + p;
|
|
303
|
+
return new Promise(async (g, w) => {
|
|
304
304
|
var b;
|
|
305
305
|
try {
|
|
306
306
|
const f = await We(
|
|
307
|
-
|
|
307
|
+
m,
|
|
308
308
|
Se,
|
|
309
309
|
{
|
|
310
310
|
user: h && c ? { id: h, accountId: c } : null,
|
|
@@ -314,7 +314,7 @@ class Z {
|
|
|
314
314
|
},
|
|
315
315
|
r
|
|
316
316
|
);
|
|
317
|
-
|
|
317
|
+
g((b = f == null ? void 0 : f.data) == null ? void 0 : b.renderWidget);
|
|
318
318
|
} catch (f) {
|
|
319
319
|
w(f);
|
|
320
320
|
}
|
|
@@ -653,7 +653,7 @@ const pe = ({
|
|
|
653
653
|
__proto__: null,
|
|
654
654
|
getSkeleton: pe
|
|
655
655
|
}, Symbol.toStringTag, { value: "Module" })), y = k("squatch-js:widget");
|
|
656
|
-
class
|
|
656
|
+
class ge {
|
|
657
657
|
constructor(t) {
|
|
658
658
|
l(this, "type");
|
|
659
659
|
l(this, "content");
|
|
@@ -905,7 +905,7 @@ function Oe() {
|
|
|
905
905
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : setTimeout(e, 0);
|
|
906
906
|
}
|
|
907
907
|
const x = k("squatch-js:EMBEDwidget");
|
|
908
|
-
class O extends
|
|
908
|
+
class O extends ge {
|
|
909
909
|
constructor(e, n) {
|
|
910
910
|
super(e);
|
|
911
911
|
l(this, "show", this.open);
|
|
@@ -913,8 +913,8 @@ class O extends me {
|
|
|
913
913
|
n && (this.container = n);
|
|
914
914
|
}
|
|
915
915
|
async load() {
|
|
916
|
-
var
|
|
917
|
-
const e = (w = (
|
|
916
|
+
var g, w, b, f, _, te, ne, ie, oe;
|
|
917
|
+
const e = (w = (g = this.context.widgetConfig) == null ? void 0 : g.values) == null ? void 0 : w.brandingConfig, n = (b = this.content) == null ? void 0 : b.includes("mint-components"), i = (e == null ? void 0 : e.loadingHeight) || 500, s = (f = e == null ? void 0 : e.widgetSize) == null ? void 0 : f.embeddedWidgets, r = s != null && s.maxWidth ? L(s.maxWidth) : "", a = s != null && s.minWidth ? L(s.minWidth) : "", d = this._createFrame({
|
|
918
918
|
minWidth: a,
|
|
919
919
|
maxWidth: r,
|
|
920
920
|
initialHeight: i
|
|
@@ -925,10 +925,10 @@ class O extends me {
|
|
|
925
925
|
throw new Error("Frame needs a content window");
|
|
926
926
|
const u = h.document;
|
|
927
927
|
u.open();
|
|
928
|
-
const
|
|
928
|
+
const m = this.widgetApi.domain === "https://staging.referralsaasquatch.com" ? "-staging" : "";
|
|
929
929
|
u.write(`
|
|
930
930
|
${(ne = e == null ? void 0 : e.main) != null && ne.brandFont ? `
|
|
931
|
-
<link rel="preconnect" href="https://fast${
|
|
931
|
+
<link rel="preconnect" href="https://fast${m}.ssqt.io">
|
|
932
932
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
933
933
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
934
934
|
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
@@ -989,7 +989,7 @@ class O extends me {
|
|
|
989
989
|
}
|
|
990
990
|
const T = k("squatch-js:POPUPwidget");
|
|
991
991
|
let R = 0;
|
|
992
|
-
class D extends
|
|
992
|
+
class D extends ge {
|
|
993
993
|
constructor(e, n = ".squatchpop") {
|
|
994
994
|
super(e);
|
|
995
995
|
l(this, "trigger");
|
|
@@ -1026,8 +1026,8 @@ class D extends me {
|
|
|
1026
1026
|
return n.addEventListener("click", a), n;
|
|
1027
1027
|
}
|
|
1028
1028
|
async load() {
|
|
1029
|
-
var p,
|
|
1030
|
-
const e = (
|
|
1029
|
+
var p, m, g, w, b, f, _;
|
|
1030
|
+
const e = (m = (p = this.context.widgetConfig) == null ? void 0 : p.values) == null ? void 0 : m.brandingConfig, n = (e == null ? void 0 : e.loadingHeight) || 500, i = (g = this.content) == null ? void 0 : g.includes("mint-components"), s = this._createFrame();
|
|
1031
1031
|
s.style.height = n + "px", this._initialiseCTA();
|
|
1032
1032
|
const r = this.container ? this._findElement() : document.body, a = (r == null ? void 0 : r.shadowRoot) || r, d = this._createPopupDialog(e);
|
|
1033
1033
|
d.appendChild(s), ((w = a.lastChild) == null ? void 0 : w.nodeName) === "DIALOG" ? a.replaceChild(d, a.lastChild) : a.appendChild(d);
|
|
@@ -1176,7 +1176,13 @@ class j {
|
|
|
1176
1176
|
user: i.user
|
|
1177
1177
|
};
|
|
1178
1178
|
} catch (i) {
|
|
1179
|
-
throw console.log("[DEBUG] Widgets.upsertUser catch - err:", i), console.log("[DEBUG] Widgets.upsertUser catch - typeof err:", typeof i), console.log(
|
|
1179
|
+
throw console.log("[DEBUG] Widgets.upsertUser catch - err:", i), console.log("[DEBUG] Widgets.upsertUser catch - typeof err:", typeof i), console.log(
|
|
1180
|
+
"[DEBUG] Widgets.upsertUser catch - err.apiErrorCode:",
|
|
1181
|
+
i.apiErrorCode
|
|
1182
|
+
), console.log(
|
|
1183
|
+
"[DEBUG] Widgets.upsertUser catch - err keys:",
|
|
1184
|
+
Object.keys(i || {})
|
|
1185
|
+
), v(i), i.apiErrorCode && (console.log("[DEBUG] Widgets.upsertUser - calling _renderErrorWidget"), this._renderErrorWidget(i, t.engagementMedium)), new Error(i);
|
|
1180
1186
|
}
|
|
1181
1187
|
}
|
|
1182
1188
|
/**
|
|
@@ -1270,10 +1276,10 @@ class j {
|
|
|
1270
1276
|
`Don't display ${c.widgetType} when no referral on widget rule match ${c.url}`
|
|
1271
1277
|
));
|
|
1272
1278
|
}), r.fuelTankAutofillUrls && (v("We found a fuel tank autofill!"), r.fuelTankAutofillUrls.forEach(({ url: c, formSelector: h }) => {
|
|
1273
|
-
var u, p,
|
|
1279
|
+
var u, p, m;
|
|
1274
1280
|
if (j._matchesUrl(c) && (v("Fuel Tank URL matches"), (p = (u = t.user) == null ? void 0 : u.referredBy) != null && p.code)) {
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1281
|
+
const g = document.querySelector(h);
|
|
1282
|
+
g ? g.value = ((m = t.user.referredBy.referredReward) == null ? void 0 : m.fuelTankCode) || "" : v(
|
|
1277
1283
|
new Error(
|
|
1278
1284
|
`Element with id/class ${h} was not found.`
|
|
1279
1285
|
)
|
|
@@ -1376,9 +1382,9 @@ function Fe() {
|
|
|
1376
1382
|
window[S] && (window[z] = window[S], n.forEach((s) => s()), window[S]._auto(), window["_" + o] = void 0, delete window["_" + o]);
|
|
1377
1383
|
}, 0);
|
|
1378
1384
|
}
|
|
1379
|
-
const E = k("squatch-js"), re = (o) => typeof o == "object" && !Array.isArray(o),
|
|
1385
|
+
const E = k("squatch-js"), re = (o) => typeof o == "object" && !Array.isArray(o), me = (o, t) => {
|
|
1380
1386
|
const e = (i) => re(t[i]) && o.hasOwnProperty(i) && re(o[i]), n = Object.getOwnPropertyNames(t).map((i) => ({
|
|
1381
|
-
[i]: e(i) ?
|
|
1387
|
+
[i]: e(i) ? me(o[i], t[i]) : t[i]
|
|
1382
1388
|
})).reduce((i, s) => ({ ...i, ...s }), {});
|
|
1383
1389
|
return {
|
|
1384
1390
|
...o,
|
|
@@ -1422,7 +1428,7 @@ function Be() {
|
|
|
1422
1428
|
try {
|
|
1423
1429
|
const r = He();
|
|
1424
1430
|
if (E("domain retrieved:", r), i) {
|
|
1425
|
-
const a =
|
|
1431
|
+
const a = me(i, n);
|
|
1426
1432
|
s = ae(JSON.stringify(a)), E("cookie to store:", a);
|
|
1427
1433
|
} else
|
|
1428
1434
|
s = ae(JSON.stringify(n)), E("cookie to store:", n);
|
|
@@ -1626,17 +1632,25 @@ class fe extends HTMLElement {
|
|
|
1626
1632
|
async renderUserUpsertVariant() {
|
|
1627
1633
|
this._setupApis();
|
|
1628
1634
|
const e = ze(this.token);
|
|
1629
|
-
|
|
1630
|
-
user
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1635
|
+
if (!e)
|
|
1636
|
+
return this.setErrorWidget(Error("No user object in token."));
|
|
1637
|
+
de("Rendering as a Verified widget");
|
|
1638
|
+
try {
|
|
1639
|
+
await this.widgetApi.upsertUser({
|
|
1640
|
+
user: e,
|
|
1641
|
+
locale: this.locale,
|
|
1642
|
+
engagementMedium: this.type,
|
|
1643
|
+
widgetType: this.widgetType,
|
|
1644
|
+
jwt: this.token
|
|
1645
|
+
});
|
|
1646
|
+
} catch (i) {
|
|
1647
|
+
return this.setErrorWidget(i instanceof Error ? i : Error(String(i)));
|
|
1648
|
+
}
|
|
1649
|
+
return await this.widgetApi.render({
|
|
1636
1650
|
locale: this.locale,
|
|
1637
1651
|
engagementMedium: this.type,
|
|
1638
1652
|
widgetType: this.widgetType
|
|
1639
|
-
}).then((i) => this._setWidget(i, { type: "upsert", user: e })).catch(this.setErrorWidget)
|
|
1653
|
+
}).then((i) => this._setWidget(i, { type: "upsert", user: e })).catch(this.setErrorWidget);
|
|
1640
1654
|
}
|
|
1641
1655
|
/**
|
|
1642
1656
|
* Fetches widget content from SaaSquatch and builds a Widget instance to support rendering the widget in the DOM
|