Skip to content

Instantly share code, notes, and snippets.

@PayneFuRC
Created April 10, 2024 03:34
Show Gist options
  • Save PayneFuRC/52c3ccb46d0a306d84600213c1e09cdb to your computer and use it in GitHub Desktop.
Save PayneFuRC/52c3ccb46d0a306d84600213c1e09cdb to your computer and use it in GitHub Desktop.
Sentry anr
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
Title: <input id="title"/>
<button id="btn" type="button">Set</button>
<script src="./renderer.js"></script>
</body>
</html>
const { app, BrowserWindow, ipcMain } = require('electron/main')
const path = require('node:path')
const crypto = require('crypto');
const { init, anrIntegration } = require('@sentry/electron/main');
let a = anrIntegration({ captureStackTrace: true, anrThreshold: 1000 })
init({
dsn: '__DSN__',
debug: true,
onFatalError: () => {},
integrations: [a],
});
function longWork() {
for (let i = 0; i < 100; i++) {
const salt = crypto.randomBytes(128).toString('base64');
// eslint-disable-next-line no-unused-vars
const hash = crypto.pbkdf2Sync('myPassword', salt, 10000, 512, 'sha512');
}
}
function createWindow () {
const mainWindow = new BrowserWindow({
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
ipcMain.on('set-title', (event, title) => {
const webContents = event.sender
const win = BrowserWindow.fromWebContents(webContents)
win.setTitle(title)
longWork()
})
mainWindow.loadFile('index.html')
}
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
{
"name": "ceaseless-volleyball-agree-oy9zj",
"productName": "ceaseless-volleyball-agree-oy9zj",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "beyondkmp",
"scripts": {
"start": "electron ."
},
"dependencies": {
"@sentry/electron": "4.22.0"
},
"devDependencies": {
"electron": "29.2.0"
}
}
const { contextBridge, ipcRenderer } = require('electron/renderer')
contextBridge.exposeInMainWorld('electronAPI', {
setTitle: (title) => ipcRenderer.send('set-title', title)
})
const setButton = document.getElementById('btn')
const titleInput = document.getElementById('title')
setButton.addEventListener('click', () => {
const title = titleInput.value
window.electronAPI.setTitle(title)
})
/* styles.css */
/* Add styles here to customize the appearance of your app */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment