Skip to content

Commit

Permalink
chore: fix build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyg603 committed Oct 21, 2024
1 parent df07ffa commit 29bd34f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 28 additions & 22 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import * as path from "path";
import { unhandledRejection } from "./crasher";

const { database, name, version } = require("../../package.json");
const { add } = require('../addon.node');

let add: (a: number, b: number) => number;
try {
add = require("../addon.node");
} catch (e) {
console.warn("Failed to load addon.node, please run `npm run build:cpp`");
}

// Required: Handle native crashes in Electron and native add-ins
crashReporter.start({
Expand All @@ -12,32 +18,32 @@ crashReporter.start({
uploadToServer: true,
rateLimit: false,
globalExtra: {
"product": name,
"version": version,
"key": "en-US",
"email": "[email protected]",
"comments": "BugSplat rocks!",
}
})
product: name,
version: version,
key: "en-US",
email: "[email protected]",
comments: "BugSplat rocks!",
},
});

// Recommended: Initialize BugSplat with database name, app name, and version to catch JavaScript errors
import { BugSplatNode as BugSplat } from "bugsplat-node"
const bugsplat = new BugSplat(database, name, version)
import { BugSplatNode as BugSplat } from "bugsplat-node";
const bugsplat = new BugSplat(database, name, version);

// Recommended: The following methods allow further customization
bugsplat.setDefaultAppKey("main")
bugsplat.setDefaultUser("Fred")
bugsplat.setDefaultEmail("[email protected]")
bugsplat.setDefaultDescription("description")
bugsplat.setDefaultAdditionalFilePaths(["./src/assets/attachment.txt"])
bugsplat.setDefaultAppKey("main");
bugsplat.setDefaultUser("Fred");
bugsplat.setDefaultEmail("[email protected]");
bugsplat.setDefaultDescription("description");
bugsplat.setDefaultAdditionalFilePaths(["./src/assets/attachment.txt"]);

// Recommended: Post to BugSplat when unhandledRejections and uncaughtExceptions occur
const javaScriptErrorHandler = async (error: Error) => {
await bugsplat.post(error);
app.quit();
}
process.on("unhandledRejection", javaScriptErrorHandler)
process.on("uncaughtException", javaScriptErrorHandler)
};
process.on("unhandledRejection", javaScriptErrorHandler);
process.on("uncaughtException", javaScriptErrorHandler);

// Optional: Uncomment to send an Error to BugSplat manually
//bugsplat.post(new Error("foobar!")).then(({ error, response, original }) => console.log(error, response, original))
Expand All @@ -58,7 +64,7 @@ function createWindow() {
mainWindow.loadFile(path.join(__dirname, "../../index.html"));

// Maximize the window so the buttons aren't hidden
mainWindow.maximize()
mainWindow.maximize();

// Open the DevTools.
mainWindow.webContents.openDevTools();
Expand Down Expand Up @@ -99,7 +105,7 @@ ipcMain.on("trigger:addon-main-crash", function () {
console.log("add = ", add(7, 3));
});

ipcMain.on('open-external-url-event', (event, url) => {
event.returnValue = 'Message received!'
ipcMain.on("open-external-url-event", (event, url) => {
event.returnValue = "Message received!";
shell.openExternal(url);
})
});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noImplicitAny": true,
"resolveJsonModule": true,
"sourceMap": true,
"outDir": "dist",
"outDir": "dist/src",
"baseUrl": ".",
"paths": {
"*": ["node_modules/*"]
Expand Down

0 comments on commit 29bd34f

Please sign in to comment.