Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 14 additions & 37 deletions src/components/Export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import localStorageSet from "roamjs-components/util/localStorageSet";
import isLiveBlock from "roamjs-components/queries/isLiveBlock";
import createPage from "roamjs-components/writes/createPage";
import { createInitialTldrawProps } from "../utils/createInitialTldrawProps";
import sendErrorEmail from "../utils/sendErrorEmail";

const ExportProgress = ({ id }: { id: string }) => {
const [progress, setProgress] = useState(0);
Expand Down Expand Up @@ -447,26 +448,14 @@ const ExportDialog: ExportDialogComponent = ({
} catch (e) {
const error = e as Error;
renderToast({
content: "Looks like there was an error. The team has been notified.",
content: "Looks like there was an error.",
intent: "danger",
id: "query-builder-error",
});
apiPost({
domain: "https://api.samepage.network",
path: "errors",
data: {
method: "extension-error",
type: "Query Builder Export Dialog Failed",
message: error.message,
stack: error.stack,
version: process.env.VERSION,
notebookUuid: JSON.stringify({
owner: "RoamJS",
app: "query-builder",
workspace: window.roamAlphaAPI.graph.name,
}),
},
}).catch(() => {});
sendErrorEmail({
error,
type: "Query Builder Export Dialog Failed",
});
} finally {
setLoading(false);
onClose();
Expand Down Expand Up @@ -719,28 +708,16 @@ const ExportDialog: ExportDialogComponent = ({
}
} catch (e) {
const error = e as Error;
apiPost({
domain: "https://api.samepage.network",
path: "errors",
sendErrorEmail({
type: "Query Builder Export Dialog Failed",
error,
data: {
method: "extension-error",
type: "Query Builder Export Dialog Failed",
data: {
activeExportType,
filename,
results:
typeof results === "function" ? "dynamic" : results,
},
message: error.message,
stack: error.stack,
version: process.env.VERSION,
notebookUuid: JSON.stringify({
owner: "RoamJS",
app: "query-builder",
workspace: window.roamAlphaAPI.graph.name,
}),
activeExportType,
filename,
results:
typeof results === "function" ? "dynamic" : results,
},
}).catch(() => {});
});
setDialogOpen(true);
setError((e as Error).message);
} finally {
Expand Down
26 changes: 6 additions & 20 deletions src/components/tldraw/Tldraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import {
DiscourseRelationUtil,
} from "./DiscourseRelationsUtil";
import { isPageUid } from "../../utils/isPageUid";
import apiPost from "roamjs-components/util/apiPost";
import sendErrorEmail from "../../utils/sendErrorEmail";

declare global {
interface Window {
Expand Down Expand Up @@ -794,27 +794,13 @@ const TldrawCanvas = ({ title }: Props) => {
const handleTldrawError = (
e: CustomEvent<{ message: string; stack: string | null }>
) => {
apiPost({
domain: "https://api.samepage.network",
path: "errors",
sendErrorEmail({
type: "Tldraw Error",
error: new Error(e.detail.message, { cause: e.detail.stack }),
data: {
method: "extension-error",
type: "Tldraw Error",
message: e.detail.message,
stack: e.detail.stack,
version: process.env.VERSION,
notebookUuid: JSON.stringify({
owner: "RoamJS",
app: "query-builder",
workspace: window.roamAlphaAPI.graph.name,
}),
data: {
title,
},
title,
},
}).catch(() => {});

console.error("Tldraw Error:", e.detail);
});
};

document.addEventListener(
Expand Down
28 changes: 8 additions & 20 deletions src/utils/calcCanvasNodeSizeAndImg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import getDiscourseNodes from "./getDiscourseNodes";
import resolveRefs from "roamjs-components/dom/resolveRefs";
import { render as renderToast } from "roamjs-components/components/Toast";
import { loadImage } from "./loadImage";
import apiPost from "roamjs-components/util/apiPost";
import sendErrorEmail from "./sendErrorEmail";

const extractFirstImageUrl = (text: string): string | null => {
const regex = /!\[.*?\]\((https:\/\/[^)]+)\)/;
Expand Down Expand Up @@ -99,27 +99,15 @@ const calcCanvasNodeSizeAndImg = async ({
};
} catch (e) {
const error = e as Error;
apiPost({
domain: "https://api.samepage.network",
path: "errors",
sendErrorEmail({
type: "Canvas Image Load Failed",
error,
data: {
method: "extension-error",
type: "Canvas Image Load Failed",
message: error.message,
stack: error.stack,
version: process.env.VERSION,
notebookUuid: JSON.stringify({
owner: "RoamJS",
app: "query-builder",
workspace: window.roamAlphaAPI.graph.name,
}),
data: {
uid,
nodeText,
imageUrl,
},
uid,
nodeText,
imageUrl,
},
}).catch(() => {});
});
renderToast({
id: "tldraw-image-load-fail",
content: error.message,
Expand Down
35 changes: 35 additions & 0 deletions src/utils/sendErrorEmail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import apiPost from "roamjs-components/util/apiPost";

const sendErrorEmail = ({
error,
data,
type,
}: {
error: Error;
data?: Record<string, unknown>;
type: string;
}) => {
const isEncrypted = window.roamAlphaAPI.graph.isEncrypted;
const isOffline = window.roamAlphaAPI.graph.type === "offline";
if (isEncrypted || isOffline) return;

apiPost({
domain: "https://api.samepage.network",
path: "errors",
data: {
method: "extension-error",
type,
message: error.message,
stack: error.stack,
version: process.env.VERSION,
notebookUuid: JSON.stringify({
owner: "RoamJS",
app: "query-builder",
workspace: window.roamAlphaAPI.graph.name,
}),
data,
},
}).catch(() => {});
};

export default sendErrorEmail;