Skip to content

Commit b1f6b66

Browse files
committed
Updated screenshot API to pico.
1 parent 875d98f commit b1f6b66

File tree

8 files changed

+30
-58
lines changed

8 files changed

+30
-58
lines changed

build/index.css

Lines changed: 0 additions & 12 deletions
This file was deleted.

build/index.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/index.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

build/index.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bugbattle",
3-
"version": "3.1.8",
3+
"version": "3.1.9",
44
"main": "build/index.js",
55
"types": "index.d.ts",
66
"scripts": {
@@ -150,6 +150,6 @@
150150
]
151151
},
152152
"dependencies": {
153-
"html2canvas": "^1.0.0-rc.7"
153+
"@gripeless/pico": "^1.0.1"
154154
}
155155
}

public/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h1>JavaScript Demo</h1>
1818
<h2>Bugbattle SDK for the Web</h2>
1919
</div>
2020
<div class="header-container-image">
21-
<img class="head-image" src="./pexels-christina-morillo-1181467.jpg" />
21+
<img class="head-image" src="pexels-christina-morillo-1181467.jpg" />
2222
</div>
2323
</div>
2424
<div class="content">
@@ -30,13 +30,14 @@ <h2>Bugbattle SDK for the Web</h2>
3030
<span>No more wasting time trying to reproduce a bug. Bugbattle reports automatically contain a replay video,
3131
session data, logs and more. Even better: You can add custom data to your bug details.</span>
3232
<br /><br />
33-
<span>In less than a minute you can add our Bugbattle SDK to your App or WebApp. Install our SDK, build and run. A piece of cake.</span>
33+
<span>In less than a minute you can add our Bugbattle SDK to your App or WebApp. Install our SDK, build and run. A
34+
piece of cake.</span>
3435
<br /><br />
3536
<a id="feedback-button">Report feedback</a>
3637
<a onclick="console.error('Fake error');">Fake critical error</a>
3738
<br />
3839
<span>What are you waiting for?</span>
39-
<br />
40+
<br />
4041
<a class="buttonlink" href="https://www.bugbattle.io/">Get started</a>
4142
</div>
4243
</body>

src/demo/App.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import BugBattle from './../lib';
44
class App {
55
constructor() {
66
// Initialize the SDK.
7-
BugBattle.initialize("8hWXOj5yeZxweCgnyxYTXqJ1qFlu0N4U", BugBattle.FEEDBACK_BUTTON);
7+
BugBattle.initialize("NF0AbayNnRfrT6QsB3uGAi6ANdd8WeX4", BugBattle.FEEDBACK_BUTTON);
88

99
// Set's the app's build number.
1010
BugBattle.setMainColor('#FEAB39');
@@ -33,6 +33,10 @@ class App {
3333
BugBattle.startBugReporting();
3434
}
3535
}
36+
37+
console.log("asdf");
38+
console.warn("asdf");
39+
console.error("asdf");
3640
}
3741
}
3842

src/lib/BugBattle.js

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "./css/App.css";
2-
import html2canvas from "html2canvas";
2+
import { dataURL } from "@gripeless/pico";
33

44
class BugBattle {
55
apiUrl = "https://api.bugbattle.io";
@@ -214,7 +214,7 @@ class BugBattle {
214214
}
215215
}
216216

217-
addLog(args, type) {
217+
addLog(args, priority) {
218218
if (!args) {
219219
return;
220220
}
@@ -226,7 +226,7 @@ class BugBattle {
226226
this.logArray.push({
227227
log: log,
228228
date: new Date(),
229-
type: type,
229+
priority,
230230
});
231231
}
232232

@@ -245,20 +245,20 @@ class BugBattle {
245245

246246
return {
247247
log: function () {
248-
self.addLog(arguments, "log");
248+
self.addLog(arguments, "INFO");
249249
origConsole.log && origConsole.log.apply(origConsole, arguments);
250250
},
251251
warn: function () {
252-
self.addLog(arguments, "warns");
252+
self.addLog(arguments, "WARNING");
253253
origConsole.warn && origConsole.warn.apply(origConsole, arguments);
254254
},
255255
error: function () {
256-
self.addLog(arguments, "error");
256+
self.addLog(arguments, "ERROR");
257257
origConsole.error && origConsole.error.apply(origConsole, arguments);
258258
self.startCrashFlow();
259259
},
260260
info: function (v) {
261-
self.addLog(arguments, "info");
261+
self.addLog(arguments, "INFO");
262262
origConsole.info && origConsole.info.apply(origConsole, arguments);
263263
},
264264
};
@@ -283,7 +283,7 @@ class BugBattle {
283283

284284
var elem = document.createElement("div");
285285
elem.className = "bugbattle--feedback-dialog-container";
286-
elem.setAttribute("data-html2canvas-ignore", "true");
286+
elem.setAttribute("data-ignore-bb", "true");
287287
elem.innerHTML = `<div class='bugbattle--feedback-dialog'>
288288
<div class="bugbattle--feedback-dialog-header">
289289
<div></div>
@@ -328,7 +328,7 @@ class BugBattle {
328328

329329
var elem = document.createElement("div");
330330
elem.className = "bugbattle--feedback-dialog-container";
331-
elem.setAttribute("data-html2canvas-ignore", "true");
331+
elem.setAttribute("data-ignore-bb", "true");
332332
elem.innerHTML = `<div class='bugbattle--feedback-dialog'>
333333
<div class="bugbattle--feedback-dialog-header">
334334
<div></div>
@@ -477,25 +477,19 @@ class BugBattle {
477477
self.preScreenshotCleanup();
478478

479479
window.scrollTo(self.snapshotPosition.x, self.snapshotPosition.y);
480-
html2canvas(document.body, {
481-
x: self.snapshotPosition.x,
482-
y: self.snapshotPosition.y,
483-
width: window.innerWidth,
484-
height: window.innerHeight,
485-
letterRendering: 1,
486-
allowTaint: true,
487-
useCORS: false,
488-
logging: false,
489-
imageTimeout: 15000,
490-
proxy: "https://jsproxy.bugbattle.io/",
480+
481+
dataURL(window, {
482+
ignore: ['[data-ignore-bb~="true"]'],
491483
})
492-
.then(function (canvas) {
493-
if (canvas) {
494-
self.screenshot = canvas.toDataURL();
484+
.then((screen) => {
485+
if (screen && screen.value) {
486+
self.screenshot = screen.value;
495487
self.prepareScreenshot();
488+
} else {
489+
self.showError();
496490
}
497491
})
498-
.catch(function () {
492+
.catch((exp) => {
499493
self.showError();
500494
});
501495
};
@@ -828,7 +822,7 @@ class BugBattle {
828822
const self = this;
829823
var bugReportingEditor = document.createElement("div");
830824
bugReportingEditor.className = "bugbattle-screenshot-editor-container";
831-
bugReportingEditor.setAttribute("data-html2canvas-ignore", "true");
825+
bugReportingEditor.setAttribute("data-ignore-bb", "true");
832826
bugReportingEditor.innerHTML = `
833827
<div class='bugbattle-screenshot-editor-container-inner'>
834828
<div class='bugbattle-screenshot-editor-borderlayer'></div>

0 commit comments

Comments
 (0)