Skip to content

Commit 3e1a9c2

Browse files
committed
v6.8.8
1 parent 27435b8 commit 3e1a9c2

File tree

7 files changed

+21834
-215
lines changed

7 files changed

+21834
-215
lines changed

build/index.js

Lines changed: 7206 additions & 1 deletion
Large diffs are not rendered by default.

demo/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const Gleap = window.Gleap;
22

33
// Gleap.setApiUrl("http://localhost:9000");
4-
Gleap.initialize("ogWhNhuiZcGWrva5nlDS8l7a78OfaLlV", '8fd4b016-b909-49e4-bd66-9a835cdd5a1c', '22327b39e9028307dd88cf1de22fff94092f72500a2a93ddb49e96a2b95476a4');
4+
Gleap.initialize("6aDbcY8I6uo5qc0CnJbfAI8mCXInmsvP");
55

66
/*function makeid(length) {
77
var result = '';

published/6.8.8/index.js

Lines changed: 7206 additions & 1 deletion
Large diffs are not rendered by default.

published/latest/index.js

Lines changed: 7206 additions & 1 deletion
Large diffs are not rendered by default.

src/AutoConfig.js

Lines changed: 210 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
import Gleap from "./Gleap";
12
import { loadFromGleapCache, saveToGleapCache } from "./GleapHelper";
23
import Session from "./Session";
34

45
export default class AutoConfig {
5-
static run = (applyFunc) => {
6-
const cachedConfig = loadFromGleapCache("config");
6+
static run = () => {
7+
const session = Session.getInstance();
8+
const cachedConfig = loadFromGleapCache(`config-${session.sdkKey}`);
79
if (cachedConfig) {
8-
applyFunc(cachedConfig, false);
9-
AutoConfig.loadConfigFromServer(applyFunc, true);
10+
AutoConfig.applyConfig(cachedConfig, false);
11+
AutoConfig.loadConfigFromServer(true).catch(function (e) {});
1012
return Promise.resolve();
1113
}
1214

13-
return AutoConfig.loadConfigFromServer(applyFunc, false);
15+
return AutoConfig.loadConfigFromServer(false);
1416
};
1517

16-
static loadConfigFromServer = (applyFunc, soft) => {
18+
static loadConfigFromServer = (soft) => {
1719
return new Promise(function (resolve, reject) {
1820
const session = Session.getInstance();
1921
const http = new XMLHttpRequest();
@@ -32,9 +34,9 @@ export default class AutoConfig {
3234
try {
3335
const config = JSON.parse(http.responseText);
3436
try {
35-
saveToGleapCache("config", config);
37+
saveToGleapCache(`config-${session.sdkKey}`, config);
3638
} catch (exp) {}
37-
applyFunc(config, soft);
39+
AutoConfig.applyConfig(config, soft);
3840
return resolve();
3941
} catch (e) {}
4042
}
@@ -44,4 +46,204 @@ export default class AutoConfig {
4446
http.send();
4547
});
4648
};
49+
50+
/**
51+
* Applies the Gleap config.
52+
* @param {*} config
53+
*/
54+
static applyConfig(config, soft) {
55+
try {
56+
const flowConfig = config.flowConfig;
57+
const projectActions = config.projectActions;
58+
59+
if (flowConfig.color) {
60+
Gleap.setStyles({
61+
primaryColor: flowConfig.color,
62+
headerColor: flowConfig.headerColor,
63+
buttonColor: flowConfig.buttonColor,
64+
borderRadius: flowConfig.borderRadius,
65+
backgroundColor: flowConfig.backgroundColor
66+
? flowConfig.backgroundColor
67+
: "#FFFFFF",
68+
});
69+
}
70+
71+
// If it's only a soft update, return here.
72+
if (soft) {
73+
return;
74+
}
75+
76+
if (flowConfig.logo && flowConfig.logo.length > 0) {
77+
Gleap.setLogoUrl(flowConfig.logo);
78+
}
79+
80+
if (flowConfig.hideBranding) {
81+
Gleap.enablePoweredBy();
82+
}
83+
84+
if (flowConfig.enableReplays) {
85+
Gleap.enableReplays(flowConfig.enableReplays);
86+
}
87+
88+
Gleap.enableShortcuts(flowConfig.enableShortcuts ? true : false);
89+
90+
if (flowConfig.enableNetworkLogs) {
91+
Gleap.enableNetworkLogger();
92+
}
93+
94+
if (flowConfig.networkLogPropsToIgnore) {
95+
Gleap.setNetworkLogFilters(flowConfig.networkLogPropsToIgnore);
96+
}
97+
98+
if (!flowConfig.enableConsoleLogs) {
99+
Gleap.disableConsoleLogOverwrite();
100+
}
101+
102+
if (
103+
typeof flowConfig.enableCrashDetector !== "undefined" &&
104+
flowConfig.enableCrashDetector
105+
) {
106+
Gleap.enableCrashDetector(true, flowConfig.enableCrashDetector);
107+
}
108+
109+
if (
110+
typeof flowConfig.enableRageClickDetector !== "undefined" &&
111+
flowConfig.enableRageClickDetector
112+
) {
113+
Gleap.enableRageClickDetector(flowConfig.rageClickDetectorIsSilent);
114+
}
115+
116+
if (flowConfig.customTranslations) {
117+
Gleap.setCustomTranslation(flowConfig.customTranslations);
118+
}
119+
120+
if (
121+
typeof flowConfig.feedbackButtonPosition !== "undefined" &&
122+
flowConfig.feedbackButtonPosition.length > 0
123+
) {
124+
Gleap.setButtonType(flowConfig.feedbackButtonPosition);
125+
}
126+
127+
if (
128+
typeof flowConfig.widgetButtonText !== "undefined" &&
129+
flowConfig.widgetButtonText.length > 0
130+
) {
131+
Gleap.setFeedbackButtonText(flowConfig.widgetButtonText);
132+
}
133+
134+
if (
135+
typeof flowConfig.hideWavingHandAfterName !== "undefined" &&
136+
flowConfig.hideWavingHandAfterName
137+
) {
138+
Gleap.setWelcomeIcon("");
139+
}
140+
141+
if (
142+
typeof flowConfig.hideUsersName !== "undefined" &&
143+
flowConfig.hideUsersName
144+
) {
145+
Gleap.setShowUserName(false);
146+
}
147+
148+
if (flowConfig.widgetInfoTitle && flowConfig.widgetInfoTitle.length > 0) {
149+
Gleap.setWidgetInfo({
150+
title: flowConfig.widgetInfoTitle,
151+
});
152+
}
153+
154+
if (
155+
flowConfig.widgetInfoSubtitle &&
156+
flowConfig.widgetInfoSubtitle.length > 0
157+
) {
158+
Gleap.setWidgetInfo({
159+
subtitle: flowConfig.widgetInfoSubtitle,
160+
});
161+
}
162+
163+
if (
164+
flowConfig.widgetInfoDialogSubtitle &&
165+
flowConfig.widgetInfoDialogSubtitle.length > 0
166+
) {
167+
Gleap.setWidgetInfo({
168+
dialogSubtitle: flowConfig.widgetInfoDialogSubtitle,
169+
});
170+
}
171+
172+
const instance = Gleap.getInstance();
173+
if (
174+
flowConfig.enableMenu &&
175+
flowConfig.menuItems &&
176+
flowConfig.menuItems.length > 0
177+
) {
178+
let menuItems = [];
179+
for (let i = 0; i < flowConfig.menuItems.length; i++) {
180+
let menuItem = flowConfig.menuItems[i];
181+
let actionFlow = null;
182+
let action = null;
183+
184+
if (menuItem.actionType === "OPEN_INTERCOM") {
185+
action = function () {
186+
if (instance.widgetCallback) {
187+
return;
188+
}
189+
if (typeof Intercom !== "undefined") {
190+
Intercom("showNewMessage");
191+
}
192+
};
193+
} else if (menuItem.actionType === "REDIRECT_URL") {
194+
if (instance.widgetCallback) {
195+
action = function () {
196+
instance.widgetCallback("openExternalURL", {
197+
url: menuItem.actionBody,
198+
});
199+
};
200+
} else {
201+
if (menuItem.actionOpenInNewTab) {
202+
action = function () {
203+
window.open(menuItem.actionBody, "_blank").focus();
204+
};
205+
} else {
206+
action = function () {
207+
window.location.href = menuItem.actionBody;
208+
};
209+
}
210+
}
211+
} else if (menuItem.actionType === "CUSTOM_ACTION") {
212+
action = function () {
213+
Gleap.triggerCustomAction(menuItem.actionBody);
214+
};
215+
} else {
216+
actionFlow = menuItem.actionType;
217+
}
218+
219+
// Action flow
220+
if (actionFlow != null || action != null) {
221+
var item = {
222+
title: menuItem.title,
223+
description: menuItem.description,
224+
icon: menuItem.icon,
225+
color: menuItem.color,
226+
};
227+
if (actionFlow) {
228+
item["actionFlow"] = actionFlow;
229+
}
230+
if (action) {
231+
item["action"] = action;
232+
}
233+
menuItems.push(item);
234+
}
235+
}
236+
237+
Gleap.setMenuOptions(menuItems);
238+
}
239+
240+
if (projectActions) {
241+
Gleap.setFeedbackActions(projectActions);
242+
}
243+
244+
if (flowConfig.buttonLogo && flowConfig.buttonLogo.length > 0) {
245+
Gleap.setButtonLogoUrl(flowConfig.buttonLogo);
246+
}
247+
} catch (e) {}
248+
}
47249
}

0 commit comments

Comments
 (0)