Skip to content

Commit b6711ea

Browse files
committed
feat(sdk): instrument transaction on validateGeneratedFile
1 parent 913919b commit b6711ea

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

server/src/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ try {
1515
console.error('Missing config.json; see README');
1616
}
1717

18-
if (config.SENTRY_DSN) {
19-
Sentry.init({ dsn: config.SENTRY_DSN });
18+
if (!config.SENTRY_DSN) {
19+
throw new Error('SENTRY_DSN was not set in config.json');
2020
}
2121

22+
Sentry.init({ dsn: config.SENTRY_DSN });
23+
2224
const storage = new Storage({
2325
projectId: config.PROJECT
2426
});
@@ -30,14 +32,21 @@ const storage = new Storage({
3032
* @param {function} The callback function.
3133
*/
3234
export function validateGeneratedFile(req: Request, res: Response) {
35+
const transaction = Sentry.startTransaction({
36+
name: 'validateGeneratedFile'
37+
});
3338
res.set('Access-Control-Allow-Origin', '*');
3439
res.set('Access-Control-Allow-Methods', 'POST');
3540

3641
const url = req.query.url;
3742
if (!url) {
3843
res.status(500).send('URL not specified');
44+
transaction.finish();
45+
return;
3946
}
4047

48+
transaction.setTag('sourcemap_url', url);
49+
4150
_validateGeneratedFile(url, report => {
4251
const bucket = storage.bucket(config.STORAGE_BUCKET);
4352

@@ -59,5 +68,6 @@ export function validateGeneratedFile(req: Request, res: Response) {
5968
});
6069

6170
stream.end(JSON.stringify(report));
71+
transaction.finish();
6272
});
6373
}

0 commit comments

Comments
 (0)