From f43aa17f1b7833af2a2d871b4e4bff4de107a49a Mon Sep 17 00:00:00 2001 From: xyTom Date: Mon, 22 Apr 2024 00:56:55 -0500 Subject: [PATCH 1/4] fix bugs and add sentry bug tracking --- package-lock.json | 247 ++++++++++++++++++++++++++++++++++++++ package.json | 1 + sentry.properties | 4 + src/main.ts | 5 + src/preload.ts | 1 + src/renderer/App.tsx | 14 +-- src/renderer/renderer.tsx | 12 ++ 7 files changed, 277 insertions(+), 7 deletions(-) create mode 100644 sentry.properties diff --git a/package-lock.json b/package-lock.json index 3e900e5..e5b3efb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,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", @@ -2344,6 +2345,136 @@ "win32" ] }, + "node_modules/@sentry-internal/feedback": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-7.110.0.tgz", + "integrity": "sha512-hrfWa3WkSOiBO5Srcr1j4kuGOlbsQic+REpLOofllVIs56DOo9+Aj9svxT+dcvZERv/nlFSV/E0BfGy9g08IEg==", + "dependencies": { + "@sentry/core": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@sentry-internal/replay-canvas": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-7.110.0.tgz", + "integrity": "sha512-SNa+AfyfX+vc6Xw0pIfDsa5Qnc9cpexU6M2D19gadtVhmep7qoFBuhBVZrSv6BtdCxvrb5EyYsHYGfjQdIDcvg==", + "dependencies": { + "@sentry/core": "7.110.0", + "@sentry/replay": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@sentry-internal/tracing": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.110.0.tgz", + "integrity": "sha512-IIHHa9e/mE7uOMJfNELI8adyoELxOy6u6TNCn5t6fphmq84w8FTc9adXkG/FY2AQpglkIvlILojfMROFB2aaAQ==", + "dependencies": { + "@sentry/core": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/browser": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.110.0.tgz", + "integrity": "sha512-gIxedVm6ZgkjQfgCDgLWJgAsolq6OxV8hQ2j1+RaDL2RngvelFo/vlX5f2sD6EbjVp77Cri8u5GkMJF+v4p84g==", + "dependencies": { + "@sentry-internal/feedback": "7.110.0", + "@sentry-internal/replay-canvas": "7.110.0", + "@sentry-internal/tracing": "7.110.0", + "@sentry/core": "7.110.0", + "@sentry/replay": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/core": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.110.0.tgz", + "integrity": "sha512-g4suCQO94mZsKVaAbyD1zLFC5YSuBQCIPHXx9fdgtfoPib7BWjWWePkllkrvsKAv4u8Oq05RfnKOhOMRHpOKqg==", + "dependencies": { + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/electron": { + "version": "4.23.0", + "resolved": "https://registry.npmjs.org/@sentry/electron/-/electron-4.23.0.tgz", + "integrity": "sha512-D6OkDJqoxHYrVgQbe6qwfjF0ZUtxNdO7q1E+fYK1vcoan3kWE2SbZJk3UqmqiTLHtR188bYB9z0TwsLM2/CRww==", + "dependencies": { + "@sentry/browser": "7.110.0", + "@sentry/core": "7.110.0", + "@sentry/node": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0", + "deepmerge": "4.3.0", + "tslib": "^2.5.0" + } + }, + "node_modules/@sentry/node": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.110.0.tgz", + "integrity": "sha512-YPfweCSzo/omnx5q1xOEZfI8Em3jnPqj7OM4ObXmoSKEK+kM1oUF3BTRzw5BJOaOCSTBFY1RAsGyfVIyrwxWnA==", + "dependencies": { + "@sentry-internal/tracing": "7.110.0", + "@sentry/core": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/replay": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/replay/-/replay-7.110.0.tgz", + "integrity": "sha512-EEpGPf3iBJjWejvoxKLVMnLtLNwPTUxHJV1oxUkbcSi3B/tG5hW7LArYDjAcvkfa4VmA8JLCwj2vYU5MQ8tj6g==", + "dependencies": { + "@sentry-internal/tracing": "7.110.0", + "@sentry/core": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@sentry/types": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.110.0.tgz", + "integrity": "sha512-DqYBLyE8thC5P5MuPn+sj8tL60nCd/f5cerFFPcudn5nJ4Zs1eI6lKlwwyHYTEu5c4KFjCB0qql6kXfwAHmTyA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/utils": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.110.0.tgz", + "integrity": "sha512-VBsdLLN+5tf73fhf/Cm7JIsUJ6y9DkJj8h4I6Mxx0rszrvOyH6S5px40K+V4jdLBzMEvVinC7q2Cbf1YM18BSw==", + "dependencies": { + "@sentry/types": "7.110.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@shikijs/core": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.3.0.tgz", @@ -4774,6 +4905,14 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/deepmerge": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", + "integrity": "sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/defaults": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", @@ -14099,6 +14238,109 @@ "dev": true, "optional": true }, + "@sentry-internal/feedback": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-7.110.0.tgz", + "integrity": "sha512-hrfWa3WkSOiBO5Srcr1j4kuGOlbsQic+REpLOofllVIs56DOo9+Aj9svxT+dcvZERv/nlFSV/E0BfGy9g08IEg==", + "requires": { + "@sentry/core": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + } + }, + "@sentry-internal/replay-canvas": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-7.110.0.tgz", + "integrity": "sha512-SNa+AfyfX+vc6Xw0pIfDsa5Qnc9cpexU6M2D19gadtVhmep7qoFBuhBVZrSv6BtdCxvrb5EyYsHYGfjQdIDcvg==", + "requires": { + "@sentry/core": "7.110.0", + "@sentry/replay": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + } + }, + "@sentry-internal/tracing": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.110.0.tgz", + "integrity": "sha512-IIHHa9e/mE7uOMJfNELI8adyoELxOy6u6TNCn5t6fphmq84w8FTc9adXkG/FY2AQpglkIvlILojfMROFB2aaAQ==", + "requires": { + "@sentry/core": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + } + }, + "@sentry/browser": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.110.0.tgz", + "integrity": "sha512-gIxedVm6ZgkjQfgCDgLWJgAsolq6OxV8hQ2j1+RaDL2RngvelFo/vlX5f2sD6EbjVp77Cri8u5GkMJF+v4p84g==", + "requires": { + "@sentry-internal/feedback": "7.110.0", + "@sentry-internal/replay-canvas": "7.110.0", + "@sentry-internal/tracing": "7.110.0", + "@sentry/core": "7.110.0", + "@sentry/replay": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + } + }, + "@sentry/core": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.110.0.tgz", + "integrity": "sha512-g4suCQO94mZsKVaAbyD1zLFC5YSuBQCIPHXx9fdgtfoPib7BWjWWePkllkrvsKAv4u8Oq05RfnKOhOMRHpOKqg==", + "requires": { + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + } + }, + "@sentry/electron": { + "version": "4.23.0", + "resolved": "https://registry.npmjs.org/@sentry/electron/-/electron-4.23.0.tgz", + "integrity": "sha512-D6OkDJqoxHYrVgQbe6qwfjF0ZUtxNdO7q1E+fYK1vcoan3kWE2SbZJk3UqmqiTLHtR188bYB9z0TwsLM2/CRww==", + "requires": { + "@sentry/browser": "7.110.0", + "@sentry/core": "7.110.0", + "@sentry/node": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0", + "deepmerge": "4.3.0", + "tslib": "^2.5.0" + } + }, + "@sentry/node": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.110.0.tgz", + "integrity": "sha512-YPfweCSzo/omnx5q1xOEZfI8Em3jnPqj7OM4ObXmoSKEK+kM1oUF3BTRzw5BJOaOCSTBFY1RAsGyfVIyrwxWnA==", + "requires": { + "@sentry-internal/tracing": "7.110.0", + "@sentry/core": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + } + }, + "@sentry/replay": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/replay/-/replay-7.110.0.tgz", + "integrity": "sha512-EEpGPf3iBJjWejvoxKLVMnLtLNwPTUxHJV1oxUkbcSi3B/tG5hW7LArYDjAcvkfa4VmA8JLCwj2vYU5MQ8tj6g==", + "requires": { + "@sentry-internal/tracing": "7.110.0", + "@sentry/core": "7.110.0", + "@sentry/types": "7.110.0", + "@sentry/utils": "7.110.0" + } + }, + "@sentry/types": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.110.0.tgz", + "integrity": "sha512-DqYBLyE8thC5P5MuPn+sj8tL60nCd/f5cerFFPcudn5nJ4Zs1eI6lKlwwyHYTEu5c4KFjCB0qql6kXfwAHmTyA==" + }, + "@sentry/utils": { + "version": "7.110.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.110.0.tgz", + "integrity": "sha512-VBsdLLN+5tf73fhf/Cm7JIsUJ6y9DkJj8h4I6Mxx0rszrvOyH6S5px40K+V4jdLBzMEvVinC7q2Cbf1YM18BSw==", + "requires": { + "@sentry/types": "7.110.0" + } + }, "@shikijs/core": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.3.0.tgz", @@ -15819,6 +16061,11 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "deepmerge": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", + "integrity": "sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og==" + }, "defaults": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", diff --git a/package.json b/package.json index 3a53b1c..9ccfe7e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/sentry.properties b/sentry.properties new file mode 100644 index 0000000..83c0d2b --- /dev/null +++ b/sentry.properties @@ -0,0 +1,4 @@ +defaults.url=https://sentry.io/ +defaults.org=snippai +defaults.project=electron +auth.token=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 diff --git a/src/main.ts b/src/main.ts index 3c5970c..59b4500 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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'); diff --git a/src/preload.ts b/src/preload.ts index 06044ca..1676419 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -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)), diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 04e32f8..c26faab 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -281,20 +281,20 @@ function App() { return ( -
+
Snippai
-
+
{/* */} - {!screenShotResult && logo} - {!screenShotResult &&

+ {!screenShotResult && logo} + {!screenShotResult &&

Press {shortcut} to make a screenshot.

} {/* */} @@ -390,7 +390,7 @@ export function ApiKeyButton(props: { onClick: () => void }) { return ( - + @@ -407,7 +407,7 @@ export function RetryButton(props: { onClick: () => void }) { return ( - + @@ -425,7 +425,7 @@ export function TrashButton(props: { onClick: () => void }) { return ( - + diff --git a/src/renderer/renderer.tsx b/src/renderer/renderer.tsx index f72a350..3ab6b37 100644 --- a/src/renderer/renderer.tsx +++ b/src/renderer/renderer.tsx @@ -30,6 +30,18 @@ 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(), + ], + // Session Replay + replaysSessionSampleRate: 0.1, // 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( From 146982bc6014d7895bc15b1977cdbc858100b2f7 Mon Sep 17 00:00:00 2001 From: xyTom Date: Mon, 22 Apr 2024 00:58:37 -0500 Subject: [PATCH 2/4] change sentry sample rate --- src/renderer/renderer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/renderer.tsx b/src/renderer/renderer.tsx index 3ab6b37..c4aefd0 100644 --- a/src/renderer/renderer.tsx +++ b/src/renderer/renderer.tsx @@ -39,7 +39,7 @@ Sentry.init({ Sentry.replayIntegration(), ], // Session Replay - replaysSessionSampleRate: 0.1, // 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. + 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. }); From 6fe5ba709ca66800b0f33fa0786883a0b7d5a307 Mon Sep 17 00:00:00 2001 From: xyTom Date: Mon, 22 Apr 2024 01:09:16 -0500 Subject: [PATCH 3/4] update sentry configuration --- src/renderer/renderer.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/renderer.tsx b/src/renderer/renderer.tsx index c4aefd0..aaf1edb 100644 --- a/src/renderer/renderer.tsx +++ b/src/renderer/renderer.tsx @@ -36,7 +36,9 @@ Sentry.init({ dsn: "https://b07962090a9e8e5aaf2a34a0b8721a9e@o4507063511089152.ingest.us.sentry.io/4507128527781888", integrations: [ - Sentry.replayIntegration(), + 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. From c5b221bddde56c73d0f8c33a5c607bbe25132f97 Mon Sep 17 00:00:00 2001 From: xyTom <75466119+xyTom@users.noreply.github.com> Date: Mon, 22 Apr 2024 01:10:51 -0500 Subject: [PATCH 4/4] Delete sentry.properties --- sentry.properties | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 sentry.properties diff --git a/sentry.properties b/sentry.properties deleted file mode 100644 index 83c0d2b..0000000 --- a/sentry.properties +++ /dev/null @@ -1,4 +0,0 @@ -defaults.url=https://sentry.io/ -defaults.org=snippai -defaults.project=electron -auth.token=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