Add sentry

This commit is contained in:
dangered wolf 2022-08-04 16:41:42 -04:00
parent e566406490
commit 92eae7b2be
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
6 changed files with 164 additions and 31 deletions

View file

@ -4,4 +4,5 @@ DIRECT_MEDIA_DOMAINS = "d.fxtwitter.com,dl.fxtwitter.com,d.pxtwitter.com,d.twitt
MOSAIC_DOMAIN_LIST = "mosaic.fxtwitter.com"
API_HOST = "api.fxtwitter.com"
HOST_URL = "https://fxtwitter.com"
REDIRECT_URL = "https://github.com/dangeredwolf/FixTweet"
REDIRECT_URL = "https://github.com/dangeredwolf/FixTweet"
SENTRY_DSN = "https://example@aaaa.ingest.sentry.io/69"

140
package-lock.json generated
View file

@ -9,6 +9,8 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@sentry/browser": "^7.8.1",
"@sentry/tracing": "^7.8.1",
"itty-router": "^2.6.1"
},
"devDependencies": {
@ -468,6 +470,81 @@
"node": ">= 8"
}
},
"node_modules/@sentry/browser": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.8.1.tgz",
"integrity": "sha512-9JuagYqHyaZu/4RqyxrAgEHo71oV592XBuUKC33gajCVKWbyG3mNqudSMoHtdM1DrV9REZ4Elha7zFaE2cJX6g==",
"dependencies": {
"@sentry/core": "7.8.1",
"@sentry/types": "7.8.1",
"@sentry/utils": "7.8.1",
"tslib": "^1.9.3"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@sentry/core": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.8.1.tgz",
"integrity": "sha512-PRivbdIzApi/gSixAxozhOBTylSVdw/9VxaStYHd7JJGhs36KXkV8ylpbCmYO4ap7/Ue9/slzwpvPOJJzmzAgA==",
"dependencies": {
"@sentry/hub": "7.8.1",
"@sentry/types": "7.8.1",
"@sentry/utils": "7.8.1",
"tslib": "^1.9.3"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@sentry/hub": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-7.8.1.tgz",
"integrity": "sha512-AxwyGyS9Lp4XsURu4t8opa5vZ+NAB6I/n+B/Uix3YZea9z8jdWYAu9vsXSizOrtxekc/i7ZN4bnlNgXVHix0iA==",
"dependencies": {
"@sentry/types": "7.8.1",
"@sentry/utils": "7.8.1",
"tslib": "^1.9.3"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@sentry/tracing": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-7.8.1.tgz",
"integrity": "sha512-orNVCsMtQUKhvh7GmyJzjOhU6oT7lC7TRT7tTRlyXQVrUmfJZsthmBtyfrTC7QWJ9vXQ0mB4jab8kMT3xE4ltg==",
"dependencies": {
"@sentry/hub": "7.8.1",
"@sentry/types": "7.8.1",
"@sentry/utils": "7.8.1",
"tslib": "^1.9.3"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@sentry/types": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.8.1.tgz",
"integrity": "sha512-LOoaeBXVI23Kh5SpIbxSRiJ6+eYZXVOFyPFH1T1mGBj95LPwRMqOdg0lUTmFJGBKbDGDB/YNjNnu1kQ7GrXBXw==",
"engines": {
"node": ">=8"
}
},
"node_modules/@sentry/utils": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.8.1.tgz",
"integrity": "sha512-isUZjft4HWTOk1Z58KFJ/zzXeFtIJgP82CkYQlW464ZR2WCqPHYlXXXRWZpOHOfMnrf+gWeX9WAGS9rTAdhiSg==",
"dependencies": {
"@sentry/types": "7.8.1",
"tslib": "^1.9.3"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@types/eslint": {
"version": "8.4.5",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.5.tgz",
@ -3547,8 +3624,7 @@
"node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
},
"node_modules/tsutils": {
"version": "3.21.0",
@ -4288,6 +4364,63 @@
"fastq": "^1.6.0"
}
},
"@sentry/browser": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.8.1.tgz",
"integrity": "sha512-9JuagYqHyaZu/4RqyxrAgEHo71oV592XBuUKC33gajCVKWbyG3mNqudSMoHtdM1DrV9REZ4Elha7zFaE2cJX6g==",
"requires": {
"@sentry/core": "7.8.1",
"@sentry/types": "7.8.1",
"@sentry/utils": "7.8.1",
"tslib": "^1.9.3"
}
},
"@sentry/core": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.8.1.tgz",
"integrity": "sha512-PRivbdIzApi/gSixAxozhOBTylSVdw/9VxaStYHd7JJGhs36KXkV8ylpbCmYO4ap7/Ue9/slzwpvPOJJzmzAgA==",
"requires": {
"@sentry/hub": "7.8.1",
"@sentry/types": "7.8.1",
"@sentry/utils": "7.8.1",
"tslib": "^1.9.3"
}
},
"@sentry/hub": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-7.8.1.tgz",
"integrity": "sha512-AxwyGyS9Lp4XsURu4t8opa5vZ+NAB6I/n+B/Uix3YZea9z8jdWYAu9vsXSizOrtxekc/i7ZN4bnlNgXVHix0iA==",
"requires": {
"@sentry/types": "7.8.1",
"@sentry/utils": "7.8.1",
"tslib": "^1.9.3"
}
},
"@sentry/tracing": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-7.8.1.tgz",
"integrity": "sha512-orNVCsMtQUKhvh7GmyJzjOhU6oT7lC7TRT7tTRlyXQVrUmfJZsthmBtyfrTC7QWJ9vXQ0mB4jab8kMT3xE4ltg==",
"requires": {
"@sentry/hub": "7.8.1",
"@sentry/types": "7.8.1",
"@sentry/utils": "7.8.1",
"tslib": "^1.9.3"
}
},
"@sentry/types": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.8.1.tgz",
"integrity": "sha512-LOoaeBXVI23Kh5SpIbxSRiJ6+eYZXVOFyPFH1T1mGBj95LPwRMqOdg0lUTmFJGBKbDGDB/YNjNnu1kQ7GrXBXw=="
},
"@sentry/utils": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.8.1.tgz",
"integrity": "sha512-isUZjft4HWTOk1Z58KFJ/zzXeFtIJgP82CkYQlW464ZR2WCqPHYlXXXRWZpOHOfMnrf+gWeX9WAGS9rTAdhiSg==",
"requires": {
"@sentry/types": "7.8.1",
"tslib": "^1.9.3"
}
},
"@types/eslint": {
"version": "8.4.5",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.5.tgz",
@ -6447,8 +6580,7 @@
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
},
"tsutils": {
"version": "3.21.0",

View file

@ -35,6 +35,8 @@
"wrangler": "^2.0.23"
},
"dependencies": {
"@sentry/browser": "^7.8.1",
"@sentry/tracing": "^7.8.1",
"itty-router": "^2.6.1"
}
}

