Add Sentry
This commit is contained in:
parent
9f4e036173
commit
774642d508
20
index.js
20
index.js
|
@ -4,6 +4,8 @@ import express from "express";
|
|||
import morgan from "morgan";
|
||||
import bodyParser from "body-parser";
|
||||
import createDOMPurify from "dompurify";
|
||||
import * as Sentry from "@sentry/node";
|
||||
import * as Tracing from "@sentry/tracing";
|
||||
|
||||
const app = express();
|
||||
app.use(morgan('combined'));
|
||||
|
@ -12,6 +14,20 @@ app.use(bodyParser.text({
|
|||
limit: '1mb',
|
||||
}));
|
||||
|
||||
if (process.env.SENTRY_DSN) {
|
||||
Sentry.init({
|
||||
dsn: process.env.SENTRY_DSN,
|
||||
integrations: [
|
||||
new Sentry.Integrations.Http({tracing: true}),
|
||||
new Tracing.Integrations.Express({app}),
|
||||
],
|
||||
tracesSampleRate: 0.2
|
||||
});
|
||||
|
||||
app.use(Sentry.Handlers.requestHandler());
|
||||
app.use(Sentry.Handlers.tracingHandler());
|
||||
}
|
||||
|
||||
app.get('/status', (req, res) => {
|
||||
res.type('text/plain').send('OK');
|
||||
});
|
||||
|
@ -27,6 +43,10 @@ app.post('/readability', (req, res) => {
|
|||
res.send(cleaned);
|
||||
});
|
||||
|
||||
if (process.env.SENTRY_DSN) {
|
||||
app.use(Sentry.Handlers.errorHandler());
|
||||
}
|
||||
|
||||
const port = process.env.PORT || 4001;
|
||||
// only accept local requests
|
||||
app.listen(port, "localhost", () => {
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mozilla/readability": "^0.4.1",
|
||||
"@sentry/node": "^6.14.1",
|
||||
"@sentry/tracing": "^6.14.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"dompurify": "^2.3.3",
|
||||
"express": "^4.17.1",
|
||||
|
@ -25,6 +27,109 @@
|
|||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sentry/core": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.14.1.tgz",
|
||||
"integrity": "sha512-x2MOax+adphal0ytBsvQukwN5mcxZzb5zsPZ1YWzewQk3BY+2T/DFo50iVpaWdUXsJL2FtoZVVgtpTmf+/3JPw==",
|
||||
"dependencies": {
|
||||
"@sentry/hub": "6.14.1",
|
||||
"@sentry/minimal": "6.14.1",
|
||||
"@sentry/types": "6.14.1",
|
||||
"@sentry/utils": "6.14.1",
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@sentry/hub": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.14.1.tgz",
|
||||
"integrity": "sha512-IqANj5qKG1N+nqBsuYIwAZsXDMmO/Sc4H2zZ2MP7QvRyp0ptpJmu1oTE0r0fohIcGgIWbnIphJjw990Lp507eA==",
|
||||
"dependencies": {
|
||||
"@sentry/types": "6.14.1",
|
||||
"@sentry/utils": "6.14.1",
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@sentry/minimal": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.14.1.tgz",
|
||||
"integrity": "sha512-rxS0YUggCSuA7EzS1ai5jU8XArk4FBHZ02gmSoSSLtwFXmeQIa9XBKY0OEFmG2LMQYNOpvcGsezDO51EB6/X9w==",
|
||||
"dependencies": {
|
||||
"@sentry/hub": "6.14.1",
|
||||
"@sentry/types": "6.14.1",
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@sentry/node": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/node/-/node-6.14.1.tgz",
|
||||
"integrity": "sha512-tnEfcaF5Z7I4D619XL76sjRd7VMDitZZ7ydfA8sWGC1BPaPyyIJzVxE/a7qJBQGW7W0Oo7ctwOI1hpmfyOpPxg==",
|
||||
"dependencies": {
|
||||
"@sentry/core": "6.14.1",
|
||||
"@sentry/hub": "6.14.1",
|
||||
"@sentry/tracing": "6.14.1",
|
||||
"@sentry/types": "6.14.1",
|
||||
"@sentry/utils": "6.14.1",
|
||||
"cookie": "^0.4.1",
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"lru_map": "^0.3.3",
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@sentry/node/node_modules/cookie": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
|
||||
"integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@sentry/tracing": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.14.1.tgz",
|
||||
"integrity": "sha512-Bv/+S5Wn9OPxP7sA9VYMV1wpmXWptFVIMFoG4BuyV4aFYdIAMxSNE/ktqXwmqn+nkBic04nP9rF6lMJBLIvIaA==",
|
||||
"dependencies": {
|
||||
"@sentry/hub": "6.14.1",
|
||||
"@sentry/minimal": "6.14.1",
|
||||
"@sentry/types": "6.14.1",
|
||||
"@sentry/utils": "6.14.1",
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@sentry/types": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.14.1.tgz",
|
||||
"integrity": "sha512-RIk3ZwQKZnASrYWfV5i4wbzVveHz8xLFAS2ySIMqh+hICKnB0N4/r8a1Of/84j7pj+iAbf5vPS85639eIf+9qg==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@sentry/utils": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.14.1.tgz",
|
||||
"integrity": "sha512-GVvf0z18L4DN0a6vIBdHSlrK/Dj8QFhuiiJ8NtccSoY8xiKXQNz9FKN5d52NUNqm59aopAxcVAcs57yQSdxrZQ==",
|
||||
"dependencies": {
|
||||
"@sentry/types": "6.14.1",
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@tootallnate/once": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
|
||||
|
@ -647,6 +752,11 @@
|
|||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/lru_map": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz",
|
||||
"integrity": "sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0="
|
||||
},
|
||||
"node_modules/media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
|
@ -1014,6 +1124,11 @@
|
|||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
|
||||
|
@ -1175,6 +1290,87 @@
|
|||
"resolved": "https://registry.npmjs.org/@mozilla/readability/-/readability-0.4.1.tgz",
|
||||
"integrity": "sha512-yar/f0w0fRUVM895s6yd5Z2oIxjG/6c3ROB/uQboSOBaDlri/nqI4aKtdqrldWciTLcdpjB2Z6MiVF2Bl9b8LA=="
|
||||
},
|
||||
"@sentry/core": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.14.1.tgz",
|
||||
"integrity": "sha512-x2MOax+adphal0ytBsvQukwN5mcxZzb5zsPZ1YWzewQk3BY+2T/DFo50iVpaWdUXsJL2FtoZVVgtpTmf+/3JPw==",
|
||||
"requires": {
|
||||
"@sentry/hub": "6.14.1",
|
||||
"@sentry/minimal": "6.14.1",
|
||||
"@sentry/types": "6.14.1",
|
||||
"@sentry/utils": "6.14.1",
|
||||
"tslib": "^1.9.3"
|
||||
}
|
||||
},
|
||||
"@sentry/hub": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.14.1.tgz",
|
||||
"integrity": "sha512-IqANj5qKG1N+nqBsuYIwAZsXDMmO/Sc4H2zZ2MP7QvRyp0ptpJmu1oTE0r0fohIcGgIWbnIphJjw990Lp507eA==",
|
||||
"requires": {
|
||||
"@sentry/types": "6.14.1",
|
||||
"@sentry/utils": "6.14.1",
|
||||
"tslib": "^1.9.3"
|
||||
}
|
||||
},
|
||||
"@sentry/minimal": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.14.1.tgz",
|
||||
"integrity": "sha512-rxS0YUggCSuA7EzS1ai5jU8XArk4FBHZ02gmSoSSLtwFXmeQIa9XBKY0OEFmG2LMQYNOpvcGsezDO51EB6/X9w==",
|
||||
"requires": {
|
||||
"@sentry/hub": "6.14.1",
|
||||
"@sentry/types": "6.14.1",
|
||||
"tslib": "^1.9.3"
|
||||
}
|
||||
},
|
||||
"@sentry/node": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/node/-/node-6.14.1.tgz",
|
||||
"integrity": "sha512-tnEfcaF5Z7I4D619XL76sjRd7VMDitZZ7ydfA8sWGC1BPaPyyIJzVxE/a7qJBQGW7W0Oo7ctwOI1hpmfyOpPxg==",
|
||||
"requires": {
|
||||
"@sentry/core": "6.14.1",
|
||||
"@sentry/hub": "6.14.1",
|
||||
"@sentry/tracing": "6.14.1",
|
||||
"@sentry/types": "6.14.1",
|
||||
"@sentry/utils": "6.14.1",
|
||||
"cookie": "^0.4.1",
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"lru_map": "^0.3.3",
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"cookie": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
|
||||
"integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@sentry/tracing": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.14.1.tgz",
|
||||
"integrity": "sha512-Bv/+S5Wn9OPxP7sA9VYMV1wpmXWptFVIMFoG4BuyV4aFYdIAMxSNE/ktqXwmqn+nkBic04nP9rF6lMJBLIvIaA==",
|
||||
"requires": {
|
||||
"@sentry/hub": "6.14.1",
|
||||
"@sentry/minimal": "6.14.1",
|
||||
"@sentry/types": "6.14.1",
|
||||
"@sentry/utils": "6.14.1",
|
||||
"tslib": "^1.9.3"
|
||||
}
|
||||
},
|
||||
"@sentry/types": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.14.1.tgz",
|
||||
"integrity": "sha512-RIk3ZwQKZnASrYWfV5i4wbzVveHz8xLFAS2ySIMqh+hICKnB0N4/r8a1Of/84j7pj+iAbf5vPS85639eIf+9qg=="
|
||||
},
|
||||
"@sentry/utils": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.14.1.tgz",
|
||||
"integrity": "sha512-GVvf0z18L4DN0a6vIBdHSlrK/Dj8QFhuiiJ8NtccSoY8xiKXQNz9FKN5d52NUNqm59aopAxcVAcs57yQSdxrZQ==",
|
||||
"requires": {
|
||||
"@sentry/types": "6.14.1",
|
||||
"tslib": "^1.9.3"
|
||||
}
|
||||
},
|
||||
"@tootallnate/once": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
|
||||
|
@ -1661,6 +1857,11 @@
|
|||
"type-check": "~0.3.2"
|
||||
}
|
||||
},
|
||||
"lru_map": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz",
|
||||
"integrity": "sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0="
|
||||
},
|
||||
"media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
|
@ -1952,6 +2153,11 @@
|
|||
"punycode": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
|
||||
},
|
||||
"type-check": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mozilla/readability": "^0.4.1",
|
||||
"@sentry/node": "^6.14.1",
|
||||
"@sentry/tracing": "^6.14.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"dompurify": "^2.3.3",
|
||||
"express": "^4.17.1",
|
||||
|
|
Loading…
Reference in New Issue