refactoring pt.1
Some checks failed
Build and Push to Docker Hub / Push Docker image to Docker Hub (push) Has been cancelled
Build and Push Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
nicholai 2025-09-09 11:24:28 -06:00
parent eaa6c3b8e3
commit 56271841f8
390 changed files with 78653 additions and 8836 deletions

128
.clinerules/sentryrules.md Normal file
View File

@ -0,0 +1,128 @@
These examples should be used as guidance when configuring Sentry functionality within a project.
# Exception Catching
Use `Sentry.captureException(error)` to capture an exception and log the error in Sentry.
Use this in try catch blocks or areas where exceptions are expected
# Tracing Examples
Spans should be created for meaningful actions within an applications like button clicks, API calls, and function calls
Use the `Sentry.startSpan` function to create a span
Child spans can exist within a parent span
## Custom Span instrumentation in component actions
The `name` and `op` properties should be meaninful for the activities in the call.
Attach attributes based on relevant information and metrics from the request
```javascript
function TestComponent() {
const handleTestButtonClick = () => {
// Create a transaction/span to measure performance
Sentry.startSpan(
{
op: "ui.click",
name: "Test Button Click",
},
(span) => {
const value = "some config";
const metric = "some metric";
// Metrics can be added to the span
span.setAttribute("config", value);
span.setAttribute("metric", metric);
doSomething();
},
);
};
return (
<button type="button" onClick={handleTestButtonClick}>
Test Sentry
</button>
);
}
```
## Custom span instrumentation in API calls
The `name` and `op` properties should be meaninful for the activities in the call.
Attach attributes based on relevant information and metrics from the request
```javascript
async function fetchUserData(userId) {
return Sentry.startSpan(
{
op: "http.client",
name: `GET /api/users/${userId}`,
},
async () => {
const response = await fetch(`/api/users/${userId}`);
const data = await response.json();
return data;
},
);
}
```
# Logs
Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/nextjs"`
Enable logging in Sentry using `Sentry.init({ _experiments: { enableLogs: true } })`
Reference the logger using `const { logger } = Sentry`
Sentry offers a consoleLoggingIntegration that can be used to log specific console error types automatically without instrumenting the individual logger calls
## Configuration
In NextJS the client side Sentry initialization is in `instrumentation-client.ts`, the server initialization is in `sentry.edge.config.ts` and the edge initialization is in `sentry.server.config.ts`
Initialization does not need to be repeated in other files, it only needs to happen the files mentioned above. You should use `import * as Sentry from "@sentry/nextjs"` to reference Sentry functionality
### Baseline
```javascript
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: "https://e1805fb820448d9a2633170f0a8aaef4@o4509987417817088.ingest.us.sentry.io/4509987418800128",
_experiments: {
enableLogs: true,
},
});
```
### Logger Integration
```javascript
Sentry.init({
dsn: "https://e1805fb820448d9a2633170f0a8aaef4@o4509987417817088.ingest.us.sentry.io/4509987418800128",
integrations: [
// send console.log, console.warn, and console.error calls as logs to Sentry
Sentry.consoleLoggingIntegration({ levels: ["log", "warn", "error"] }),
],
});
```
## Logger Examples
`logger.fmt` is a template literal function that should be used to bring variables into the structured logs.
```javascript
logger.trace("Starting database connection", { database: "users" });
logger.debug(logger.fmt`Cache miss for user: ${userId}`);
logger.info("Updated profile", { profileId: 345 });
logger.warn("Rate limit reached for endpoint", {
endpoint: "/api/results/",
isEnterprise: false,
});
logger.error("Failed to process payment", {
orderId: "order_123",
amount: 99.99,
});
logger.fatal("Database connection pool exhausted", {
database: "users",
activeConnections: 100,
});
```

3
.gitignore vendored
View File

@ -3,3 +3,6 @@ node_modules
.env
/generated/prisma
# Sentry Config File
.env.sentry-build-plugin

View File

@ -1,5 +1,10 @@
{
"pages": {
"/global-error": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/global-error.js"
],
"/layout": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
@ -16,20 +21,15 @@
"static/chunks/main-app.js",
"static/chunks/app/api/auth/[...nextauth]/route.js"
],
"/api/assets/route": [
"/projects/page": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/api/assets/route.js"
"static/chunks/app/projects/page.js"
],
"/api/projects/route": [
"/crew/page": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/api/projects/route.js"
],
"/api/blog/route": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/api/blog/route.js"
"static/chunks/app/crew/page.js"
],
"/blog/page": [
"static/chunks/webpack.js",
@ -41,15 +41,25 @@
"static/chunks/main-app.js",
"static/chunks/app/faq/page.js"
],
"/api/faq/route": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/api/faq/route.js"
],
"/contact/page": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/contact/page.js"
],
"/projects/page": [
"/admin/layout": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/projects/page.js"
"static/chunks/app/admin/layout.js"
],
"/admin/page": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/admin/page.js"
]
}
}

