Skip to content

Commit

Permalink
Merge pull request #9 from xyTom/add-sentry
Browse files Browse the repository at this point in the history
Add sentry
  • Loading branch information
xyTom authored Apr 22, 2024
2 parents 8f70409 + c5b221b commit 9735bd7
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 7 deletions.
247 changes: 247 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-tooltip": "^1.0.7",
"@sentry/electron": "^4.23.0",
"@xenova/transformers": "^2.16.1",
"better-react-mathjax": "^2.0.3",
"class-variance-authority": "^0.7.0",
Expand Down
5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { app, BrowserWindow, globalShortcut, ipcMain, Menu } from 'electron';
import path from 'path';
import * as Sentry from "@sentry/electron/main";

Sentry.init({
dsn: "https://b07962090a9e8e5aaf2a34a0b8721a9e@o4507063511089152.ingest.us.sentry.io/4507128527781888",
});
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Screenshots = require('electron-screenshots');

Expand Down
1 change: 1 addition & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts

import { contextBridge, ipcRenderer } from 'electron';
import "@sentry/electron/preload";

contextBridge.exposeInMainWorld('electronAPI', {
onScreenShotRes: (callback: any) => ipcRenderer.on('screenshot-result', (_event, value) => callback(value)),
Expand Down
14 changes: 7 additions & 7 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,20 @@ function App() {

return (

<div className="App dark">
<div className="App dark select-none">

<header className="App-header relative">
<div className="flex h-8 px-4 md:px-6 w-full shrink-0 absolute top-[0.5rem] right-0">
<div className="hidden sm:flex" >
<span className="sr-only">Snippai</span>
</div>
<div className="ml-auto space-x-4 flex text-white">
<div className="ml-auto space-x-4 flex text-white select-none">
<ModelSelect handleModelChange={handleModelChange} />
</div>
</div>
{/* <!-- if no screenshot result, show the logo --> */}
{!screenShotResult && <img src={logo} className="App-logo" alt="logo" />}
{!screenShotResult && <p className="mb-2">
{!screenShotResult && <img src={logo} className="App-logo select-none" alt="logo" />}
{!screenShotResult && <p className="mb-2 select-none">
Press <code>{shortcut}</code> to make a screenshot.
</p>}
{/* <!-- if has screenshot result, show the result --> */}
Expand Down Expand Up @@ -390,7 +390,7 @@ export function ApiKeyButton(props: { onClick: () => void }) {
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<TooltipTrigger asChild>
<Button variant="outline" size="icon" className="mt-auto" onClick={props.onClick}>
<KeyRound className="h-10 w-5" />
</Button>
Expand All @@ -407,7 +407,7 @@ export function RetryButton(props: { onClick: () => void }) {
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<TooltipTrigger asChild>
<Button variant="secondary" size="icon" onClick={props.onClick}>
<RotateCw className="h-10 w-5" />
</Button>
Expand All @@ -425,7 +425,7 @@ export function TrashButton(props: { onClick: () => void }) {
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<TooltipTrigger asChild>
<Button variant="destructive" size="icon" onClick={props.onClick}>
<Trash2 className="h-10 w-5" />
</Button>
Expand Down
14 changes: 14 additions & 0 deletions src/renderer/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ import './index.css';
import App from './App'
import React from 'react'
import ReactDOM from 'react-dom/client'
import * as Sentry from "@sentry/electron/renderer";

Sentry.init({
dsn: "https://b07962090a9e8e5aaf2a34a0b8721a9e@o4507063511089152.ingest.us.sentry.io/4507128527781888",

integrations: [
Sentry.replayIntegration({
maskAllText: false,
}),
],
// Session Replay
replaysSessionSampleRate: 1.0, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
});

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
Expand Down

0 comments on commit 9735bd7

Please sign in to comment.