Skip to content

Commit

Permalink
feat: setup sentry (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradel authored May 19, 2024
1 parent 02dbbd4 commit 0e49bd1
Show file tree
Hide file tree
Showing 13 changed files with 1,960 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-planets-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stackspulse": patch
---

Setup sentry monitoring.
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NEXT_TELEMETRY_DISABLED=1
NEXT_PUBLIC_BASE_URL=https://stackspulse.com
NEXT_PUBLIC_FATHOM_ID=LBVAPCKU
NEXT_PUBLIC_SENTRY_DSN=https://[email protected]/4507282761187328
1 change: 0 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ github.ref == 'refs/heads/main' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ sqlite.db-*

# Chainhooks
chainhooks.production.json

# Sentry Config File
.env.sentry-build-plugin
9 changes: 8 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { withSentryConfig } from "@sentry/nextjs";

/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
};

export default nextConfig;
export default withSentryConfig(nextConfig, {
silent: !process.env.CI,
widenClientFileUpload: true,
disableLogger: true,
automaticVercelMonitors: true,
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"@dotenvx/dotenvx": "0.40.0",
"@radix-ui/themes": "3.0.5",
"@sentry/nextjs": "8.2.1",
"@stacks/transactions": "6.15.0",
"@t3-oss/env-core": "0.10.1",
"@t3-oss/env-nextjs": "0.10.1",
Expand Down
1,917 changes: 1,890 additions & 27 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions sentry.client.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { env } from "@/env";
import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: env.NEXT_PUBLIC_SENTRY_DSN,
debug: false,
});
7 changes: 7 additions & 0 deletions sentry.edge.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { env } from "@/env";
import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: env.NEXT_PUBLIC_SENTRY_DSN,
debug: false,
});
8 changes: 8 additions & 0 deletions sentry.server.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { env } from "@/env";
import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: env.NEXT_PUBLIC_SENTRY_DSN,
debug: false,
spotlight: process.env.NODE_ENV === "development",
});
19 changes: 19 additions & 0 deletions src/app/global-error.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client";

import * as Sentry from "@sentry/nextjs";
import Error from "next/error";
import { useEffect } from "react";

export default function GlobalError({ error }) {
useEffect(() => {
Sentry.captureException(error);
}, [error]);

return (
<html>
<body>
<Error />
</body>
</html>
);
}
2 changes: 2 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export const env = createEnv({
client: {
NEXT_PUBLIC_BASE_URL: z.string().min(1),
NEXT_PUBLIC_FATHOM_ID: z.string().optional(),
NEXT_PUBLIC_SENTRY_DSN: z.string().optional(),
},
experimental__runtimeEnv: {
NEXT_PUBLIC_BASE_URL: process.env.NEXT_PUBLIC_BASE_URL,
NEXT_PUBLIC_FATHOM_ID: process.env.NEXT_PUBLIC_FATHOM_ID,
NEXT_PUBLIC_SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN,
},
});
9 changes: 9 additions & 0 deletions src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("../sentry.server.config");
}

if (process.env.NEXT_RUNTIME === "edge") {
await import("../sentry.edge.config");
}
}

0 comments on commit 0e49bd1

Please sign in to comment.