Skip to content

Commit

Permalink
Add Sentry error monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhobbs committed Sep 11, 2024
1 parent 0832125 commit 15d92eb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
7 changes: 6 additions & 1 deletion action-src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import setup from '../node-src/errorMonitoring';
setup('action');

import { error, getInput, getMultilineInput, setFailed, setOutput } from '@actions/core';
import { context } from '@actions/github';
import * as Sentry from '@sentry/node';
import path from 'path';

import { run as runNode } from '../node-src';
Expand Down Expand Up @@ -200,7 +204,8 @@ async function run() {
process.exit(1);
}
}

run().catch((e) => {
error(e);
setFailed(e.message);
});
}).finally(() => Sentry.flush(1000));
13 changes: 10 additions & 3 deletions bin-src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import setup from '../node-src/errorMonitoring';
setup('cli');

import { run } from '../node-src';
import * as Sentry from '@sentry/node';

export async function main(argv: string[]) {
const { code } = await run({ argv });

process.exit(code);
try {
const { code } = await run({ argv });
process.exitCode = code;
} finally {
await Sentry.flush(1000);
}
}
12 changes: 12 additions & 0 deletions node-src/errorMonitoring.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Sentry from '@sentry/node';

export default (environment: string) => {
Sentry.init({
dsn: 'https://4fa173db2ef3fb073b8ea153a5466d28@o4504181686599680.ingest.us.sentry.io/4507930289373184',
sampleRate: 1.0,
environment,
enabled: process.env.DISABLE_ERROR_MONITORING !== 'true',
enableTracing: false,
integrations: [],
});
}

0 comments on commit 15d92eb

Please sign in to comment.