Skip to content

Commit 672e807

Browse files
committed
Cleanup.
1 parent 262754f commit 672e807

File tree

8 files changed

+66
-13
lines changed

8 files changed

+66
-13
lines changed

demo/main.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
const Gleap = window.Gleap;
22

3-
//Gleap.setFrameUrl("http://0.0.0.0:3001");
4-
//Gleap.setApiUrl("http://0.0.0.0:9000");
5-
Gleap.initialize("ogWhNhuiZcGWrva5nlDS8l7a78OfaLlV");
3+
Gleap.setFrameUrl("http://0.0.0.0:3001");
4+
Gleap.setApiUrl("http://0.0.0.0:9000");
5+
6+
Gleap.setLanguage("de");
7+
8+
Gleap.initialize("zhkMPoY1k41yhOus4BRwVKE7Qas5zbyA");
69
//Gleap.setEnvironment("dev");
710

811
/*Gleap.setUrlHandler((url, newTab) => {

src/Gleap.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ class Gleap {
461461
* @param {string} language country code with two letters
462462
*/
463463
static setLanguage(language) {
464+
if (Gleap.getInstance().initialized) {
465+
console.warn("You must not change the language after Gleap is initialized. Please call this method before Gleap.initialize()");
466+
}
467+
464468
GleapTranslationManager.getInstance().setOverrideLanguage(language);
465469
}
466470

