Skip to content

Commit

Permalink
chore: added Sentry config package.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezeikel committed Nov 25, 2024
1 parent da78294 commit 833f8f6
Show file tree
Hide file tree
Showing 19 changed files with 158 additions and 73 deletions.
22 changes: 4 additions & 18 deletions apps/web/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
import { withSentryConfig } from "@sentry/nextjs";
import type { NextConfig } from "next";
import { withSentry } from "@cuurly/sentry-config/next";

const nextConfig: NextConfig = {
const nextConfig = {
images: {
domains: ["res.cloudinary.com"],
},
compiler: {},
};

const sentryOptions = {
silent: false,
org: "ezeikel",
export default withSentry(nextConfig, {
project: "cuurly-web",
authToken: process.env.SENTRY_AUTH_TOKEN,
widenClientFileUpload: true,
transpileClientSDK: true,
tunnelRoute: "/monitoring",
hideSourceMaps: true,
disableLogger: true,
automaticVercelMonitors: true,
};

const configWithSentry = withSentryConfig(nextConfig, sentryOptions);

export default configWithSentry;
});
26 changes: 4 additions & 22 deletions apps/web/sentry.client.config.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
import * as Sentry from "@sentry/nextjs";
import { initClientSentry } from "@cuurly/sentry-config/client";

Sentry.init({
dsn: "https://[email protected]/5263646",
// Replay may only be enabled for the client-side
integrations: [Sentry.replayIntegration()],

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for tracing.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,

// ...

// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
// that it will also get attached to your source maps
});
initClientSentry(
"https://[email protected]/5263646",
);
19 changes: 4 additions & 15 deletions apps/web/sentry.edge.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import * as Sentry from "@sentry/nextjs";
import { initEdgeSentry } from "@cuurly/sentry-config/edge";

Sentry.init({
dsn: "https://[email protected]/5263646",

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for tracing.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// ...

// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
// that it will also get attached to your source maps
});
initEdgeSentry(
"https://[email protected]/5263646",
);
19 changes: 4 additions & 15 deletions apps/web/sentry.server.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import * as Sentry from "@sentry/nextjs";
import { initServerSentry } from "@cuurly/sentry-config/server";

Sentry.init({
dsn: "https://[email protected]/5263646",

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for tracing.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// ...

// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
// that it will also get attached to your source maps
});
initServerSentry(
"https://[email protected]/5263646",
);
Binary file modified bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions configs/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"eslint-plugin-react-hooks": "latest",
"globals": "latest"
},
"devDependencies": {
"@cuurly/tsconfig": "*"
},
"peerDependencies": {
"eslint": "^8.0.0",
"prettier": "^3.0.0",
Expand Down
6 changes: 5 additions & 1 deletion configs/prettier-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"name": "@cuurly/prettier-config",
"version": "0.1.0",
"private": true,
"main": "index.json"
"main": "index.json",
"devDependencies": {
"@cuurly/eslint-config": "*",
"@cuurly/tsconfig": "*"
}
}
15 changes: 15 additions & 0 deletions configs/prettier-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "@cuurly/tsconfig/base.json",
"compilerOptions": {
"outDir": "dist",
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json",
"target": "es2019",
"module": "esnext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["./**/*.ts", "index.ts"],
"exclude": ["node_modules", "dist"]
}
7 changes: 7 additions & 0 deletions configs/sentry-config/base.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// eslint-disable-next-line import/prefer-default-export
export const getBaseConfig = (dsn) => ({
dsn,
tracesSampleRate: 1.0,
debug: process.env.NODE_ENV === "development",
environment: process.env.NODE_ENV,
});
12 changes: 12 additions & 0 deletions configs/sentry-config/client.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Sentry from "@sentry/nextjs";
import { getBaseConfig } from "./base.mjs";