2
src/env.d.ts vendored
View file

@ -6,4 +6,4 @@ declare const REDIRECT_URL: string;
declare const MOSAIC_DOMAIN_LIST: string;
declare const API_HOST: string;
declare const EXCEPTION_DISCORD_WEBHOOK: string;
declare const SENTRY_DSN: string;

View file

@ -1,3 +1,6 @@
import * as Sentry from "@sentry/browser";
import { Integrations } from "@sentry/tracing";
import { Router } from 'itty-router';
import { Constants } from './constants';
import { handleStatus } from './status';
@ -218,30 +221,22 @@ const cacheWrapper = async (event: FetchEvent): Promise<Response> => {
Event to receive web requests on Cloudflare Worker
*/
addEventListener('fetch', (event: FetchEvent) => {
try {
event.respondWith(cacheWrapper(event));
} catch (e: unknown) {
const error = e as Error;
if (typeof EXCEPTION_DISCORD_WEBHOOK !== 'undefined') {
try {
fetch(EXCEPTION_DISCORD_WEBHOOK, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'User-Agent': `${Constants.BRANDING_NAME}`
},
body: JSON.stringify({
embeds: [
{
title: `Exception in ${Constants.BRANDING_NAME}`,
description: `${error} - occurred while processing ${event.request.url}`,
}
]
})
});
} catch (e) {
console.log('Failed to send caught exception to Discord', e);
}
}
if (typeof SENTRY_DSN !== 'undefined') {
Sentry.init({
dsn: SENTRY_DSN,
debug: true,
integrations: [new Integrations.BrowserTracing()],
tracesSampleRate: 1.0,
});
console.log('Sentry initialized')
} else {
console.log('Sentry DSN not defined');
}
try {
throw "hi"
} catch (e: unknown) {
Sentry.captureException(e);
}
event.respondWith(cacheWrapper(event));
});

View file

@ -37,6 +37,9 @@ module.exports = {
}),
new webpack.DefinePlugin({
API_HOST: `'${process.env.API_HOST}'`
}),
new webpack.DefinePlugin({
SENTRY_DSN: `'${process.env.SENTRY_DSN}'`
})
],
optimization: {