You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
nodejs
To obtain Authorization for the Sentry API, you can do this by following these steps:
Log in to Sentry: Log in to your Sentry account and go to the Sentry console.
Create a new API key: In the Sentry console, click the user avatar in the upper right corner and select "API".
Generate an API Key: Click the "New API Key" button to create a new API key.
import Koa from 'koa'
import fetch from 'node-fetch'
import https from 'https';
const app = new Koa();
const host = 'xxx.sunyur.com';
const knownProjectIds = [2];
const agent = new https.Agent({
rejectUnauthorized: false
});
app.use(async (ctx) => {
const envelope = await new Promise((resolve) => {
const chunks = [];
ctx.req.on('data', (chunk) => chunks.push(chunk));
ctx.req.on('end', () => resolve(Buffer.concat(chunks).toString()));
});
const pieces = envelope.split('\n', 2);
const header = JSON.parse(pieces[0]);
if (header.dsn) {
const dsn = new URL(header.dsn);
const projectId = parseInt(dsn.pathname.replace('/', ''), 10);
console.log('envelope', ctx.headers);
if (knownProjectIds.includes(projectId)) {
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/x-sentry-envelope',
'Authorization':
Bearer token
},
body: envelope,
agent
};
}
});
app.listen(3001, () => {
console.log('Server is running on port 3001');
});
Beta Was this translation helpful? Give feedback.
All reactions