Skip to content

The open alternative to Salesforce, designed for AI.

revert: Sentry #20064 + @sentry 10.27 (prod bisect) (#20221)

Charles Bochetff22988caf5b
diff --git a/packages/twenty-front/package.json b/packages/twenty-front/package.json
index 0cc2b67ed1e..00ad2147588 100644
--- a/packages/twenty-front/package.json
+++ b/packages/twenty-front/package.json
@@ -57,7 +57,7 @@
"@react-email/components": "^0.5.3",
"@react-pdf/renderer": "^4.1.6",
"@scalar/api-reference-react": "^0.4.36",
- "@sentry/react": "^10.51.0",
+ "@sentry/react": "^10.27.0",
"@sniptt/guards": "^0.2.0",
"@tiptap/core": "3.4.2",
"@tiptap/extension-bold": "3.4.2",
diff --git a/packages/twenty-server/package.json b/packages/twenty-server/package.json
index 68bcf9620ba..a5ed9ba6ac9 100644
--- a/packages/twenty-server/package.json
+++ b/packages/twenty-server/package.json
@@ -78,9 +78,9 @@
"@ptc-org/nestjs-query-graphql": "patch:@ptc-org/[email protected]#./patches/@ptc-org+nestjs-query-graphql+4.2.0.patch",
"@ptc-org/nestjs-query-typeorm": "4.2.1-alpha.2",
"@react-email/render": "^1.2.3",
- "@sentry/nestjs": "^10.51.0",
- "@sentry/node": "^10.51.0",
- "@sentry/profiling-node": "^10.51.0",
+ "@sentry/nestjs": "^10.27.0",
+ "@sentry/node": "^10.27.0",
+ "@sentry/profiling-node": "^10.27.0",
"@sniptt/guards": "0.2.0",
"addressparser": "1.0.1",
"ai": "6.0.97",
diff --git a/packages/twenty-server/src/engine/core-modules/auth/middlewares/workspace-auth-context.middleware.ts b/packages/twenty-server/src/engine/core-modules/auth/middlewares/workspace-auth-context.middleware.ts
index 23c87cd7d80..c446be9c326 100644
--- a/packages/twenty-server/src/engine/core-modules/auth/middlewares/workspace-auth-context.middleware.ts
+++ b/packages/twenty-server/src/engine/core-modules/auth/middlewares/workspace-auth-context.middleware.ts
@@ -13,7 +13,6 @@ import { buildApiKeyAuthContext } from 'src/engine/core-modules/auth/utils/build
import { buildApplicationAuthContext } from 'src/engine/core-modules/auth/utils/build-application-auth-context.util';
import { buildPendingActivationUserAuthContext } from 'src/engine/core-modules/auth/utils/build-pending-activation-user-auth-context.util';
import { buildUserAuthContext } from 'src/engine/core-modules/auth/utils/build-user-auth-context.util';
-import { applyWorkspaceSentryContext } from 'src/engine/core-modules/sentry/utils/apply-workspace-sentry-context.util';
@Injectable()
export class WorkspaceAuthContextMiddleware implements NestMiddleware {
@@ -26,8 +25,6 @@ export class WorkspaceAuthContextMiddleware implements NestMiddleware {
const authContext = this.buildAuthContext(req);
- applyWorkspaceSentryContext(authContext);
-
withWorkspaceAuthContext(authContext, () => {
next();
});
diff --git a/packages/twenty-server/src/engine/core-modules/message-queue/drivers/bullmq.driver.ts b/packages/twenty-server/src/engine/core-modules/message-queue/drivers/bullmq.driver.ts
index dedb66ac095..0f94e52594d 100644
--- a/packages/twenty-server/src/engine/core-modules/message-queue/drivers/bullmq.driver.ts
+++ b/packages/twenty-server/src/engine/core-modules/message-queue/drivers/bullmq.driver.ts
@@ -4,7 +4,6 @@ import {
type OnModuleInit,
} from '@nestjs/common';
-import * as Sentry from '@sentry/node';
import {
type JobsOptions,
MetricsTime,
@@ -29,7 +28,6 @@ import { type MessageQueue } from 'src/engine/core-modules/message-queue/message
import { getJobKey } from 'src/engine/core-modules/message-queue/utils/get-job-key.util';
import { type MetricsService } from 'src/engine/core-modules/metrics/metrics.service';
import { MetricsKeys } from 'src/engine/core-modules/metrics/types/metrics-keys.type';
-import { applyWorkspaceSentryContextFromJobData } from 'src/engine/core-modules/sentry/utils/apply-workspace-sentry-context-from-job-data.util';
export type BullMQDriverOptions = QueueOptions;
@@ -110,28 +108,25 @@ export class BullMQDriver
this.workerMap[queueName] = new Worker(
queueName,
- async (job) =>
- Sentry.withIsolationScope(async () => {
- applyWorkspaceSentryContextFromJobData(job.data);
-
- // TODO: Correctly support for job.id
- const timeStart = performance.now();
- const workspaceId = job.data?.workspaceId;
- const workspaceSuffix = workspaceId
- ? ` [workspace=${workspaceId}]`
- : '';
-
- this.logger.log(
- `Processing job ${job.id} with name ${job.name} on queue ${queueName}${workspaceSuffix}`,
- );
- await handler({ data: job.data, id: job.id ?? '', name: job.name });
- const timeEnd = performance.now();
- const executionTime = timeEnd - timeStart;
-
- this.logger.log(
- `Job ${job.id} with name ${job.name} processed on queue ${queueName} in ${executionTime.toFixed(2)}ms${workspaceSuffix}`,
- );
- }),
+ async (job) => {
+ // TODO: Correctly support for job.id
+ const timeStart = performance.now();
+ const workspaceId = job.data?.workspaceId;
+ const workspaceSuffix = workspaceId
+ ? ` [workspace=${workspaceId}]`
+ : '';
+
+ this.logger.log(
+ `Processing job ${job.id} with name ${job.name} on queue ${queueName}${workspaceSuffix}`,
+ );
+ await handler({ data: job.data, id: job.id ?? '', name: job.name });
+ const timeEnd = performance.now();
+ const executionTime = timeEnd - timeStart;
+
+ this.logger.log(
+ `Job ${job.id} with name ${job.name} processed on queue ${queueName} in ${executionTime.toFixed(2)}ms${workspaceSuffix}`,
+ );
+ },
workerOptions,
);
diff --git a/packages/twenty-server/src/engine/core-modules/sentry/utils/apply-workspace-sentry-context-from-job-data.util.ts b/packages/twenty-server/src/engine/core-modules/sentry/utils/apply-workspace-sentry-context-from-job-data.util.ts
deleted file mode 100644
index 0d78ba3515f..00000000000
--- a/packages/twenty-server/src/engine/core-modules/sentry/utils/apply-workspace-sentry-context-from-job-data.util.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { applyWorkspaceSentryFields } from 'src/engine/core-modules/sentry/utils/apply-workspace-sentry-fields.util';
-
-export const applyWorkspaceSentryContextFromJobData = (
- jobData: unknown,
-): void => {
- if (typeof jobData !== 'object' || jobData === null) {
- return;
- }
-
- const workspaceId = (jobData as { workspaceId?: unknown }).workspaceId;
- const userWorkspaceId = (jobData as { userWorkspaceId?: unknown })
- .userWorkspaceId;
-
- if (typeof workspaceId !== 'string' || workspaceId.length === 0) {
- return;
- }
-
- applyWorkspaceSentryFields({
- workspaceId,
- userWorkspaceId:
- typeof userWorkspaceId === 'string' && userWorkspaceId.length > 0
- ? userWorkspaceId
- : undefined,
- });
-};
diff --git a/packages/twenty-server/src/engine/core-modules/sentry/utils/apply-workspace-sentry-context.util.ts b/packages/twenty-server/src/engine/core-modules/sentry/utils/apply-workspace-sentry-context.util.ts
deleted file mode 100644
index 3c9ea343d8f..00000000000
--- a/packages/twenty-server/src/engine/core-modules/sentry/utils/apply-workspace-sentry-context.util.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { type WorkspaceAuthContext } from 'src/engine/core-modules/auth/types/workspace-auth-context.type';
-import { applyWorkspaceSentryFields } from 'src/engine/core-modules/sentry/utils/apply-workspace-sentry-fields.util';
-
-export const applyWorkspaceSentryContext = (
- authContext: WorkspaceAuthContext,
-): void => {
- const workspaceId = authContext.workspace?.id;
-
- if (!workspaceId) {
- return;
- }
-
- switch (authContext.type) {
- case 'user':
- case 'pendingActivationUser':
- applyWorkspaceSentryFields({
- workspaceId,
- userWorkspaceId: authContext.userWorkspaceId,
- });
- return;
- case 'apiKey':
- case 'application':
- case 'system':
- applyWorkspaceSentryFields({ workspaceId });
- return;
- }
-};
diff --git a/packages/twenty-server/src/engine/core-modules/sentry/utils/apply-workspace-sentry-fields.util.ts b/packages/twenty-server/src/engine/core-modules/sentry/utils/apply-workspace-sentry-fields.util.ts
deleted file mode 100644
index a65e17d3d58..00000000000
--- a/packages/twenty-server/src/engine/core-modules/sentry/utils/apply-workspace-sentry-fields.util.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import * as Sentry from '@sentry/node';
-
-type WorkspaceSentryFields = {
- workspaceId: string;
- userWorkspaceId?: string;
-};
-
-export const applyWorkspaceSentryFields = (
- fields: WorkspaceSentryFields,
-): void => {
- Sentry.setUser({
- id: fields.userWorkspaceId ?? fields.workspaceId,
- });
-
- Sentry.setTag('twenty.workspace.id', fields.workspaceId);
- if (fields.userWorkspaceId) {
- Sentry.setTag('twenty.user_workspace.id', fields.userWorkspaceId);
- }
-
- Sentry.setContext('twenty', {
- workspace_id: fields.workspaceId,
- ...(fields.userWorkspaceId && {
- user_workspace_id: fields.userWorkspaceId,
- }),
- });
-};
diff --git a/packages/twenty-server/src/instrument.ts b/packages/twenty-server/src/instrument.ts
index 1c09ae04b0e..217d1231399 100644
--- a/packages/twenty-server/src/instrument.ts
+++ b/packages/twenty-server/src/instrument.ts
@@ -45,29 +45,6 @@ if (process.env.EXCEPTION_HANDLER_DRIVER === ExceptionHandlerDriver.SENTRY) {
profilesSampleRate: 0.3,
sendDefaultPii: true,
debug: process.env.NODE_ENV === NodeEnvironment.DEVELOPMENT,
- beforeSendSpan: (span) => {
- const twentyContext = Sentry.getIsolationScope().getScopeData().contexts
- ?.twenty as
- | {
- workspace_id?: string;
- user_workspace_id?: string;
- }
- | undefined;
-
- if (!twentyContext?.workspace_id) {
- return span;
- }
-
- span.data = {
- ...span.data,
- 'twenty.workspace.id': twentyContext.workspace_id,
- ...(twentyContext.user_workspace_id && {
- 'twenty.user_workspace.id': twentyContext.user_workspace_id,
- }),
- };
-
- return span;
- },
});
}
diff --git a/yarn.lock b/yarn.lock
index 88ed01b1c7b..d96a118835b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -20408,7 +20408,7 @@ __metadata:
languageName: node
linkType: hard
-"@sentry/nestjs@npm:^10.51.0":
+"@sentry/nestjs@npm:^10.27.0":
version: 10.51.0
resolution: "@sentry/nestjs@npm:10.51.0"
dependencies:
@@ -20457,7 +20457,7 @@ __metadata:
languageName: node
linkType: hard
-"@sentry/node@npm:10.51.0, @sentry/node@npm:^10.51.0":
+"@sentry/node@npm:10.51.0, @sentry/node@npm:^10.27.0":
version: 10.51.0
resolution: "@sentry/node@npm:10.51.0"
dependencies:
@@ -20510,7 +20510,7 @@ __metadata:
languageName: node
linkType: hard
-"@sentry/profiling-node@npm:^10.51.0":
+"@sentry/profiling-node@npm:^10.27.0":
version: 10.51.0
resolution: "@sentry/profiling-node@npm:10.51.0"
dependencies:
@@ -20523,7 +20523,7 @@ __metadata:
languageName: node
linkType: hard
-"@sentry/react@npm:^10.51.0":
+"@sentry/react@npm:^10.27.0":
version: 10.51.0
resolution: "@sentry/react@npm:10.51.0"
dependencies:
@@ -57848,7 +57848,7 @@ __metadata:
"@react-email/components": "npm:^0.5.3"
"@react-pdf/renderer": "npm:^4.1.6"
"@scalar/api-reference-react": "npm:^0.4.36"
- "@sentry/react": "npm:^10.51.0"
+ "@sentry/react": "npm:^10.27.0"
"@sniptt/guards": "npm:^0.2.0"
"@storybook-community/storybook-addon-cookie": "npm:^5.0.0"
"@storybook/addon-coverage": "npm:^3.0.0"
@@ -58096,9 +58096,9 @@ __metadata:
"@ptc-org/nestjs-query-graphql": "patch:@ptc-org/[email protected]#./patches/@ptc-org+nestjs-query-graphql+4.2.0.patch"
"@ptc-org/nestjs-query-typeorm": "npm:4.2.1-alpha.2"
"@react-email/render": "npm:^1.2.3"
- "@sentry/nestjs": "npm:^10.51.0"
- "@sentry/node": "npm:^10.51.0"
- "@sentry/profiling-node": "npm:^10.51.0"
+ "@sentry/nestjs": "npm:^10.27.0"
+ "@sentry/node": "npm:^10.27.0"
+ "@sentry/profiling-node": "npm:^10.27.0"
"@sniptt/guards": "npm:0.2.0"
"@swc/cli": "npm:^0.7.10"
"@swc/core": "npm:^1.15.11"