src/GleapConfigManager.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class GleapConfigManager {
4444
*/
4545
start = () => {
4646
const session = GleapSession.getInstance();
47-
const cachedConfig = loadFromGleapCache(`config-${session.sdkKey}`);
47+
const cachedConfig = loadFromGleapCache(`config-${session.sdkKey}-${GleapTranslationManager.getInstance().getActiveLanguage()}`);
4848
if (cachedConfig) {
4949
this.applyConfig(cachedConfig);
5050
this.loadConfigFromServer().catch(function (e) { });
@@ -59,9 +59,10 @@ export default class GleapConfigManager {
5959
return new Promise(function (resolve, reject) {
6060
const session = GleapSession.getInstance();
6161
const http = new XMLHttpRequest();
62+
const lang = GleapTranslationManager.getInstance().getActiveLanguage();
6263
http.open(
6364
"GET",
64-
session.apiUrl + "/config/" + session.sdkKey
65+
session.apiUrl + "/config/" + session.sdkKey + "?lang=" + lang,
6566
);
6667
http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
6768
session.injectSession(http);
@@ -74,7 +75,7 @@ export default class GleapConfigManager {
7475
try {
7576
const config = JSON.parse(http.responseText);
7677
try {
77-
saveToGleapCache(`config-${session.sdkKey}`, config);
78+
saveToGleapCache(`config-${session.sdkKey}-lang`, config);
7879
} catch (exp) { }
7980
self.applyConfig(config);
8081
return resolve();

src/GleapFeedback.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ export default class GleapFeedback {
118118
return feedbackData;
119119
}
120120

121+
getTicketData() {
122+
return new Promise((resolve, reject) => {
123+
this.takeSnapshot().then(() => {
124+
const dataToSend = this.getData();
125+
resolve(dataToSend);
126+
}).catch((exp) => {
127+
reject();
128+
});
129+
});
130+
}
131+
121132
sendFeedback() {
122133
return new Promise((resolve, reject) => {
123134
this.takeSnapshot().then(() => {

src/GleapFrameManager.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import Gleap, {
1010
GleapTranslationManager,
1111
GleapSession,
1212
GleapConfigManager,
13+
GleapCustomDataManager,
14+
GleapMetaDataManager,
15+
GleapConsoleLogManager,
16+
GleapNetworkIntercepter,
17+
GleapTagManager,
1318
} from "./Gleap";
1419
import { widgetMaxHeight } from "./UI";
1520
import { runFunctionWhenDomIsReady } from "./GleapHelper";
@@ -429,6 +434,27 @@ export default class GleapFrameManager {
429434
}
430435
}
431436

437+
if (data.name === "collect-ticket-data") {
438+
var ticketData = {
439+
customData: GleapCustomDataManager.getInstance().getCustomData(),
440+
metaData: GleapMetaDataManager.getInstance().getMetaData(),
441+
consoleLog: GleapConsoleLogManager.getInstance().getLogs(),
442+
networkLogs: GleapNetworkIntercepter.getInstance().getRequests(),
443+
customEventLog: GleapStreamedEvent.getInstance().getEventArray()
444+
};
445+
446+
// Add tags
447+
const tags = GleapTagManager.getInstance().getTags();
448+
if (tags && tags.length > 0) {
449+
ticketData.tags = tags;
450+
}
451+
452+
this.sendMessage({
453+
name: "collect-ticket-data",
454+
data: ticketData,
455+
});
456+
}
457+
432458
if (data.name === "height-update") {
433459
this.frameHeight = data.data;
434460

src/GleapSession.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ export default class GleapSession {
159159
this.notifySessionReady();
160160
};
161161

162+
updateSessionLanguage = (language) => {
163+
console.log("Updating session language to: " + language);
164+
};
165+
162166
startSession = (attemp = 0) => {
163167
// Check if we already have a session cookie.
164168
try {

src/GleapTranslationManager.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GleapFrameManager, GleapFeedbackButtonManager } from "./Gleap";
1+
import { GleapFrameManager, GleapFeedbackButtonManager, GleapSession } from "./Gleap";
22

33
export default class GleapTranslationManager {
44
customTranslation = {};
@@ -28,8 +28,9 @@ export default class GleapTranslationManager {
2828
*/
2929
setOverrideLanguage(language) {
3030
this.overrideLanguage = language;
31-
GleapFrameManager.getInstance().sendConfigUpdate();
32-
this.updateRTLSupport();
31+
32+
//GleapFrameManager.getInstance().sendConfigUpdate();
33+
//this.updateRTLSupport();
3334
}
3435

3536
updateRTLSupport() {
@@ -60,6 +61,8 @@ export default class GleapTranslationManager {
6061
}
6162

6263
static translateText(key) {
64+
return key;
65+
6366
if (!key) {
6467
return "";
6568
}

src/UI.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const injectStyledCSS = (
6161

6262
var borderRadius = parseInt(borderRadius, 10);
6363
const buttonBorderRadius = Math.round(borderRadius * 1.05);
64+
const containerRadius = Math.round(borderRadius * 0.8);
6465
const chatRadius = Math.round(borderRadius * 0.6);
6566
const formItemBorderRadius = Math.round(borderRadius * 0.4);
6667
const formItemSmallBorderRadius = Math.round(borderRadius * 0.25);
@@ -97,7 +98,7 @@ export const injectStyledCSS = (
9798
z-index: ${zIndexBase + 31};
9899
visibility: visible;
99100
box-shadow: 0px 5px 30px rgba(0, 0, 0, 0.16);
100-
border-radius: ${borderRadius}px;
101+
border-radius: ${containerRadius}px;
101102
overflow: hidden;
102103
animation-duration: .3s;
103104
animation-fill-mode: both;
@@ -188,7 +189,7 @@ export const injectStyledCSS = (
188189
.gleap-frame-container--survey-full .gleap-frame-container-inner {
189190
max-width: 640px !important;
190191
width: calc(100% - 24px);
191-
border-radius: ${borderRadius}px;
192+
border-radius: ${containerRadius}px;
192193
overflow: hidden;
193194
}
194195
@@ -465,8 +466,8 @@ export const injectStyledCSS = (
465466
content: " ";
466467
position: absolute;
467468
width: 100%;
468-
height: calc(100% - ${borderRadius}px);
469-
top: ${borderRadius}px;
469+
height: calc(100% - ${containerRadius}px);
470+
top: ${containerRadius}px;
470471
background-color: ${backgroundColor};
471472
z-index: -1;
472473
}

0 commit comments

Comments
 (0)