Skip to content

Commit 1511498

Browse files
committed
v6.4.6
1 parent e5cb55b commit 1511498

File tree

8 files changed

+44
-50
lines changed

8 files changed

+44
-50
lines changed

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export namespace Gleap {
3939
}): void;
4040
function disableConsoleLogOverwrite(): void;
4141
function enableNetworkLogger(): void;
42+
function setLiveSite(isLiveSite: boolean): void;
4243
function enableShortcuts(enabled: boolean): void;
4344
function enableReplays(enabled: boolean): void;
4445
function setLanguage(language: string): void;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "6.4.5",
3+
"version": "6.4.6",
44
"main": "build/index.js",
55
"scripts": {
66
"start": "webpack serve",

published/6.4.6/appwidget.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/6.4.6/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/6.4.6/index.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/latest/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Gleap.js

Lines changed: 37 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ class Gleap {
144144
instance.uiContainer = container;
145145
}
146146

147+
/**
148+
* Set if you running on a live site or local environment.
149+
* @param {*} isLiveSite
150+
*/
151+
static setLiveSite(isLiveSite) {
152+
const instance = this.getInstance();
153+
instance.isLiveSite = isLiveSite;
154+
}
155+
147156
/**
148157
* Initializes the SDK
149158
* @param {*} sdkKey
@@ -628,23 +637,33 @@ class Gleap {
628637
static setStyles(styles) {
629638
this.getInstance().mainColor = styles.primaryColor;
630639

631-
var headerColor = styles.headerColor
640+
const headerColor = styles.headerColor
632641
? styles.headerColor
633642
: styles.primaryColor;
634-
var buttonColor = styles.buttonColor
643+
const buttonColor = styles.buttonColor
635644
? styles.buttonColor
636645
: styles.primaryColor;
637-
var borderRadius = styles.borderRadius ? styles.borderRadius : 20;
646+
const borderRadius = styles.borderRadius ? styles.borderRadius : 20;
638647

639648
if (
640649
document.readyState === "complete" ||
641650
document.readyState === "loaded" ||
642651
document.readyState === "interactive"
643652
) {
644-
injectStyledCSS(styles.primaryColor, headerColor, buttonColor, borderRadius);
653+
injectStyledCSS(
654+
styles.primaryColor,
655+
headerColor,
656+
buttonColor,
657+
borderRadius
658+
);
645659
} else {
646660
document.addEventListener("DOMContentLoaded", function (event) {
647-
injectStyledCSS(styles.primaryColor, headerColor, buttonColor, borderRadius);
661+
injectStyledCSS(
662+
styles.primaryColor,
663+
headerColor,
664+
buttonColor,
665+
borderRadius
666+
);
648667
});
649668
}
650669
}
@@ -915,34 +934,6 @@ class Gleap {
915934
}
916935
}
917936

918-
checkOnlineStatus(url) {
919-
return new Promise((resolve, reject) => {
920-
var xhr = new XMLHttpRequest();
921-
xhr.onreadystatechange = function () {
922-
if (xhr.readyState === XMLHttpRequest.DONE) {
923-
try {
924-
const status = JSON.parse(xhr.responseText);
925-
resolve(status);
926-
} catch (exp) {
927-
reject();
928-
}
929-
}
930-
};
931-
xhr.ontimeout = function () {
932-
reject();
933-
};
934-
xhr.onerror = function () {
935-
reject();
936-
};
937-
xhr.open(
938-
"GET",
939-
"https://uptime.gleap.io/?url=" + encodeURIComponent(url),
940-
true
941-
);
942-
xhr.send();
943-
});
944-
}
945-
946937
startCrashDetection() {
947938
const self = this;
948939
window.onerror = function (msg, url, lineNo, columnNo, error) {
@@ -1257,26 +1248,25 @@ class Gleap {
12571248
this.enableScroll();
12581249
}
12591250

1260-
init() {
1261-
const self = this;
1251+
isLocalNetwork(hostname = window.location.hostname) {
1252+
return (
1253+
["localhost", "127.0.0.1", "", "::1"].includes(hostname) ||
1254+
hostname.startsWith("192.168.") ||
1255+
hostname.startsWith("10.0.") ||
1256+
hostname.endsWith(".local")
1257+
);
1258+
}
12621259

1260+
init() {
12631261
this.overwriteConsoleLog();
12641262
this.startCrashDetection();
12651263
this.registerKeyboardListener();
12661264
this.registerEscapeListener();
12671265

1268-
if (window && window.location && window.location.origin) {
1269-
this.checkOnlineStatus(window.location.origin)
1270-
.then(function (status) {
1271-
if (status && status.up) {
1272-
self.isLiveSite = true;
1273-
} else {
1274-
self.isLiveSite = false;
1275-
}
1276-
})
1277-
.catch(function () {
1278-
self.isLiveSite = false;
1279-
});
1266+
if (this.isLocalNetwork()) {
1267+
this.isLiveSite = false;
1268+
} else {
1269+
this.isLiveSite = true;
12801270
}
12811271
}
12821272

0 commit comments

Comments
 (0)