Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc686fa987
|
||
|
|
ea4b5a2353
|
||
|
|
1a03384b49
|
||
|
|
3f7e592600
|
||
|
|
f7cd514997
|
||
|
|
3a4f6624fc
|
@@ -43,6 +43,7 @@ DOMAIN_NAME=localhost
|
|||||||
ENABLE_CORS=false
|
ENABLE_CORS=false
|
||||||
CORS_DOMAIN_NAME=localhost
|
CORS_DOMAIN_NAME=localhost
|
||||||
SENTRY_DSN=
|
SENTRY_DSN=
|
||||||
|
NEXT_PUBLIC_SENTRY_DSN=
|
||||||
|
|
||||||
# Media Limits (in KB)
|
# Media Limits (in KB)
|
||||||
MAX_IMAGE_SIZE_KB=512
|
MAX_IMAGE_SIZE_KB=512
|
||||||
|
|||||||
@@ -106,3 +106,5 @@ jobs:
|
|||||||
MAIL_FROM: ${{ secrets.MAIL_FROM }}
|
MAIL_FROM: ${{ secrets.MAIL_FROM }}
|
||||||
DOMAIN_NAME: ${{ secrets.DOMAIN_NAME }}
|
DOMAIN_NAME: ${{ secrets.DOMAIN_NAME }}
|
||||||
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
|
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
|
||||||
|
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
||||||
|
NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_DSN }}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@memegoat/backend",
|
"name": "@memegoat/backend",
|
||||||
"version": "1.10.1",
|
"version": "1.10.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "",
|
"author": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import { CACHE_MANAGER } from "@nestjs/cache-manager";
|
import { CACHE_MANAGER } from "@nestjs/cache-manager";
|
||||||
import { Test, TestingModule } from "@nestjs/testing";
|
import { Test, TestingModule } from "@nestjs/testing";
|
||||||
|
import * as Sentry from "@sentry/nestjs";
|
||||||
import { DatabaseService } from "./database/database.service";
|
import { DatabaseService } from "./database/database.service";
|
||||||
import { HealthController } from "./health.controller";
|
import { HealthController } from "./health.controller";
|
||||||
|
|
||||||
|
jest.mock("@sentry/nestjs", () => ({
|
||||||
|
getClient: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
describe("HealthController", () => {
|
describe("HealthController", () => {
|
||||||
let controller: HealthController;
|
let controller: HealthController;
|
||||||
|
|
||||||
@@ -37,10 +42,15 @@ describe("HealthController", () => {
|
|||||||
it("should return ok if database and redis are connected", async () => {
|
it("should return ok if database and redis are connected", async () => {
|
||||||
mockDb.execute.mockResolvedValue([]);
|
mockDb.execute.mockResolvedValue([]);
|
||||||
mockCacheManager.set.mockResolvedValue(undefined);
|
mockCacheManager.set.mockResolvedValue(undefined);
|
||||||
|
(Sentry.getClient as jest.Mock).mockReturnValue({
|
||||||
|
getOptions: () => ({ dsn: "http://dsn" }),
|
||||||
|
});
|
||||||
|
|
||||||
const result = await controller.check();
|
const result = await controller.check();
|
||||||
expect(result.status).toBe("ok");
|
expect(result.status).toBe("ok");
|
||||||
expect(result.database).toBe("connected");
|
expect(result.database).toBe("connected");
|
||||||
expect(result.redis).toBe("connected");
|
expect(result.redis).toBe("connected");
|
||||||
|
expect(result.sentry).toBe("active");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return error if database is disconnected", async () => {
|
it("should return error if database is disconnected", async () => {
|
||||||
@@ -62,4 +72,19 @@ describe("HealthController", () => {
|
|||||||
expect(result.redis).toBe("disconnected");
|
expect(result.redis).toBe("disconnected");
|
||||||
expect(result.redisError).toBe("Redis Error");
|
expect(result.redisError).toBe("Redis Error");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should return sentry disabled if client or dsn is missing", async () => {
|
||||||
|
mockDb.execute.mockResolvedValue([]);
|
||||||
|
mockCacheManager.set.mockResolvedValue(undefined);
|
||||||
|
(Sentry.getClient as jest.Mock).mockReturnValue(undefined);
|
||||||
|
|
||||||
|
const result = await controller.check();
|
||||||
|
expect(result.sentry).toBe("disabled");
|
||||||
|
|
||||||
|
(Sentry.getClient as jest.Mock).mockReturnValue({
|
||||||
|
getOptions: () => ({ dsn: undefined }),
|
||||||
|
});
|
||||||
|
const result2 = await controller.check();
|
||||||
|
expect(result2.sentry).toBe("disabled");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { CACHE_MANAGER } from "@nestjs/cache-manager";
|
import { CACHE_MANAGER } from "@nestjs/cache-manager";
|
||||||
import { Controller, Get, Inject } from "@nestjs/common";
|
import { Controller, Get, Inject } from "@nestjs/common";
|
||||||
|
import * as Sentry from "@sentry/nestjs";
|
||||||
import type { Cache } from "cache-manager";
|
import type { Cache } from "cache-manager";
|
||||||
import { sql } from "drizzle-orm";
|
import { sql } from "drizzle-orm";
|
||||||
import { DatabaseService } from "./database/database.service";
|
import { DatabaseService } from "./database/database.service";
|
||||||
@@ -39,6 +40,14 @@ export class HealthController {
|
|||||||
health.redisError = error.message;
|
health.redisError = error.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check Sentry status
|
||||||
|
const sentryClient = Sentry.getClient();
|
||||||
|
if (sentryClient?.getOptions().dsn) {
|
||||||
|
health.sentry = "active";
|
||||||
|
} else {
|
||||||
|
health.sentry = "disabled";
|
||||||
|
}
|
||||||
|
|
||||||
return health;
|
return health;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,35 @@ async function bootstrap() {
|
|||||||
|
|
||||||
const sentryDsn = configService.get<string>("SENTRY_DSN");
|
const sentryDsn = configService.get<string>("SENTRY_DSN");
|
||||||
if (sentryDsn) {
|
if (sentryDsn) {
|
||||||
Sentry.init({
|
try {
|
||||||
dsn: sentryDsn,
|
Sentry.init({
|
||||||
integrations: [nodeProfilingIntegration()],
|
dsn: sentryDsn,
|
||||||
tracesSampleRate: 1.0,
|
integrations: [Sentry.nestIntegration(), nodeProfilingIntegration()],
|
||||||
profilesSampleRate: 1.0,
|
tracesSampleRate: 1.0,
|
||||||
sendDefaultPii: false, // RGPD
|
profilesSampleRate: 1.0,
|
||||||
beforeSend(event) {
|
sendDefaultPii: false, // RGPD
|
||||||
// Hachage de l'IP utilisateur pour Sentry si elle est présente
|
beforeSend(event) {
|
||||||
if (event.user?.ip_address) {
|
// Hachage de l'IP utilisateur pour Sentry si elle est présente
|
||||||
event.user.ip_address = createHash("sha256")
|
if (event.user?.ip_address) {
|
||||||
.update(event.user.ip_address)
|
event.user.ip_address = createHash("sha256")
|
||||||
.digest("hex");
|
.update(event.user.ip_address)
|
||||||
}
|
.digest("hex");
|
||||||
return event;
|
}
|
||||||
},
|
return event;
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const client = Sentry.getClient();
|
||||||
|
if (client?.getOptions().dsn) {
|
||||||
|
logger.log("Sentry is initialized and connection is active");
|
||||||
|
} else {
|
||||||
|
logger.warn("Sentry initialized but DSN is missing");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Failed to initialize Sentry: ${error.message}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn("Sentry is disabled (SENTRY_DSN not configured)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sécurité
|
// Sécurité
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ services:
|
|||||||
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-https://api.memegoat.fr}
|
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-https://api.memegoat.fr}
|
||||||
NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL:-https://memegoat.fr}
|
NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL:-https://memegoat.fr}
|
||||||
NEXT_PUBLIC_CONTACT_EMAIL: ${MAIL_FROM:-noreply@memegoat.fr}
|
NEXT_PUBLIC_CONTACT_EMAIL: ${MAIL_FROM:-noreply@memegoat.fr}
|
||||||
|
NEXT_PUBLIC_SENTRY_DSN: ${NEXT_PUBLIC_SENTRY_DSN}
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
|
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:3000}
|
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:3000}
|
||||||
|
NEXT_PUBLIC_SENTRY_DSN: ${NEXT_PUBLIC_SENTRY_DSN}
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { withSentryConfig } from "@sentry/nextjs";
|
||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const appUrl = process.env.NEXT_PUBLIC_APP_URL || "https://memegoat.fr";
|
const appUrl = process.env.NEXT_PUBLIC_APP_URL || "https://memegoat.fr";
|
||||||
@@ -29,4 +30,23 @@ const nextConfig: NextConfig = {
|
|||||||
output: "standalone",
|
output: "standalone",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default withSentryConfig(nextConfig, {
|
||||||
|
// For all available options, see:
|
||||||
|
// https://github.com/getsentry/sentry-webpack-plugin#options
|
||||||
|
|
||||||
|
org: "yidhra",
|
||||||
|
project: "javascript-nextjs",
|
||||||
|
|
||||||
|
// Only print logs for uploading source maps in CI
|
||||||
|
silent: !process.env.CI,
|
||||||
|
|
||||||
|
// For all available options, see:
|
||||||
|
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
||||||
|
|
||||||
|
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
||||||
|
widenClientFileUpload: true,
|
||||||
|
|
||||||
|
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
|
||||||
|
// This can increase your server load as well as your Sentry bill.
|
||||||
|
tunnelRoute: "/monitoring",
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@memegoat/frontend",
|
"name": "@memegoat/frontend",
|
||||||
"version": "1.10.1",
|
"version": "1.10.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
"@radix-ui/react-toggle": "^1.1.10",
|
"@radix-ui/react-toggle": "^1.1.10",
|
||||||
"@radix-ui/react-toggle-group": "^1.1.11",
|
"@radix-ui/react-toggle-group": "^1.1.11",
|
||||||
"@radix-ui/react-tooltip": "^1.2.8",
|
"@radix-ui/react-tooltip": "^1.2.8",
|
||||||
|
"@sentry/nextjs": "^10.38.0",
|
||||||
"axios": "^1.13.2",
|
"axios": "^1.13.2",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
|||||||
22
frontend/sentry.client.config.ts
Normal file
22
frontend/sentry.client.config.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import * as Sentry from "@sentry/nextjs";
|
||||||
|
|
||||||
|
Sentry.init({
|
||||||
|
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||||
|
|
||||||
|
// Ajustez ces valeurs en production
|
||||||
|
tracesSampleRate: 1.0,
|
||||||
|
|
||||||
|
// Replay est activé par défaut
|
||||||
|
replaysSessionSampleRate: 0.1,
|
||||||
|
replaysOnErrorSampleRate: 1.0,
|
||||||
|
|
||||||
|
integrations: [
|
||||||
|
Sentry.replayIntegration({
|
||||||
|
maskAllText: true,
|
||||||
|
blockAllMedia: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
|
||||||
|
// Protection PII
|
||||||
|
sendDefaultPii: false,
|
||||||
|
});
|
||||||
11
frontend/sentry.edge.config.ts
Normal file
11
frontend/sentry.edge.config.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import * as Sentry from "@sentry/nextjs";
|
||||||
|
|
||||||
|
Sentry.init({
|
||||||
|
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||||
|
|
||||||
|
// Ajustez ces valeurs en production
|
||||||
|
tracesSampleRate: 1.0,
|
||||||
|
|
||||||
|
// Protection PII
|
||||||
|
sendDefaultPii: false,
|
||||||
|
});
|
||||||
22
frontend/sentry.server.config.ts
Normal file
22
frontend/sentry.server.config.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { createHash } from "node:crypto";
|
||||||
|
import * as Sentry from "@sentry/nextjs";
|
||||||
|
|
||||||
|
Sentry.init({
|
||||||
|
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||||
|
|
||||||
|
// Ajustez ces valeurs en production
|
||||||
|
tracesSampleRate: 1.0,
|
||||||
|
|
||||||
|
// Protection PII
|
||||||
|
sendDefaultPii: false,
|
||||||
|
|
||||||
|
beforeSend(event) {
|
||||||
|
// Hachage de l'IP utilisateur pour Sentry si elle est présente
|
||||||
|
if (event.user?.ip_address) {
|
||||||
|
event.user.ip_address = createHash("sha256")
|
||||||
|
.update(event.user.ip_address)
|
||||||
|
.digest("hex");
|
||||||
|
}
|
||||||
|
return event;
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@memegoat/source",
|
"name": "@memegoat/source",
|
||||||
"version": "1.10.1",
|
"version": "1.10.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"version:get": "cmake -P version.cmake GET",
|
"version:get": "cmake -P version.cmake GET",
|
||||||
|
|||||||
995
pnpm-lock.yaml
generated
995
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user