Skip to content

Commit

Permalink
Add Sentry for error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mglaman committed Nov 23, 2023
1 parent 1e7b56b commit 648a33f
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 1 deletion.
13 changes: 13 additions & 0 deletions playground-api/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import {PromiseResult} from 'aws-sdk/lib/request';
import middy from 'middy';
import { cors } from 'middy/middlewares';
import { v4 as uuid } from 'uuid';
import * as Sentry from "@sentry/node";

Sentry.init({
dsn: "https://eb2a3a58974934df33e68af214e70607@o4505060230627328.ingest.sentry.io/4506276580818944",

// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
});

interface HttpRequest {
body: string;
Expand Down Expand Up @@ -239,6 +248,7 @@ async function analyseResult(request: HttpRequest): Promise<HttpResponse> {
});
} catch (e) {
console.error(e);
Sentry.captureException(e);
return Promise.resolve({statusCode: 500});
}
}
Expand Down Expand Up @@ -358,6 +368,7 @@ async function retrieveResult(request: HttpRequest): Promise<HttpResponse> {
});
} catch (e) {
console.error(e);
Sentry.captureException(e);
return Promise.resolve({statusCode: 500});
}
}
Expand Down Expand Up @@ -396,6 +407,7 @@ async function retrieveSample(request: HttpRequest): Promise<HttpResponse> {
});
} catch (e) {
console.error(e);
Sentry.captureException(e);
return Promise.resolve({statusCode: 500});
}
}
Expand Down Expand Up @@ -443,6 +455,7 @@ async function retrieveLegacyResult(request: HttpRequest): Promise<HttpResponse>
});
} catch (e) {
console.error(e);
Sentry.captureException(e);
return Promise.resolve({statusCode: 500});
}
}
Expand Down
6 changes: 6 additions & 0 deletions playground-runner/analyze.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
error_reporting(E_ALL);
ini_set('display_errors', '1');

\Sentry\init([
'dsn' => 'https://eb2a3a58974934df33e68af214e70607@o4505060230627328.ingest.sentry.io/4506276580818944',
'traces_sample_rate' => 1.0,
'profiles_sample_rate' => 1.0,
]);

$phpstanVersion = InstalledVersions::getPrettyVersion('phpstan/phpstan');
$phpstanDrupalVersion = InstalledVersions::getPrettyVersion('mglaman/phpstan-drupal');
// @note: we use the constant here, because analysis fails for _some reason_ unless the class is loaded ahead of time.
Expand Down
1 change: 1 addition & 0 deletions playground-runner/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"mglaman/phpstan-drupal": "^1.2.0",
"nette/di": "^3",
"nette/neon": "^3.3",
"sentry/sentry": "^4.0",
"symfony/console": "^6.2"
},
"minimum-stability": "dev",
Expand Down
215 changes: 214 additions & 1 deletion playground-runner/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 648a33f

Please sign in to comment.