View File

@ -2,9 +2,7 @@
"polyfillFiles": [
"static/chunks/polyfills.js"
],
"devFiles": [
"static/chunks/react-refresh.js"
],
"devFiles": [],
"ampDevFiles": [],
"lowPriorityFiles": [
"static/development/_buildManifest.js",
@ -16,16 +14,7 @@
],
"rootMainFilesTree": {},
"pages": {
"/_app": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/_app.js"
],
"/_error": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/_error.js"
]
"/_app": []
},
"ampFirstPages": []
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,31 +0,0 @@
{
"polyfillFiles": [
"static/chunks/polyfills.js"
],
"devFiles": [
"static/chunks/fallback/react-refresh.js"
],
"ampDevFiles": [
"static/chunks/fallback/webpack.js",
"static/chunks/fallback/amp.js"
],
"lowPriorityFiles": [],
"rootMainFiles": [
"static/chunks/fallback/webpack.js",
"static/chunks/fallback/main-app.js"
],
"rootMainFilesTree": {},
"pages": {
"/_app": [
"static/chunks/fallback/webpack.js",
"static/chunks/fallback/main.js",
"static/chunks/fallback/pages/_app.js"
],
"/_error": [
"static/chunks/fallback/webpack.js",
"static/chunks/fallback/main.js",
"static/chunks/fallback/pages/_error.js"
]
},
"ampFirstPages": []
}

View File

@ -4,8 +4,8 @@
"dynamicRoutes": {},
"notFoundRoutes": [],
"preview": {
"previewModeId": "2dbbd9987899e3cc204e40a239815375",
"previewModeSigningKey": "bad8f11a5056d21fe20e0a5bd813454b38ea3fd25ce77e7cafe32a4ed4634967",
"previewModeEncryptionKey": "6ba64c891fac3489e8fdafbd722323c67985c8be4cd315b61eb3ea2addc6df0f"
"previewModeId": "0d7f22499a8e7cb0f6dc0991b071ee08",
"previewModeSigningKey": "4815944c88776b54f4d30ca55e3481a304fedf700da30261c2d89034e267b911",
"previewModeEncryptionKey": "d597e4fbbf187baf182306010bb7c4a6c59d24fd1babf34805112333501a3634"
}
}

View File

@ -1 +1 @@
{"version":3,"caseSensitive":false,"basePath":"","rewrites":{"beforeFiles":[],"afterFiles":[{"source":"/admin/:path*","destination":"/admin/:path*","regex":"^\\/admin(?:\\/((?:[^\\/]+?)(?:\\/(?:[^\\/]+?))*))?(?:\\/)?$","check":true}],"fallback":[]},"redirects":[{"source":"/:path+/","destination":"/:path+","permanent":true,"internal":true,"regex":"^(?:\\/((?:[^\\/]+?)(?:\\/(?:[^\\/]+?))*))\\/$"}],"headers":[]}
{"version":3,"caseSensitive":false,"basePath":"","rewrites":{"beforeFiles":[],"afterFiles":[{"source":"/monitoring(/?)","has":[{"type":"query","key":"o","value":"(?<orgid>\\d*)"},{"type":"query","key":"p","value":"(?<projectid>\\d*)"},{"type":"query","key":"r","value":"(?<region>[a-z]{2})"}],"destination":"https://o:orgid.ingest.:region.sentry.io/api/:projectid/envelope/?hsts=0","regex":"^\\/monitoring(\\/?)(?:\\/)?$","check":true},{"source":"/monitoring(/?)","has":[{"type":"query","key":"o","value":"(?<orgid>\\d*)"},{"type":"query","key":"p","value":"(?<projectid>\\d*)"}],"destination":"https://o:orgid.ingest.sentry.io/api/:projectid/envelope/?hsts=0","regex":"^\\/monitoring(\\/?)(?:\\/)?$","check":true},{"source":"/admin/:path*","destination":"/admin/:path*","regex":"^\\/admin(?:\\/((?:[^\\/]+?)(?:\\/(?:[^\\/]+?))*))?(?:\\/)?$","check":true}],"fallback":[]},"redirects":[{"source":"/:path+/","destination":"/:path+","permanent":true,"internal":true,"regex":"^(?:\\/((?:[^\\/]+?)(?:\\/(?:[^\\/]+?))*))\\/$"}],"headers":[]}

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More