Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
DestroyRef,
OnInit,
inject,
isDevMode,
signal,
} from '@angular/core';
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ if (SENTRY_DSN) {
dsn: SENTRY_DSN,
environment: isDevMode() ? 'development' : 'production',
integrations: [
Sentry.breadcrumbsIntegration({
console: false,
}),
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
maskAllText: true,
Expand All @@ -20,7 +23,7 @@ if (SENTRY_DSN) {
tracesSampleRate: 1,
replaysSessionSampleRate: 1,
replaysOnErrorSampleRate: 1,
enableLogs: true,
enableLogs: false,
});
}

Expand Down
33 changes: 32 additions & 1 deletion src/utils/thrift/provide-thrift-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { combineLatest, map } from 'rxjs';
import { UnionToIntersection } from 'utility-types';

import { Type, inject, isDevMode, makeEnvironmentProviders } from '@angular/core';
import * as Sentry from '@sentry/angular';

import { ConnectOptions } from '@vality/domain-proto';
import { toJson } from '@vality/ng-thrift';
Expand All @@ -18,6 +19,8 @@ export const LOGGING = {
fullLogging: isDevMode(),
};

type ParsedThriftError = ReturnType<typeof parseThriftError>;

export function parseThriftError<T extends object>(error: unknown) {
const traceId = error?.['info']?.headers?.['x-woody-trace-id'];

Expand Down Expand Up @@ -72,12 +75,40 @@ export function parseThriftError<T extends object>(error: unknown) {
}
}

function captureThriftError(
params: Parameters<NonNullable<ConnectOptions['loggingFn']>>[0],
error: ParsedThriftError,
) {
Sentry.withScope((scope) => {
scope.setTags({
'thrift.error_type': error.type,
'thrift.namespace': params.namespace,
'thrift.service': params.serviceName,
'thrift.method': params.name,
});
scope.setFingerprint([
'{{ default }}',
error.type,
params.namespace,
params.serviceName,
params.name,
]);

if (error.traceId) {
scope.setTag('thrift.trace_id', error.traceId);
}

Sentry.captureException(params.error);
});
}

const logger: ConnectOptions['loggingFn'] = (params) => {
const info = `${params.name} (${params.namespace} ${params.serviceName})`;

switch (params.type) {
case 'error': {
const parsedError = parseThriftError(params.error);
captureThriftError(params, parsedError);
console.groupCollapsed(
`🔴\u00A0${info}`,
`\n⚠️\u00A0${parsedError.message || parsedError.name || 'Unknown error'}`,
Expand Down Expand Up @@ -131,7 +162,7 @@ function createConnectOptions(serviceName: string) {
createCallOptions: () => ({
headers: createRequestWachterHeaders(),
}),
timeout: isDevMode() ? 10_000 : 60_000,
timeout: isDevMode() ? 15_000 : 60_000,
...config.api.wachter,
}),
),
Expand Down
Loading