Skip to content

Commit d275b95

Browse files
committed
chore: Setup sentry
1 parent 0eba50a commit d275b95

File tree

6 files changed

+124
-5
lines changed

6 files changed

+124
-5
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@react-input/mask": "^1.2.5",
2323
"@rescript/core": "1.4.0",
2424
"@rescript/react": "^0.12.1",
25+
"@sentry/react": "^8.35.0",
2526
"@tailwindcss/container-queries": "^0.1.1",
2627
"@types/react": "^18.3.3",
2728
"@types/react-dom": "^18.3.0",

src/ErrorBoundary.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from "react";
22
import pandaImage from "./assets/fail-panda.gif";
33
import { logException } from "./hooks/useAnalytics";
4+
import * as Sentry from "@sentry/react";
45

56
type ErrorBoundaryProps = {
67
children?: React.ReactNode;
@@ -23,7 +24,7 @@ type ErrorBoundaryState = {
2324
};
2425

2526
export const ShowErrorContext = React.createContext<(error: unknown) => void>(
26-
() => {},
27+
() => { },
2728
);
2829

2930
export class ErrorBoundary extends React.Component<ErrorBoundaryProps> {
@@ -39,14 +40,24 @@ export class ErrorBoundary extends React.Component<ErrorBoundaryProps> {
3940

4041
logError = (error: unknown, additionalInfo?: React.ErrorInfo) => {
4142
logException(error, additionalInfo);
43+
44+
Sentry.captureException(error,
45+
{
46+
contexts: {
47+
react: {
48+
...additionalInfo
49+
},
50+
}
51+
}
52+
);
4253
};
4354

44-
componentDidCatch(e: unknown, { componentStack }: React.ErrorInfo) {
55+
componentDidCatch(e: unknown, additionalInfo: React.ErrorInfo) {
4556
if (!this.state.error) {
4657
return;
4758
}
4859

49-
this.logError(e, componentStack as any);
60+
this.logError(e, additionalInfo as any);
5061
}
5162

5263
getErrorDetails = () => {

src/Main.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,27 @@ import LolApp from "./LolApp";
66
import { BrowserNotSupported, isBrowserSupported } from "./BrowserNotSupported";
77
import { ErrorBoundary } from "./ErrorBoundary";
88
import { registerSW } from "virtual:pwa-register";
9+
import * as Sentry from "@sentry/react";
910

1011
registerSW({ immediate: false });
1112

13+
Sentry.init({
14+
dsn: "https://c0ff8dd14d638c4e77dfa9c25e4bd42d@o464504.ingest.us.sentry.io/4508197084725248",
15+
integrations: [
16+
Sentry.browserTracingIntegration(),
17+
Sentry.replayIntegration(),
18+
],
19+
tracesSampleRate: 1.0,
20+
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
21+
tracePropagationTargets: [
22+
"localhost",
23+
/^https:\/\/subtitles\.fframes\.studio/
24+
],
25+
enabled: process.env.NODE_ENV !== 'development',
26+
replaysSessionSampleRate: 0.05, // 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.
27+
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
28+
});
29+
1230
const rootElement = document.querySelector("#root");
1331
if (rootElement) {
1432
const root = ReactDOM.createRoot(rootElement);

src/codecs/subtitle-renderer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export function createCtx(
6969
canvas: OffscreenCanvas,
7070
style: style,
7171
): RendererContext {
72-
// @ts-expect-error
7372
let stage = new KonvaCore.Stage({
7473
width: videoConfig.codedWidth,
7574
height: videoConfig.codedHeight,

vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default defineConfig({
1515
registerType: "autoUpdate",
1616
injectRegister: "auto",
1717
workbox: {
18+
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
1819
globPatterns: ["**/*.{js,css,html,ico,png,svg,woff2,ttf}"],
1920
},
2021
}),

yarn.lock

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,88 @@
16811681
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.24.2.tgz#0610af0fb8fec52be779d5b163bbbd6930150467"
16821682
integrity sha512-2mLH46K1u3r6uwc95hU+OR9q/ggYMpnS7pSp83Ece1HUQgF9Nh/QwTK5rcgbFnV9j+08yBrU5sA/P0RK2MSBNA==
16831683

1684+
"@sentry-internal/browser-utils@8.35.0":
1685+
version "8.35.0"
1686+
resolved "https://registry.yarnpkg.com/@sentry-internal/browser-utils/-/browser-utils-8.35.0.tgz#92602f8dd2bb777af2994eb446cb3cf71bf0cfad"
1687+
integrity sha512-uj9nwERm7HIS13f/Q52hF/NUS5Al8Ma6jkgpfYGeppYvU0uSjPkwMogtqoJQNbOoZg973tV8qUScbcWY616wNA==
1688+
dependencies:
1689+
"@sentry/core" "8.35.0"
1690+
"@sentry/types" "8.35.0"
1691+
"@sentry/utils" "8.35.0"
1692+
1693+
"@sentry-internal/feedback@8.35.0":
1694+
version "8.35.0"
1695+
resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-8.35.0.tgz#b31fb7fbec8ecd9cc683948a0d1af2b87731b0a1"
1696+
integrity sha512-7bjSaUhL0bDArozre6EiIhhdWdT/1AWNWBC1Wc5w1IxEi5xF7nvF/FfvjQYrONQzZAI3HRxc45J2qhLUzHBmoQ==
1697+
dependencies:
1698+
"@sentry/core" "8.35.0"
1699+
"@sentry/types" "8.35.0"
1700+
"@sentry/utils" "8.35.0"
1701+
1702+
"@sentry-internal/replay-canvas@8.35.0":
1703+
version "8.35.0"
1704+
resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-8.35.0.tgz#de7849e0d4212ee37a9225b1fc346188d9b05072"
1705+
integrity sha512-TUrH6Piv19kvHIiRyIuapLdnuwxk/Un/l1WDCQfq7mK9p1Pac0FkQ7Uufjp6zY3lyhDDZQ8qvCS4ioCMibCwQg==
1706+
dependencies:
1707+
"@sentry-internal/replay" "8.35.0"
1708+
"@sentry/core" "8.35.0"
1709+
"@sentry/types" "8.35.0"
1710+
"@sentry/utils" "8.35.0"
1711+
1712+
"@sentry-internal/replay@8.35.0":
1713+
version "8.35.0"
1714+
resolved "https://registry.yarnpkg.com/@sentry-internal/replay/-/replay-8.35.0.tgz#f71abae95cb492a54b43885386adbc5c639486c7"
1715+
integrity sha512-3wkW03vXYMyWtTLxl9yrtkV+qxbnKFgfASdoGWhXzfLjycgT6o4/04eb3Gn71q9aXqRwH17ISVQbVswnRqMcmA==
1716+
dependencies:
1717+
"@sentry-internal/browser-utils" "8.35.0"
1718+
"@sentry/core" "8.35.0"
1719+
"@sentry/types" "8.35.0"
1720+
"@sentry/utils" "8.35.0"
1721+
1722+
"@sentry/browser@8.35.0":
1723+
version "8.35.0"
1724+
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-8.35.0.tgz#67820951fd092ef72ee1a4897464bc7c8d317d77"
1725+
integrity sha512-WHfI+NoZzpCsmIvtr6ChOe7yWPLQyMchPnVhY3Z4UeC70bkYNdKcoj/4XZbX3m0D8+71JAsm0mJ9s9OC3Ue6MQ==
1726+
dependencies:
1727+
"@sentry-internal/browser-utils" "8.35.0"
1728+
"@sentry-internal/feedback" "8.35.0"
1729+
"@sentry-internal/replay" "8.35.0"
1730+
"@sentry-internal/replay-canvas" "8.35.0"
1731+
"@sentry/core" "8.35.0"
1732+
"@sentry/types" "8.35.0"
1733+
"@sentry/utils" "8.35.0"
1734+
1735+
"@sentry/core@8.35.0":
1736+
version "8.35.0"
1737+
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-8.35.0.tgz#17090f4d2d3bb983d9d99ecd2d27f4e9e107e0b0"
1738+
integrity sha512-Ci0Nmtw5ETWLqQJGY4dyF+iWh7PWKy6k303fCEoEmqj2czDrKJCp7yHBNV0XYbo00prj2ZTbCr6I7albYiyONA==
1739+
dependencies:
1740+
"@sentry/types" "8.35.0"
1741+
"@sentry/utils" "8.35.0"
1742+
1743+
"@sentry/react@^8.35.0":
1744+
version "8.35.0"
1745+
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-8.35.0.tgz#059e9a02717ed0eb96919ea76a52f315a370b2ba"
1746+
integrity sha512-8Y+s4pE9hvT2TwSo5JS/Enw2cNFlwiLcJDNGCj/Hho+FePFYA59hbN06ouTHWARnO+swANHKZQj24Wp57p1/tg==
1747+
dependencies:
1748+
"@sentry/browser" "8.35.0"
1749+
"@sentry/core" "8.35.0"
1750+
"@sentry/types" "8.35.0"
1751+
"@sentry/utils" "8.35.0"
1752+
hoist-non-react-statics "^3.3.2"
1753+
1754+
"@sentry/types@8.35.0":
1755+
version "8.35.0"
1756+
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-8.35.0.tgz#535c807800f7e378f61416f30177c0ef81b95012"
1757+
integrity sha512-AVEZjb16MlYPifiDDvJ19dPQyDn0jlrtC1PHs6ZKO+Rzyz+2EX2BRdszvanqArldexPoU1p5Bn2w81XZNXThBA==
1758+
1759+
"@sentry/utils@8.35.0":
1760+
version "8.35.0"
1761+
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-8.35.0.tgz#1e099fcbc60040091c79f028a83226c145d588ee"
1762+
integrity sha512-MdMb6+uXjqND7qIPWhulubpSeHzia6HtxeJa8jYI09OCvIcmNGPydv/Gx/LZBwosfMHrLdTWcFH7Y7aCxrq7cg==
1763+
dependencies:
1764+
"@sentry/types" "8.35.0"
1765+
16841766
"@surma/rollup-plugin-off-main-thread@^2.2.3":
16851767
version "2.2.3"
16861768
resolved "https://registry.yarnpkg.com/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz#ee34985952ca21558ab0d952f00298ad2190c053"
@@ -2867,6 +2949,13 @@ hasown@^2.0.0, hasown@^2.0.1, hasown@^2.0.2:
28672949
dependencies:
28682950
function-bind "^1.1.2"
28692951

2952+
hoist-non-react-statics@^3.3.2:
2953+
version "3.3.2"
2954+
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
2955+
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
2956+
dependencies:
2957+
react-is "^16.7.0"
2958+
28702959
html-encoding-sniffer@^4.0.0:
28712960
version "4.0.0"
28722961
resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz#696df529a7cfd82446369dc5193e590a3735b448"
@@ -3787,7 +3876,7 @@ react-fontpicker-ts@^1.0.0:
37873876
resolved "https://registry.yarnpkg.com/react-fontpicker-ts/-/react-fontpicker-ts-1.0.0.tgz#287008e5f243601e3dff30cce67853cf0fbb65b6"
37883877
integrity sha512-kJgdcorggEMhlDs4Ezaq75HoFHPd8VvbLBYrXP2L4UAszg/kNQBmo8RAW79whAX/VDg4ZixF4QeROA4oIagOaQ==
37893878

3790-
react-is@^16.13.1, react-is@^16.8.4:
3879+
react-is@^16.13.1, react-is@^16.7.0, react-is@^16.8.4:
37913880
version "16.13.1"
37923881
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
37933882
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

0 commit comments

Comments
 (0)