@konnectio/core
Version:
Konnectio Core Frontend Integration.
640 lines (639 loc) • 20.1 kB
JavaScript
import { g as V } from "./_commonjsHelpers-DaMA6jEr.js";
var E = { exports: {} }, S = { exports: {} }, j = S.exports, P;
function L() {
return P || (P = 1, (function(e, r) {
(function(o, t) {
e.exports = t();
})(j, function() {
function o(a) {
return !isNaN(parseFloat(a)) && isFinite(a);
}
function t(a) {
return a.charAt(0).toUpperCase() + a.substring(1);
}
function s(a) {
return function() {
return this[a];
};
}
var l = ["isConstructor", "isEval", "isNative", "isToplevel"], p = ["columnNumber", "lineNumber"], f = ["fileName", "functionName", "source"], i = ["args"], m = ["evalOrigin"], n = l.concat(p, f, i, m);
function c(a) {
if (a)
for (var d = 0; d < n.length; d++)
a[n[d]] !== void 0 && this["set" + t(n[d])](a[n[d]]);
}
c.prototype = {
getArgs: function() {
return this.args;
},
setArgs: function(a) {
if (Object.prototype.toString.call(a) !== "[object Array]")
throw new TypeError("Args must be an Array");
this.args = a;
},
getEvalOrigin: function() {
return this.evalOrigin;
},
setEvalOrigin: function(a) {
if (a instanceof c)
this.evalOrigin = a;
else if (a instanceof Object)
this.evalOrigin = new c(a);
else
throw new TypeError("Eval Origin must be an Object or StackFrame");
},
toString: function() {
var a = this.getFileName() || "", d = this.getLineNumber() || "", v = this.getColumnNumber() || "", b = this.getFunctionName() || "";
return this.getIsEval() ? a ? "[eval] (" + a + ":" + d + ":" + v + ")" : "[eval]:" + d + ":" + v : b ? b + " (" + a + ":" + d + ":" + v + ")" : a + ":" + d + ":" + v;
}
}, c.fromString = function(d) {
var v = d.indexOf("("), b = d.lastIndexOf(")"), F = d.substring(0, v), T = d.substring(v + 1, b).split(","), O = d.substring(b + 1);
if (O.indexOf("@") === 0)
var k = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(O, ""), I = k[1], q = k[2], U = k[3];
return new c({
functionName: F,
args: T || void 0,
fileName: I,
lineNumber: q || void 0,
columnNumber: U || void 0
});
};
for (var u = 0; u < l.length; u++)
c.prototype["get" + t(l[u])] = s(l[u]), c.prototype["set" + t(l[u])] = /* @__PURE__ */ (function(a) {
return function(d) {
this[a] = !!d;
};
})(l[u]);
for (var h = 0; h < p.length; h++)
c.prototype["get" + t(p[h])] = s(p[h]), c.prototype["set" + t(p[h])] = /* @__PURE__ */ (function(a) {
return function(d) {
if (!o(d))
throw new TypeError(a + " must be a Number");
this[a] = Number(d);
};
})(p[h]);
for (var g = 0; g < f.length; g++)
c.prototype["get" + t(f[g])] = s(f[g]), c.prototype["set" + t(f[g])] = /* @__PURE__ */ (function(a) {
return function(d) {
this[a] = String(d);
};
})(f[g]);
return c;
});
})(S)), S.exports;
}
var B = E.exports, $;
function M() {
return $ || ($ = 1, (function(e, r) {
(function(o, t) {
e.exports = t(L());
})(B, function(t) {
var s = /(^|@)\S+:\d+/, l = /^\s*at .*(\S+:\d+|\(native\))/m, p = /^(eval@)?(\[native code])?$/;
return {
/**
* Given an Error object, extract the most information from it.
*
* @param {Error} error object
* @return {Array} of StackFrames
*/
parse: function(i) {
if (typeof i.stacktrace < "u" || typeof i["opera#sourceloc"] < "u")
return this.parseOpera(i);
if (i.stack && i.stack.match(l))
return this.parseV8OrIE(i);
if (i.stack)
return this.parseFFOrSafari(i);
throw new Error("Cannot parse given Error object");
},
// Separate line and column numbers from a string of the form: (URI:Line:Column)
extractLocation: function(i) {
if (i.indexOf(":") === -1)
return [i];
var m = /(.+?)(?::(\d+))?(?::(\d+))?$/, n = m.exec(i.replace(/[()]/g, ""));
return [n[1], n[2] || void 0, n[3] || void 0];
},
parseV8OrIE: function(i) {
var m = i.stack.split(`
`).filter(function(n) {
return !!n.match(l);
}, this);
return m.map(function(n) {
n.indexOf("(eval ") > -1 && (n = n.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
var c = n.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), u = c.match(/ (\(.+\)$)/);
c = u ? c.replace(u[0], "") : c;
var h = this.extractLocation(u ? u[1] : c), g = u && c || void 0, a = ["eval", "<anonymous>"].indexOf(h[0]) > -1 ? void 0 : h[0];
return new t({
functionName: g,
fileName: a,
lineNumber: h[1],
columnNumber: h[2],
source: n
});
}, this);
},
parseFFOrSafari: function(i) {
var m = i.stack.split(`
`).filter(function(n) {
return !n.match(p);
}, this);
return m.map(function(n) {
if (n.indexOf(" > eval") > -1 && (n = n.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), n.indexOf("@") === -1 && n.indexOf(":") === -1)
return new t({
functionName: n
});
var c = /((.*".+"[^@]*)?[^@]*)(?:@)/, u = n.match(c), h = u && u[1] ? u[1] : void 0, g = this.extractLocation(n.replace(c, ""));
return new t({
functionName: h,
fileName: g[0],
lineNumber: g[1],
columnNumber: g[2],
source: n
});
}, this);
},
parseOpera: function(i) {
return !i.stacktrace || i.message.indexOf(`
`) > -1 && i.message.split(`
`).length > i.stacktrace.split(`
`).length ? this.parseOpera9(i) : i.stack ? this.parseOpera11(i) : this.parseOpera10(i);
},
parseOpera9: function(i) {
for (var m = /Line (\d+).*script (?:in )?(\S+)/i, n = i.message.split(`
`), c = [], u = 2, h = n.length; u < h; u += 2) {
var g = m.exec(n[u]);
g && c.push(new t({
fileName: g[2],
lineNumber: g[1],
source: n[u]
}));
}
return c;
},
parseOpera10: function(i) {
for (var m = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, n = i.stacktrace.split(`
`), c = [], u = 0, h = n.length; u < h; u += 2) {
var g = m.exec(n[u]);
g && c.push(
new t({
functionName: g[3] || void 0,
fileName: g[2],
lineNumber: g[1],
source: n[u]
})
);
}
return c;
},
// Opera 10.65+ Error.stack very similar to FF/Safari
parseOpera11: function(i) {
var m = i.stack.split(`
`).filter(function(n) {
return !!n.match(s) && !n.match(/^Error created at/);
}, this);
return m.map(function(n) {
var c = n.split("@"), u = this.extractLocation(c.pop()), h = c.shift() || "", g = h.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, a;
h.match(/\(([^)]*)\)/) && (a = h.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
var d = a === void 0 || a === "[arguments not available]" ? void 0 : a.split(",");
return new t({
functionName: g,
args: d,
fileName: u[0],
lineNumber: u[1],
columnNumber: u[2],
source: n
});
}, this);
}
};
});
})(E)), E.exports;
}
var D = M();
const J = /* @__PURE__ */ V(D);
var N = '"1.1.0"', G = "5pqzBljrmDvquWZYSrSUKldIUREtPyB3", H = '"4.4.5"';
function w(e, r, o) {
return o && !e && console.error(`Flare JavaScript client v${N}: ${r}`), !!e;
}
function X(e, r) {
return w(
e,
"The client was not yet initialised with an API key. Run client.light('<flare-project-key>') when you initialise your app. If you are running in dev mode and didn't run the light command on purpose, you can ignore this error.",
r
);
}
function z(e, r) {
return w("canSolve" in e, "A solution provider without a [canSolve] property was added.", r) && w(
"getSolutions" in e,
"A solution provider without a [getSolutions] property was added.",
r
);
}
function K(e) {
let r = [];
const o = JSON.stringify(e, function(t, s) {
if (typeof s == "object" && s !== null) {
if (r.indexOf(s) !== -1)
try {
return JSON.parse(JSON.stringify(s));
} catch {
return;
}
r.push(s);
}
return s;
});
return r = null, o;
}
function W(e) {
return e.reduce((r, o) => r.concat(o), []);
}
function x() {
return Math.round(Date.now() / 1e3);
}
var Y = class {
report(e, r, o, t) {
return fetch(r, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Api-Token": o ?? "",
"X-Requested-With": "XMLHttpRequest",
"X-Report-Browser-Extension-Errors": JSON.stringify(t)
},
body: K({
...e,
key: o
})
}).then(
(s) => {
s.status !== 204 && console.error(`Received response with status ${s.status} from Flare`);
},
(s) => console.error(s)
);
}
};
function Q() {
return window.document.cookie ? {
cookies: window.document.cookie.split("; ").reduce(
(e, r) => {
const [o, t] = r.split(/=/);
return e[o] = t, e;
},
{}
)
} : {};
}
function Z() {
return {
request: {
url: window.document.location.href,
useragent: window.navigator.userAgent,
referrer: window.document.referrer,
readyState: window.document.readyState
}
};
}
function ee() {
if (!window.location.search)
return {};
const e = {};
return new URLSearchParams(window.location.search).forEach((r, o) => {
e[o] = r;
}), { request_data: { queryString: e } };
}
function _(e) {
return typeof window > "u" ? e : {
...Q(),
...Z(),
...ee(),
...e
};
}
function re(e, r, o = {}) {
return new Promise((t) => {
const s = e.reduce(
(l, p) => (l.push(Promise.resolve(p.canSolve(r, o))), l),
[]
);
Promise.all(s).then((l) => {
const p = [];
l.forEach((f, i) => {
f && p.push(
Promise.resolve(e[i].getSolutions(r, o))
);
}), Promise.all(p).then((f) => {
t(W(f));
});
});
});
}
var C = {};
function te(e, r, o) {
return new Promise((t) => {
if (!e || !r)
return t({
codeSnippet: {
0: `Could not read from file: missing file URL or line number. URL: ${e} lineNumber: ${r}`
},
trimmedColumnNumber: null
});
ne(e).then((s) => t(s ? oe(s, r, o) : {
codeSnippet: {
0: `Could not read from file: Error while opening file at URL ${e}`
},
trimmedColumnNumber: null
}));
});
}
function ne(e) {
return C[e] ? Promise.resolve(C[e]) : fetch(e).then((r) => r.status !== 200 ? null : r.text()).catch(() => null);
}
function oe(e, r, o, t = 1e3, s = 40) {
const l = {};
let p = null;
const f = e.split(`
`);
for (let i = -s / 2; i <= s / 2; i++) {
const m = r + i;
if (m >= 0 && f[m]) {
const n = m + 1;
if (f[m].length > t) {
if (o && o + t / 2 > t) {
l[n] = f[m].substr(
o - Math.round(t / 2),
t
), n === r && (p = Math.round(t / 2));
continue;
}
l[n] = f[m].substr(0, t) + "…";
continue;
}
l[n] = f[m];
}
}
return { codeSnippet: l, trimmedColumnNumber: p };
}
function R(e, r) {
return new Promise((o) => {
if (!ie(e))
return w(!1, "Couldn't generate stacktrace of below error:", r), r && console.error(e), o([
{
line_number: 0,
column_number: 0,
method: "unknown",
file: "unknown",
code_snippet: {
0: "Could not read from file: stacktrace missing"
},
trimmed_column_number: null,
class: "unknown"
}
]);
Promise.all(
J.parse(e).map((t) => new Promise((s) => {
te(t.fileName, t.lineNumber, t.columnNumber).then((l) => {
s({
line_number: t.lineNumber || 1,
column_number: t.columnNumber || 1,
method: t.functionName || "Anonymous or unknown function",
file: t.fileName || "Unknown file",
code_snippet: l.codeSnippet,
trimmed_column_number: l.trimmedColumnNumber,
class: ""
});
});
}))
).then(o);
});
}
function ie(e) {
return !!e && (!!e.stack || !!e.stacktrace || !!e["opera#sourceloc"]) && typeof (e.stack || e.stacktrace || e["opera#sourceloc"]) == "string" && e.stack !== `${e.name}: ${e.message}`;
}
var ae = class {
constructor(e = new Y()) {
this.api = e, this.config = {
key: null,
version: N,
sourcemapVersion: H,
stage: "",
maxGlowsPerReport: 30,
reportingUrl: "https://reporting.flareapp.io/api/reports",
reportBrowserExtensionErrors: !1,
debug: !1,
beforeEvaluate: (r) => r,
beforeSubmit: (r) => r
}, this.glows = [], this.context = { context: {} }, this.solutionProviders = [];
}
light(e = G, r = !1) {
return this.config.key = e, this.config.debug = r, this;
}
configure(e) {
return this.config = { ...this.config, ...e }, this;
}
test() {
return this.report(new Error("The Flare client is set up correctly!"));
}
glow(e, r = "info", o = []) {
const t = x();
return this.glows.push({
name: e,
message_level: r,
meta_data: o,
time: t,
microtime: t
}), this.glows.length > this.config.maxGlowsPerReport && (this.glows = this.glows.slice(this.glows.length - this.config.maxGlowsPerReport)), this;
}
clearGlows() {
return this.glows = [], this;
}
addContext(e, r) {
return this.context.context[e] = r, this;
}
addContextGroup(e, r) {
return this.context[e] = r, this;
}
registerSolutionProvider(e) {
return z(e, this.config.debug) ? (this.solutionProviders.push(e), this) : this;
}
async report(e, r = {}, o = {}) {
if (!await this.config.beforeEvaluate(e))
return;
const s = await this.createReportFromError(e, r, o);
if (s)
return this.sendReport(s);
}
async reportMessage(e, r = {}, o = "Log") {
const t = await R(Error(), this.config.debug);
t.shift(), this.sendReport({
notifier: `Flare JavaScript client v${N}`,
exception_class: o,
seen_at: x(),
message: e,
language: "javascript",
glows: this.glows,
context: _({ ...r, ...this.context }),
stacktrace: t,
sourcemap_version_id: this.config.sourcemapVersion,
solutions: [],
stage: this.config.stage
});
}
createReportFromError(e, r = {}, o = {}) {
if (!w(e, "No error provided.", this.config.debug))
return Promise.resolve(!1);
const t = x();
return Promise.all([
re(this.solutionProviders, e, o),
R(e, this.config.debug)
]).then((s) => {
const [l, p] = s;
return w(p.length, "Couldn't generate stacktrace of this error: " + e, this.config.debug), {
notifier: `Flare JavaScript client v${N}`,
exception_class: e.constructor && e.constructor.name ? e.constructor.name : "undefined",
seen_at: t,
message: e.message,
language: "javascript",
glows: this.glows,
context: _({ ...r, ...this.context }),
stacktrace: p,
sourcemap_version_id: this.config.sourcemapVersion,
solutions: l,
stage: this.config.stage
};
});
}
async sendReport(e) {
if (!X(this.config.key, this.config.debug))
return;
const r = await this.config.beforeSubmit(e);
if (r)
return this.api.report(
r,
this.config.reportingUrl,
this.config.key,
this.config.reportBrowserExtensionErrors
);
}
// Deprecated, the following methods exist for backwards compatibility.
set beforeEvaluate(e) {
this.config.beforeEvaluate = e ?? "";
}
set beforeSubmit(e) {
this.config.beforeSubmit = e ?? "";
}
set stage(e) {
this.config.stage = e ?? "";
}
};
function se() {
if (typeof window > "u")
return;
const e = window.flare;
if (!window || !e)
return;
const r = window.onerror, o = window.onunhandledrejection;
window.onerror = (t, s, l, p, f) => {
f && e.report(f), typeof r == "function" && r(t, s, l, p, f);
}, window.onunhandledrejection = (t) => {
t.reason instanceof Error && e.report(t.reason), typeof o == "function" && o(t);
};
}
var y = new ae();
typeof window < "u" && window && (window.flare = y, se());
const A = [
"fancybox",
"jQuery",
"Modernizr",
"cssua",
"ScrollTrigger",
"calcSelectArrowDimensions",
"this.elements.$menu.smartmenus",
"woocommerce",
"elementor",
"avadaAddQuantityBoxes",
"fusion",
"FLBuilderAccordion",
"_initLayerSlider",
"Divi",
"gsap",
"Swiper",
"mailchimp",
"_AutofillCallbackHandler",
"$(...)",
"imagesLoaded",
"accessing a cross-origin frame",
"scrollspy",
"No layout mode: packery",
"Vimeo",
"Network Error",
"Request aborted",
"timeout exceeded",
"Loading chunk",
"TrackerStorageType",
"Failed to load because no supported source was found.",
"The element has no supported sources.",
"grecaptcha",
"lightbox",
"priceCalcElement",
"AwesomeMenu",
"breakdance",
"Maximum call stack size exceeded.",
"Cookies is not defined",
"getUniqId",
"Cannot read properties of null (reading 'classList')",
"n.getModal",
"e.target.closest is not a function",
"Cannot read properties of undefined (reading 'Item')",
"refreshFsLightbox",
"fbq",
"Cannot assign to read only property 'push' of object '[object Array]'",
"naturalWidth",
"Request failed with status code",
"Can't find variable: _",
"astraNavMenuTogglePro",
"The operation was aborted.",
"Failed to fetch dynamically imported module:",
"Importing a module script failed.",
"The request is not allowed by the user agent",
"this.Vi.close",
"The operation is insecure.",
"gformValidateFileSize",
"BreakdanceEntrance",
"Cannot read properties of undefined (reading '__')",
"The play() request was interrupted because video-only",
"Animation is interrupted by user input.",
"Animation is already playing.",
'Position "NaN" is not reachable.',
"Cannot redefine property: onbeforeunload",
"e.remove is not a function",
"Can't find variable: Cookies",
"Load failed",
"wp is not defined",
"Backbone",
"Invalid attempt to destructure non-iterable instance",
"Can't find variable: EmptyRanges",
"Cannot read properties of undefined (reading 'setLocaleData')"
];
y.light("5pqzBljrmDvquWZYSrSUKldIUREtPyB3"), y.addContext("version", "4.4.5"), y.beforeEvaluate = (e) => {
for (let r = 0; r < A.length; r++)
if (e.message.includes(A[r]))
return !1;
return e;
};
function ue(e) {
const r = e.config.errorHandler;
e.config.errorHandler = (o, t, s) => {
const l = t && t.$options && t.$options.name ? t.$options.name : "AnonymousComponent", p = {
vue: { info: s, componentName: l }
};
if (y.report(o, p, { vue: { vm: t, info: s } }), typeof r == "function") {
r(o, t, s);
return;
}
throw o;
};
}
export {
ue as f
};
//# sourceMappingURL=index-DNcHdiEm.js.map