Skip to content

Commit f9fc02e

Browse files
committed
v7.0.17
1 parent 913ae68 commit f9fc02e

File tree

8 files changed

+57
-18
lines changed

8 files changed

+57
-18
lines changed

demo/main.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Gleap.preFillForm({
66
});
77

88
// Gleap.setApiUrl("http://localhost:9000");
9-
Gleap.initialize("ogWhNhuiZcGWrva5nlDS8l7a78OfaLlV");
9+
// Gleap.setFrameUrl("http://localhost:3001");
10+
Gleap.initialize("MMxTvMklWdr6pgZzA3hJk9K0IvOsIT2A");
1011

1112
Gleap.attachCustomData({
1213
mission: "Unicorn",
@@ -17,6 +18,11 @@ Gleap.attachCustomData({
1718
},
1819
});
1920

21+
Gleap.log("Test log");
22+
Gleap.log("Test log info", "INFO");
23+
Gleap.log("Test log warn", "WARNING");
24+
Gleap.log("Test log err", "ERROR");
25+
2026
// Register custom action.
2127
Gleap.registerCustomAction((customAction) => {
2228
console.log("Custom action called:");

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export namespace Gleap {
4242
function registerCustomAction(
4343
customAction: (action: { name: string }) => void
4444
): void;
45+
function log(message: string, logLevel?: "INFO" | "WARNING" | "ERROR"): void;
4546
function logEvent(name: string, data?: any): void;
4647
function setAppBuildNumber(buildNumber: string): void;
4748
function setAppVersionCode(versionCode: 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": "7.0.16",
3+
"version": "7.0.17",
44
"main": "build/index.js",
55
"scripts": {
66
"start": "webpack serve",

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

src/Gleap.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ class Gleap {
8787
GleapConsoleLogManager.getInstance().stop();
8888
}
8989

90+
/**
91+
* Add entry to logs.
92+
* @param {*} message
93+
* @param {*} logLevel
94+
* @returns
95+
*/
96+
static log(message, logLevel = "INFO") {
97+
GleapConsoleLogManager.getInstance().addLog(message, logLevel);
98+
}
99+
90100
/**
91101
* Initializes the SDK
92102
* @param {*} sdkKey

src/GleapClickListener.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class GleapClickListener {
1818

1919
if (!GleapFrameManager.getInstance().isOpened()) {
2020
GleapConsoleLogManager.getInstance().addLog(
21-
[getDOMElementDescription(event.target)],
21+
getDOMElementDescription(event.target),
2222
"CLICK"
2323
);
2424
}

src/GleapConsoleLogManager.js

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { truncateString } from "./GleapHelper";
22

33
export default class GleapConsoleLogManager {
44
logArray = [];
5+
disabled = false;
56
originalConsoleLog;
67
logMaxLength = 500;
78

@@ -26,16 +27,39 @@ export default class GleapConsoleLogManager {
2627
* Revert console log overwrite.
2728
*/
2829
stop() {
30+
this.disabled = true;
2931
window.console = this.originalConsoleLog;
3032
}
3133

34+
/**
35+
* Add message with log level to logs.
36+
* @param {*} message
37+
* @param {*} logLevel
38+
* @returns
39+
*/
40+
addLog(message, logLevel = "INFO") {
41+
if (!message || message.length <= 0) {
42+
return;
43+
}
44+
45+
this.logArray.push({
46+
log: truncateString(message, 1000),
47+
date: new Date(),
48+
priority: logLevel,
49+
});
50+
51+
if (this.logArray.length > this.logMaxLength) {
52+
this.logArray.shift();
53+
}
54+
}
55+
3256
/**
3357
* Add entry to logs.
3458
* @param {*} args
35-
* @param {*} priority
59+
* @param {*} logLevel
3660
* @returns
3761
*/
38-
addLog(args, priority) {
62+
addLogWithArgs(args, logLevel) {
3963
if (!args || args.length <= 0) {
4064
return;
4165
}
@@ -44,21 +68,18 @@ export default class GleapConsoleLogManager {
4468
for (var i = 0; i < args.length; i++) {
4569
log += args[i] + " ";
4670
}
47-
this.logArray.push({
48-
log: truncateString(log, 1000),
49-
date: new Date(),
50-
priority,
51-
});
5271

53-
if (this.logArray.length > this.logMaxLength) {
54-
this.logArray.shift();
55-
}
72+
this.addLog(log, logLevel);
5673
}
5774

5875
/**
5976
* Start console log overwrite.
6077
*/
6178
start() {
79+
if (this.disabled) {
80+
return;
81+
}
82+
6283
const self = this;
6384
window.console = (function (origConsole) {
6485
if (!window.console || !origConsole) {
@@ -70,19 +91,19 @@ export default class GleapConsoleLogManager {
7091
return {
7192
...origConsole,
7293
log: function () {
73-
self.addLog(arguments, "INFO");
94+
self.addLogWithArgs(arguments, "INFO");
7495
origConsole.log && origConsole.log.apply(origConsole, arguments);
7596
},
7697
warn: function () {
77-
self.addLog(arguments, "WARNING");
98+
self.addLogWithArgs(arguments, "WARNING");
7899
origConsole.warn && origConsole.warn.apply(origConsole, arguments);
79100
},
80101
error: function () {
81-
self.addLog(arguments, "ERROR");
102+
self.addLogWithArgs(arguments, "ERROR");
82103
origConsole.error && origConsole.error.apply(origConsole, arguments);
83104
},
84105
info: function (v) {
85-
self.addLog(arguments, "INFO");
106+
self.addLogWithArgs(arguments, "INFO");
86107
origConsole.info && origConsole.info.apply(origConsole, arguments);
87108
},
88109
};

src/GleapCrashDetector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class GleapCrashDetector {
2525
"Column: " + colno,
2626
"Stack: " + stackTrace,
2727
];
28-
GleapConsoleLogManager.getInstance().addLog(messageObject, "ERROR");
28+
GleapConsoleLogManager.getInstance().addLogWithArgs(messageObject, "ERROR");
2929

3030
const flowConfig = GleapConfigManager.getInstance().getFlowConfig();
3131
if (flowConfig && typeof flowConfig.enableCrashDetector !== "undefined" && flowConfig.enableCrashDetector) {

0 commit comments

Comments
 (0)