Skip to content

Commit

Permalink
update sentry and add profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
nichtsam committed Jun 29, 2024
1 parent 9c37c55 commit e8a6703
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 227 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ COPY --from=build /app/public /app/public
COPY --from=build /app/package.json /app/package.json
COPY --from=build /app/server.js /app/server.js
COPY --from=build /app/server-utils.js /app/server-utils.js
COPY --from=build /app/server-monitoring.js /app/server-monitoring.js
COPY ./mdx ./mdx

CMD [ "pnpm","start" ]
8 changes: 4 additions & 4 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ forceEnvValidation();

const ABORT_DELAY = 5_000;

if (env.NODE_ENV === "production" && env.SENTRY_DSN) {
import("./utils/monitoring.server.ts").then(({ init }) => init());
}

type DocRequestArgs = Parameters<HandleDocumentRequestFunction>;
export default function handleRequest(
...[
Expand All @@ -31,6 +27,10 @@ export default function handleRequest(
loadContext,
]: DocRequestArgs
) {
if (env.NODE_ENV === "production" && env.SENTRY_DSN) {
responseHeaders.append("Document-Policy", "js-profiling");
}

const nonce = String(loadContext.cspNonce);
const callbackName = isbot(request.headers.get("user-agent"))
? "onAllReady"
Expand Down
3 changes: 3 additions & 0 deletions app/utils/monitoring.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
init as sentryInit,
browserTracingIntegration,
replayIntegration,
browserProfilingIntegration,
} from "@sentry/remix";
import { useLocation, useMatches } from "@remix-run/react";
import { useEffect } from "react";
Expand All @@ -10,6 +11,7 @@ export function init() {
sentryInit({
dsn: window.ENV.SENTRY_DSN,
tracesSampleRate: 1,
profilesSampleRate: 1,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1,

Expand All @@ -20,6 +22,7 @@ export function init() {
useMatches,
}),
replayIntegration(),
browserProfilingIntegration(),
],
});
}
9 changes: 0 additions & 9 deletions app/utils/monitoring.server.ts

This file was deleted.

6 changes: 1 addition & 5 deletions app/utils/path.server.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { existsSync } from "fs";
import { dirname, resolve } from "path";
import { env } from "process";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url); // prod: build/server/assets/server-build-[hash].js | dev: app/utils/path.server.ts
const __dirname = dirname(__filename); // prod: build/server/assets | dev: app/utils
export const rootPath = resolve(
__dirname,
env.NODE_ENV === "production" ? "../../../" : "../../",
);
export const rootPath = resolve(__dirname, "../../");

export function getFilePathInDirectoryByName(
dirPath: string,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"@remix-run/node": "2.9.1",
"@remix-run/react": "2.9.1",
"@remix-run/serve": "2.9.1",
"@sentry/remix": "8.9.2",
"@sentry/profiling-node": "8.13.0",
"@sentry/remix": "8.13.0",
"@sentry/vite-plugin": "2.18.0",
"address": "2.0.2",
"cache-control-parser": "2.0.6",
Expand Down
Loading

0 comments on commit e8a6703

Please sign in to comment.