Skip to content

Commit

Permalink
Rollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoverna committed Dec 20, 2024
1 parent 3366c08 commit 7e88892
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
26 changes: 25 additions & 1 deletion astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,31 @@ export default defineConfig({
devToolbar: {
enabled: false,
},
integrations: [react(), expressiveCode()],
integrations: [
react(),
expressiveCode(),
{
name: 'rollbar',
hooks: {
'astro:config:setup': async ({ injectScript }) => {
injectScript(
'page-ssr',
`
import Rollbar from 'rollbar';
import { DEPLOYMENT_DESTINATION, ROLLBAR_TOKEN } from 'astro:env/server';
new Rollbar({
accessToken: ROLLBAR_TOKEN,
captureUncaught: true,
captureUnhandledRejections: true,
environment: DEPLOYMENT_DESTINATION,
});
`,
);
},
},
},
],
// This project does not use static markdown, only remote. See our <Markdown /> component
markdown: {},
vite: {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/logToRollbar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ROLLBAR_TOKEN } from 'astro:env/server';
import { DEPLOYMENT_DESTINATION, ROLLBAR_TOKEN } from 'astro:env/server';
import Rollbar from 'rollbar';

const rollbar = new Rollbar({ accessToken: ROLLBAR_TOKEN });
const rollbar = new Rollbar({ accessToken: ROLLBAR_TOKEN, environment: DEPLOYMENT_DESTINATION });

type Options = {
request?: Request;
Expand Down

0 comments on commit 7e88892

Please sign in to comment.