Skip to content

Commit

Permalink
v6.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
boehlerlukas committed Dec 15, 2021
1 parent e5cb55b commit 1511498
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 50 deletions.
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export namespace Gleap {
}): void;
function disableConsoleLogOverwrite(): void;
function enableNetworkLogger(): void;
function setLiveSite(isLiveSite: boolean): void;
function enableShortcuts(enabled: boolean): void;
function enableReplays(enabled: boolean): void;
function setLanguage(language: string): void;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gleap",
"version": "6.4.5",
"version": "6.4.6",
"main": "build/index.js",
"scripts": {
"start": "webpack serve",
Expand Down
1 change: 1 addition & 0 deletions published/6.4.6/appwidget.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions published/6.4.6/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions published/6.4.6/index.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion published/latest/index.js

Large diffs are not rendered by default.

84 changes: 37 additions & 47 deletions src/Gleap.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ class Gleap {
instance.uiContainer = container;
}

/**
* Set if you running on a live site or local environment.
* @param {*} isLiveSite
*/
static setLiveSite(isLiveSite) {
const instance = this.getInstance();
instance.isLiveSite = isLiveSite;
}

/**
* Initializes the SDK
* @param {*} sdkKey
Expand Down Expand Up @@ -628,23 +637,33 @@ class Gleap {
static setStyles(styles) {
this.getInstance().mainColor = styles.primaryColor;

var headerColor = styles.headerColor
const headerColor = styles.headerColor
? styles.headerColor
: styles.primaryColor;
var buttonColor = styles.buttonColor
const buttonColor = styles.buttonColor
? styles.buttonColor
: styles.primaryColor;
var borderRadius = styles.borderRadius ? styles.borderRadius : 20;
const borderRadius = styles.borderRadius ? styles.borderRadius : 20;

if (
document.readyState === "complete" ||
document.readyState === "loaded" ||
document.readyState === "interactive"
) {
injectStyledCSS(styles.primaryColor, headerColor, buttonColor, borderRadius);
injectStyledCSS(
styles.primaryColor,
headerColor,
buttonColor,
borderRadius
);
} else {
document.addEventListener("DOMContentLoaded", function (event) {
injectStyledCSS(styles.primaryColor, headerColor, buttonColor, borderRadius);
injectStyledCSS(
styles.primaryColor,
headerColor,
buttonColor,
borderRadius
);
});
}
}
Expand Down Expand Up @@ -915,34 +934,6 @@ class Gleap {
}
}

checkOnlineStatus(url) {
return new Promise((resolve, reject) => {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
try {
const status = JSON.parse(xhr.responseText);
resolve(status);
} catch (exp) {
reject();
}
}
};
xhr.ontimeout = function () {
reject();
};
xhr.onerror = function () {
reject();
};
xhr.open(
"GET",
"https://uptime.gleap.io/?url=" + encodeURIComponent(url),
true
);
xhr.send();
});
}

startCrashDetection() {
const self = this;
window.onerror = function (msg, url, lineNo, columnNo, error) {
Expand Down Expand Up @@ -1257,26 +1248,25 @@ class Gleap {
this.enableScroll();
}

init() {
const self = this;
isLocalNetwork(hostname = window.location.hostname) {
return (
["localhost", "127.0.0.1", "", "::1"].includes(hostname) ||
hostname.startsWith("192.168.") ||
hostname.startsWith("10.0.") ||
hostname.endsWith(".local")
);
}

init() {
this.overwriteConsoleLog();
this.startCrashDetection();
this.registerKeyboardListener();
this.registerEscapeListener();

if (window && window.location && window.location.origin) {
this.checkOnlineStatus(window.location.origin)
.then(function (status) {
if (status && status.up) {
self.isLiveSite = true;
} else {
self.isLiveSite = false;
}
})
.catch(function () {
self.isLiveSite = false;
});
if (this.isLocalNetwork()) {
this.isLiveSite = false;
} else {
this.isLiveSite = true;
}
}

Expand Down

0 comments on commit 1511498

Please sign in to comment.