// eslint-disable-next-line import/prefer-default-export
export const initClientSentry = (dsn) => {
Sentry.init({
...getBaseConfig(dsn),
integrations: [Sentry.replayIntegration()],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
};
9 changes: 9 additions & 0 deletions configs/sentry-config/edge.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as Sentry from "@sentry/nextjs";
import { getBaseConfig } from "./base.mjs";

// eslint-disable-next-line import/prefer-default-export
export const initEdgeSentry = (dsn) => {
Sentry.init({
...getBaseConfig(dsn),
});
};
3 changes: 3 additions & 0 deletions configs/sentry-config/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintConfig from "@cuurly/eslint-config";

export default [...eslintConfig];
4 changes: 4 additions & 0 deletions configs/sentry-config/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./client.mjs";
export * from "./server.mjs";
export * from "./edge.mjs";
export * from "./next.mjs";
18 changes: 18 additions & 0 deletions configs/sentry-config/next.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { withSentryConfig } from "@sentry/nextjs";

export const getSentryWebpackPluginOptions = ({ org, project }) => ({
silent: false,
org: org || "ezeikel",
project: project || "cuurly-web",
authToken: process.env.SENTRY_AUTH_TOKEN,
widenClientFileUpload: true,
transpileClientSDK: true,
tunnelRoute: "/monitoring",
hideSourceMaps: true,
disableLogger: true,
automaticVercelMonitors: true,
});

export const withSentry = (config, options) => {
return withSentryConfig(config, getSentryWebpackPluginOptions(options));
};
40 changes: 40 additions & 0 deletions configs/sentry-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@cuurly/sentry-config",
"version": "0.1.0",
"private": true,
"type": "module",
"main": "index.js",
"exports": {
".": "./index.mjs",
"./client": "./client.mjs",
"./server": "./server.mjs",
"./edge": "./edge.mjs",
"./next": "./next.mjs"
},
"scripts": {
"clean": "git clean -xdf .next .turbo node_modules",
"lint": "eslint",
"lint:fix": "eslint --fix",
"typecheck": "tsc --noEmit",
"format": "prettier --write . --ignore-path ../../.gitignore --cache",
"check-format": "prettier --check . --ignore-path ../../.gitignore --cache",
"prepare": "husky"
},
"lint-staged": {
"**/*.+(js|jsx|json|ts|tsx|css|html|md)": [
"prettier --ignore-path .gitignore --write",
"jest --findRelatedTests --passWithNoTests"
]
},
"dependencies": {
"@sentry/nextjs": "^8.35.0"
},
"devDependencies": {
"@cuurly/eslint-config": "*",
"@cuurly/prettier-config": "*",
"@cuurly/tsconfig": "*"
},
"peerDependencies": {
"@sentry/nextjs": "^8.35.0"
}
}
9 changes: 9 additions & 0 deletions configs/sentry-config/server.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as Sentry from "@sentry/nextjs";
import { getBaseConfig } from "./base.mjs";

// eslint-disable-next-line import/prefer-default-export
export const initServerSentry = (dsn) => {
Sentry.init({
...getBaseConfig(dsn),
});
};
15 changes: 15 additions & 0 deletions configs/sentry-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "@cuurly/tsconfig/base.json",
"compilerOptions": {
"outDir": "dist",
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json",
"target": "es2019",
"module": "esnext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["./**/*.ts", "index.mjs, "server.mjs", "next.mjs"", "edge.mjs", "client.mjs", "base.mjs"],
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"db:studio": "bunx prisma studio",
"db:generate": "bunx prisma generate",
"db:migrate:deploy": "bunx prisma migrate deploy",
"postinstall": "bunx prisma generate --schema=\"./packages/db/prisma/schema.prisma\""
"postinstall": "bunx prisma generate --schema=\"./prisma/schema.prisma\""
},
"dependencies": {
"@neondatabase/serverless": "^0.10.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
previewFeatures = ["driverAdapters", "tracing"]
}

datasource db {
Expand Down

0 comments on commit 833f8f6

Please sign in to comment.