Skip to content

Commit 1d7f441

Browse files
committed
v6.8.7
1 parent c6027fb commit 1d7f441

File tree

9 files changed

+209
-205
lines changed

9 files changed

+209
-205
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.

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.8.6",
3+
"version": "6.8.7",
44
"main": "build/index.js",
55
"scripts": {
66
"start": "webpack serve",

published/6.8.6/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.

published/6.8.7/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.8.7/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.8.7/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/AutoConfig.js

Lines changed: 10 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import Gleap from "./Gleap";
21
import { loadFromGleapCache, saveToGleapCache } from "./GleapHelper";
32
import Session from "./Session";
43

54
export default class AutoConfig {
65
static run = () => {
7-
/*const cachedConfig = loadFromGleapCache("config");
6+
const cachedConfig = loadFromGleapCache("config");
87
if (cachedConfig) {
9-
AutoConfig.applyConfig(cachedConfig);
10-
AutoConfig.loadConfigFromServer(false);
11-
return Promise.resolve();
12-
}*/
8+
AutoConfig.loadConfigFromServer();
9+
return Promise.resolve(cachedConfig);
10+
}
1311

14-
return AutoConfig.loadConfigFromServer(true);
12+
return AutoConfig.loadConfigFromServer();
1513
};
1614

17-
static loadConfigFromServer = (updateConfig = false) => {
18-
return new Promise(function (resolve) {
15+
static loadConfigFromServer = () => {
16+
return new Promise(function (resolve, reject) {
1917
const session = Session.getInstance();
2018
const http = new XMLHttpRequest();
2119
http.open(
@@ -25,7 +23,7 @@ export default class AutoConfig {
2523
http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
2624
session.injectSession(http);
2725
http.onerror = function () {
28-
resolve();
26+
reject();
2927
};
3028
http.onreadystatechange = function (e) {
3129
if (http.readyState === XMLHttpRequest.DONE) {
@@ -35,198 +33,13 @@ export default class AutoConfig {
3533
try {
3634
saveToGleapCache("config", config);
3735
} catch (exp) {}
38-
if (updateConfig) {
39-
AutoConfig.applyConfig(config);
40-
}
36+
return resolve(config);
4137
} catch (e) {}
4238
}
43-
resolve();
39+
reject();
4440
}
4541
};
4642
http.send();
4743
});
4844
};
49-
50-
static applyConfig(config) {
51-
try {
52-
const flowConfig = config.flowConfig;
53-
const projectActions = config.projectActions;
54-
55-
const instance = Gleap.getInstance();
56-
if (flowConfig.logo && flowConfig.logo.length > 0) {
57-
Gleap.setLogoUrl(flowConfig.logo);
58-
}
59-
60-
if (flowConfig.color) {
61-
Gleap.setStyles({
62-
primaryColor: flowConfig.color,
63-
headerColor: flowConfig.headerColor,
64-
buttonColor: flowConfig.buttonColor,
65-
borderRadius: flowConfig.borderRadius,
66-
backgroundColor: flowConfig.backgroundColor
67-
? flowConfig.backgroundColor
68-
: "#FFFFFF",
69-
});
70-
}
71-
72-
if (flowConfig.hideBranding) {
73-
Gleap.enablePoweredBy();
74-
}
75-
76-
if (flowConfig.networkLogPropsToIgnore) {
77-
Gleap.setNetworkLogFilters(flowConfig.networkLogPropsToIgnore);
78-
}
79-
80-
if (!flowConfig.enableConsoleLogs) {
81-
Gleap.disableConsoleLogOverwrite();
82-
}
83-
84-
if (
85-
typeof flowConfig.enableCrashDetector !== "undefined" &&
86-
flowConfig.enableCrashDetector
87-
) {
88-
Gleap.enableCrashDetector(true, flowConfig.enableCrashDetector);
89-
}
90-
91-
if (
92-
typeof flowConfig.enableRageClickDetector !== "undefined" &&
93-
flowConfig.enableRageClickDetector
94-
) {
95-
Gleap.enableRageClickDetector(flowConfig.rageClickDetectorIsSilent);
96-
}
97-
98-
if (flowConfig.customTranslations) {
99-
Gleap.setCustomTranslation(flowConfig.customTranslations);
100-
}
101-
102-
if (
103-
typeof flowConfig.feedbackButtonPosition !== "undefined" &&
104-
flowConfig.feedbackButtonPosition.length > 0
105-
) {
106-
Gleap.setButtonType(flowConfig.feedbackButtonPosition);
107-
}
108-
109-
if (
110-
typeof flowConfig.widgetButtonText !== "undefined" &&
111-
flowConfig.widgetButtonText.length > 0
112-
) {
113-
Gleap.setFeedbackButtonText(flowConfig.widgetButtonText);
114-
}
115-
116-
if (
117-
typeof flowConfig.hideWavingHandAfterName !== "undefined" &&
118-
flowConfig.hideWavingHandAfterName
119-
) {
120-
Gleap.setWelcomeIcon("");
121-
}
122-
123-
if (
124-
typeof flowConfig.hideUsersName !== "undefined" &&
125-
flowConfig.hideUsersName
126-
) {
127-
Gleap.setShowUserName(false);
128-
}
129-
130-
if (flowConfig.widgetInfoTitle && flowConfig.widgetInfoTitle.length > 0) {
131-
Gleap.setWidgetInfo({
132-
title: flowConfig.widgetInfoTitle,
133-
});
134-
}
135-
136-
if (
137-
flowConfig.widgetInfoSubtitle &&
138-
flowConfig.widgetInfoSubtitle.length > 0
139-
) {
140-
Gleap.setWidgetInfo({
141-
subtitle: flowConfig.widgetInfoSubtitle,
142-
});
143-
}
144-
145-
if (
146-
flowConfig.widgetInfoDialogSubtitle &&
147-
flowConfig.widgetInfoDialogSubtitle.length > 0
148-
) {
149-
Gleap.setWidgetInfo({
150-
dialogSubtitle: flowConfig.widgetInfoDialogSubtitle,
151-
});
152-
}
153-
154-
if (
155-
flowConfig.enableMenu &&
156-
flowConfig.menuItems &&
157-
flowConfig.menuItems.length > 0
158-
) {
159-
let menuItems = [];
160-
for (let i = 0; i < flowConfig.menuItems.length; i++) {
161-
let menuItem = flowConfig.menuItems[i];
162-
let actionFlow = null;
163-
let action = null;
164-
165-
if (menuItem.actionType === "OPEN_INTERCOM") {
166-
action = function () {
167-
if (instance.widgetCallback) {
168-
return;
169-
}
170-
if (typeof Intercom !== "undefined") {
171-
Intercom("showNewMessage");
172-
}
173-
};
174-
} else if (menuItem.actionType === "REDIRECT_URL") {
175-
if (instance.widgetCallback) {
176-
action = function () {
177-
instance.widgetCallback("openExternalURL", {
178-
url: menuItem.actionBody,
179-
});
180-
};
181-
} else {
182-
if (menuItem.actionOpenInNewTab) {
183-
action = function () {
184-
window.open(menuItem.actionBody, "_blank").focus();
185-
};
186-
} else {
187-
action = function () {
188-
window.location.href = menuItem.actionBody;
189-
};
190-
}
191-
}
192-
} else if (menuItem.actionType === "CUSTOM_ACTION") {
193-
action = function () {
194-
Gleap.triggerCustomAction(menuItem.actionBody);
195-
};
196-
} else {
197-
actionFlow = menuItem.actionType;
198-
}
199-
200-
// Action flow
201-
if (actionFlow != null || action != null) {
202-
var item = {
203-
title: menuItem.title,
204-
description: menuItem.description,
205-
icon: menuItem.icon,
206-
color: menuItem.color,
207-
};
208-
if (actionFlow) {
209-
item["actionFlow"] = actionFlow;
210-
}
211-
if (action) {
212-
item["action"] = action;
213-
}
214-
menuItems.push(item);
215-
}
216-
}
217-
218-
Gleap.setMenuOptions(menuItems);
219-
}
220-
221-
if (projectActions) {
222-
Gleap.setFeedbackActions(projectActions);
223-
}
224-
225-
if (flowConfig.buttonLogo && flowConfig.buttonLogo.length > 0) {
226-
Gleap.setButtonLogoUrl(flowConfig.buttonLogo);
227-
}
228-
} catch (e) {
229-
console.log(e);
230-
}
231-
}
23245
}

0 commit comments

Comments
 (0)