From 621272c842626baef9c6f5174d1897c485879d37 Mon Sep 17 00:00:00 2001 From: spiral Date: Thu, 7 Apr 2022 07:26:52 -0400 Subject: [PATCH] feat: add Sentry and Plausible integrations --- index.html | 3 ++- package.json | 2 ++ src/api/index.ts | 8 +++++- src/main.ts | 16 ++++++++++++ yarn.lock | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index ddd50aad..a82a2d15 100644 --- a/index.html +++ b/index.html @@ -31,8 +31,9 @@ ); } }(window.location)) - + +
diff --git a/package.json b/package.json index 7c1c9ea4..aac54545 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "vite": "^2.7.0" }, "dependencies": { + "@sentry/browser": "^6.19.5", + "@sentry/tracing": "^6.19.5", "@types/twemoji": "^12.1.2", "axios": "^0.24.0", "discord-markdown": "^2.5.1", diff --git a/src/api/index.ts b/src/api/index.ts index d63bd690..260bb0b2 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,4 +1,5 @@ import axios from 'axios'; +import * as Sentry from '@sentry/browser'; const baseUrl = () => localStorage.isBeta ? "https://api.beta.pluralkit.me" : "https://api.pluralkit.me"; @@ -9,7 +10,12 @@ const scheduled = []; const runAPI = () => { if (scheduled.length == 0) return; const {axiosData, res, rej} = scheduled.shift(); - axios(axiosData).then((resp) => res(parseData(resp.status, resp.data))).catch(rej); + axios(axiosData) + .then((resp) => res(parseData(resp.status, resp.data))) + .catch((err) => { + Sentry.captureException("Fetch error", err); + rej(err); + }); } setInterval(runAPI, 500); diff --git a/src/main.ts b/src/main.ts index d8200ac4..77475248 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,19 @@ +import * as Sentry from "@sentry/browser"; +import { Integrations } from "@sentry/tracing"; + +Sentry.init({ + dsn: "https://58109fec589f4c2bbfa190329acf679a@sentry.pluralkit.me/4", + integrations: [new Integrations.BrowserTracing()], + + enabled: true, + debug: false, + release: "dev", + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + tracesSampleRate: 1.0, +}); + import App from './App.svelte' const app = new App({ diff --git a/yarn.lock b/yarn.lock index 988ec05f..60141f29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -36,6 +36,69 @@ estree-walker "^2.0.1" picomatch "^2.2.2" +"@sentry/browser@^6.19.5": + version "6.19.5" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.19.5.tgz#77d4c860ab86f89a41d4b15a8eafb42417c47888" + integrity sha512-dmk15tTm9J+6v/N8nSoc7dUnpS/EJdwfOd3YSRk2iaJLJkWvJ7ELRe5SnH4MnK89Qpw7FKC5OjB977TeK11QAA== + dependencies: + "@sentry/core" "6.19.5" + "@sentry/types" "6.19.5" + "@sentry/utils" "6.19.5" + tslib "^1.9.3" + +"@sentry/core@6.19.5": + version "6.19.5" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.19.5.tgz#b8e0d54a22f588f8cbe2740913b8d06ec76fb1bb" + integrity sha512-PSrJYdhti5IWBo+1hLn4olRPQXJxsnkrB5X7Wk2peEYKGk6Vx98B9h7lQ4Tgsg9sUUOH4HsmNwU2kZKtMRVB5Q== + dependencies: + "@sentry/hub" "6.19.5" + "@sentry/minimal" "6.19.5" + "@sentry/types" "6.19.5" + "@sentry/utils" "6.19.5" + tslib "^1.9.3" + +"@sentry/hub@6.19.5": + version "6.19.5" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.19.5.tgz#978849b003ff130225540355fddfdc3feb4fc7a8" + integrity sha512-aMpsQFOcsdkfjbruIretxetmU+XbQNrheaFHJSOt1hB4LZr1fU4M29wKkK5Hj5ELiaNcC23u+0G7y5Nizwzsnw== + dependencies: + "@sentry/types" "6.19.5" + "@sentry/utils" "6.19.5" + tslib "^1.9.3" + +"@sentry/minimal@6.19.5": + version "6.19.5" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.19.5.tgz#a1b08eadde9e77e063346d5f3170a58aa1da0916" + integrity sha512-zcYGEuqPbLo1gHeYHalna7rNPZIA6+U9dPCDgQpM2GgIGhAxJxvyx57ducatxRQgdPtljn5/VPDxdACiwoc+Jg== + dependencies: + "@sentry/hub" "6.19.5" + "@sentry/types" "6.19.5" + tslib "^1.9.3" + +"@sentry/tracing@^6.19.5": + version "6.19.5" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.19.5.tgz#dfce99842768ff7bde73d1368a848b72e83a734b" + integrity sha512-8jozVkPMj3I7emgmKWCRr0DvblZHwJ2SS5qCAA5gmKo6uNTVwwe6Sh1ovETJ/rrZ72YGfpeC/yYBcNpst8I+iQ== + dependencies: + "@sentry/hub" "6.19.5" + "@sentry/minimal" "6.19.5" + "@sentry/types" "6.19.5" + "@sentry/utils" "6.19.5" + tslib "^1.9.3" + +"@sentry/types@6.19.5": + version "6.19.5" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.19.5.tgz#628e76351209a5e4fcaa94bcbe56fe788d65ea15" + integrity sha512-G5bGj0ZXRPDrEAxuNO6Jyeq/OG6v9msoE9C/xy1r6JMvVTxX000TmLGKjK1NqqrBbVWdcyFbT3jhJgae0uyBVA== + +"@sentry/utils@6.19.5": + version "6.19.5" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.19.5.tgz#507312fff2f7332debc8e54240e3b5c6d94db768" + integrity sha512-VuNraZZzEu/qVI11CMiRcSa+JVNwOuUe4HfZrDmnJbfrTpbQgjAdScnekEHLaGILGm8lQ8M2qeOxqfNF6kRn9w== + dependencies: + "@sentry/types" "6.19.5" + tslib "^1.9.3" + "@sveltejs/vite-plugin-svelte@^1.0.0-next.30": version "1.0.0-next.31" resolved "https://registry.yarnpkg.com/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-1.0.0-next.31.tgz#5d0d5445ed85a1af613224eacff78c69f14c7fad" @@ -1072,6 +1135,11 @@ trim-repeated@^1.0.0: dependencies: escape-string-regexp "^1.0.2" +tslib@^1.9.3: + version "1.14.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" + integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== + tslib@^2.0.3, tslib@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"