Added manual sentry error reporting
This commit is contained in:
parent
f096043975
commit
d9cd5f78cc
8
src/helpers/logging.js
Normal file
8
src/helpers/logging.js
Normal file
@ -0,0 +1,8 @@
|
||||
import { captureException } from "@sentry/react";
|
||||
|
||||
export function logError(error) {
|
||||
console.error(error);
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
captureException(error);
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import GridSizeModel from "../ml/gridSize/GridSizeModel";
|
||||
|
||||
import { logError } from "./logging";
|
||||
|
||||
export function getMapDefaultInset(width, height, gridX, gridY) {
|
||||
// Max the width
|
||||
const gridScale = width / gridX;
|
||||
@ -140,7 +142,7 @@ export async function getGridSize(image) {
|
||||
try {
|
||||
prediction = await gridSizeML(image, candidates);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
logError(error);
|
||||
}
|
||||
|
||||
if (!prediction) {
|
||||
|
@ -3,6 +3,7 @@ import { encode, decode } from "@msgpack/msgpack";
|
||||
import shortid from "shortid";
|
||||
|
||||
import blobToBuffer from "../helpers/blobToBuffer";
|
||||
import { logError } from "../helpers/logging";
|
||||
|
||||
// Limit buffer size to 16kb to avoid issues with chrome packet size
|
||||
// http://viblast.com/blog/2015/2/5/webrtc-data-channel-message-size/
|
||||
@ -78,7 +79,7 @@ class Connection extends SimplePeer {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
logError(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import { EventEmitter } from "events";
|
||||
import Connection from "./Connection";
|
||||
|
||||
import { omit } from "../helpers/shared";
|
||||
import { logError } from "../helpers/logging";
|
||||
|
||||
/**
|
||||
* @typedef {object} SessionPeer
|
||||
@ -112,8 +113,8 @@ class Session extends EventEmitter {
|
||||
const data = await response.json();
|
||||
this._iceServers = data.iceServers;
|
||||
this.socket.emit("join party", partyId, password);
|
||||
} catch (e) {
|
||||
console.error("Unable to join party:", e.message);
|
||||
} catch (error) {
|
||||
logError(error);
|
||||
this.emit("disconnected");
|
||||
}
|
||||
}
|
||||
@ -190,6 +191,7 @@ class Session extends EventEmitter {
|
||||
|
||||
this.peers[id] = peer;
|
||||
} catch (error) {
|
||||
logError(error);
|
||||
this.emit("error", { error });
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ import Footer from "../components/Footer";
|
||||
import Banner from "../components/Banner";
|
||||
import LoadingOverlay from "../components/LoadingOverlay";
|
||||
|
||||
import { logError } from "../helpers/logging";
|
||||
|
||||
const prices = [
|
||||
{ price: "$5.00", name: "Small", value: 5 },
|
||||
{ price: "$15.00", name: "Medium", value: 15 },
|
||||
@ -36,8 +38,9 @@ function Donate() {
|
||||
setStripe(stripe);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch((err) => {
|
||||
setError(err.message);
|
||||
.catch((error) => {
|
||||
logError(error);
|
||||
setError(error.message);
|
||||
setLoading(false);
|
||||
});
|
||||
});
|
||||
|
@ -49,7 +49,6 @@ function Game() {
|
||||
const [peerError, setPeerError] = useState(null);
|
||||
useEffect(() => {
|
||||
function handlePeerError({ error }) {
|
||||
console.error(error.code);
|
||||
if (error.code === "ERR_WEBRTC_SUPPORT") {
|
||||
setPeerError("WebRTC not supported.");
|
||||
} else if (error.code === "ERR_CREATE_OFFER") {
|
||||
|
Loading…
Reference in New Issue
Block a user