Improve snackbar and fix sentry (#7181)

- Improve snackbar to enable displaying multi-line message (so far we
only displayed the first few words which was very frustrating)

- Followup on previous issue to enable tim@apple.dev on the demo
workspace (prefilled automatically)

- Fix sentry tracing which had been broken when migrating from v7 to v8
This commit is contained in:
Félix Malfait
2024-09-21 06:33:15 +02:00
committed by GitHub
parent 20d06b3c0f
commit 6d5d73fbe8
13 changed files with 84 additions and 62 deletions

View File

@ -6,15 +6,17 @@ export function SentryCronMonitor(monitorSlug: string, schedule: string) {
propertyKey: string,
descriptor: PropertyDescriptor,
) {
if (!Sentry.isInitialized()) {
return descriptor;
}
const originalMethod = descriptor.value;
descriptor.value = async function (...args: any[]) {
if (!Sentry.isInitialized()) {
return await originalMethod.apply(this, args);
}
let checkInId: string | undefined;
try {
Sentry.captureCheckIn(
checkInId = Sentry.captureCheckIn(
{
monitorSlug,
status: 'in_progress',
@ -25,13 +27,14 @@ export function SentryCronMonitor(monitorSlug: string, schedule: string) {
value: schedule,
},
checkinMargin: 1,
maxRuntime: 1,
maxRuntime: 5,
timezone: 'UTC',
},
);
const result = await originalMethod.apply(this, args);
Sentry.captureCheckIn({
checkInId,
monitorSlug,
status: 'ok',
});
@ -39,6 +42,7 @@ export function SentryCronMonitor(monitorSlug: string, schedule: string) {
return result;
} catch (error) {
Sentry.captureCheckIn({
checkInId,
monitorSlug,
status: 'error',
});

View File

@ -1,42 +1,13 @@
import * as Sentry from '@sentry/node';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
import { ExceptionHandlerOptions } from 'src/engine/core-modules/exception-handler/interfaces/exception-handler-options.interface';
import { ExceptionHandlerUser } from 'src/engine/core-modules/exception-handler/interfaces/exception-handler-user.interface';
import {
ExceptionHandlerDriverInterface,
ExceptionHandlerSentryDriverFactoryOptions,
} from 'src/engine/core-modules/exception-handler/interfaces';
import { WorkspaceCacheKeys } from 'src/engine/workspace-cache-storage/workspace-cache-storage.service';
import { ExceptionHandlerDriverInterface } from 'src/engine/core-modules/exception-handler/interfaces';
export class ExceptionHandlerSentryDriver
implements ExceptionHandlerDriverInterface
{
constructor(options: ExceptionHandlerSentryDriverFactoryOptions['options']) {
Sentry.init({
environment: options.environment,
release: options.release,
dsn: options.dsn,
integrations: [
// TODO: Redis integration doesn't seem to work - investigate why
Sentry.redisIntegration({
cachePrefixes: Object.values(WorkspaceCacheKeys).map(
(key) => `engine:${key}:`,
),
}),
Sentry.httpIntegration(),
Sentry.expressIntegration(),
Sentry.graphqlIntegration(),
Sentry.postgresIntegration(),
nodeProfilingIntegration(),
],
tracesSampleRate: 0.1,
profilesSampleRate: 0.3,
debug: options.debug,
});
}
captureExceptions(
exceptions: ReadonlyArray<any>,
options?: ExceptionHandlerOptions,

View File

@ -1,15 +1,15 @@
import { DynamicModule, Global, Module } from '@nestjs/common';
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
import { ExceptionHandlerDriver } from 'src/engine/core-modules/exception-handler/interfaces';
import { EXCEPTION_HANDLER_DRIVER } from 'src/engine/core-modules/exception-handler/exception-handler.constants';
import {
ConfigurableModuleClass,
OPTIONS_TYPE,
ASYNC_OPTIONS_TYPE,
} from 'src/engine/core-modules/exception-handler/exception-handler.module-definition';
import { ExceptionHandlerConsoleDriver } from 'src/engine/core-modules/exception-handler/drivers/console.driver';
import { ExceptionHandlerSentryDriver } from 'src/engine/core-modules/exception-handler/drivers/sentry.driver';
import { EXCEPTION_HANDLER_DRIVER } from 'src/engine/core-modules/exception-handler/exception-handler.constants';
import {
ASYNC_OPTIONS_TYPE,
ConfigurableModuleClass,
OPTIONS_TYPE,
} from 'src/engine/core-modules/exception-handler/exception-handler.module-definition';
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
import { ExceptionHandlerDriver } from 'src/engine/core-modules/exception-handler/interfaces';
@Global()
@Module({
@ -23,7 +23,7 @@ export class ExceptionHandlerModule extends ConfigurableModuleClass {
useValue:
options.type === ExceptionHandlerDriver.Console
? new ExceptionHandlerConsoleDriver()
: new ExceptionHandlerSentryDriver(options.options),
: new ExceptionHandlerSentryDriver(),
};
const dynamicModule = super.forRoot(options);
@ -45,7 +45,7 @@ export class ExceptionHandlerModule extends ConfigurableModuleClass {
return config.type === ExceptionHandlerDriver.Console
? new ExceptionHandlerConsoleDriver()
: new ExceptionHandlerSentryDriver(config.options);
: new ExceptionHandlerSentryDriver();
},
inject: options.inject || [],
};

View File

@ -31,6 +31,7 @@ export const workspaceMemberPrefillData = async (
nameLastName: 'A',
locale: 'en',
colorScheme: 'Light',
userEmail: 'noah@demo.dev',
userId: DEMO_SEED_USER_IDS.NOAH,
},
{
@ -39,6 +40,7 @@ export const workspaceMemberPrefillData = async (
nameLastName: 'I',
locale: 'en',
colorScheme: 'Light',
userEmail: 'hugo@demo.dev',
userId: DEMO_SEED_USER_IDS.HUGO,
},
{
@ -47,6 +49,7 @@ export const workspaceMemberPrefillData = async (
nameLastName: 'Apple',
locale: 'en',
colorScheme: 'Light',
userEmail: 'tim@apple.dev',
userId: DEMO_SEED_USER_IDS.TIM,
},
])