Skip to content

Commit 4f7f1d4

Browse files
committed
ref(core): Make event processing logs warnings
It can be confusing to users why event processing errors log out as errors. Let's bump this down to warnings instead - which better represent how actionable most of these thrown errors are.
1 parent b3fddcd commit 4f7f1d4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/core/src/baseclient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
545545
return finalEvent.event_id;
546546
},
547547
reason => {
548-
IS_DEBUG_BUILD && logger.error(reason);
548+
IS_DEBUG_BUILD && logger.warn(reason);
549549
return undefined;
550550
},
551551
);

packages/core/test/lib/base.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -940,13 +940,13 @@ describe('BaseClient', () => {
940940
const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, beforeSend });
941941
const client = new TestClient(options);
942942
const captureExceptionSpy = jest.spyOn(client, 'captureException');
943-
const loggerErrorSpy = jest.spyOn(logger, 'error');
943+
const loggerWarnSpy = jest.spyOn(logger, 'warn');
944944

945945
client.captureEvent({ message: 'hello' });
946946

947947
expect(TestClient.instance!.event).toBeUndefined();
948948
expect(captureExceptionSpy).not.toBeCalled();
949-
expect(loggerErrorSpy).toBeCalledWith(new SentryError('`beforeSend` returned `null`, will not send event.'));
949+
expect(loggerWarnSpy).toBeCalledWith(new SentryError('`beforeSend` returned `null`, will not send event.'));
950950
});
951951

952952
test('calls beforeSend and log info about invalid return value', () => {
@@ -958,12 +958,12 @@ describe('BaseClient', () => {
958958
// @ts-ignore we need to test regular-js behavior
959959
const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, beforeSend });
960960
const client = new TestClient(options);
961-
const loggerErrorSpy = jest.spyOn(logger, 'error');
961+
const loggerWarnSpy = jest.spyOn(logger, 'warn');
962962

963963
client.captureEvent({ message: 'hello' });
964964

965965
expect(TestClient.instance!.event).toBeUndefined();
966-
expect(loggerErrorSpy).toBeCalledWith(
966+
expect(loggerWarnSpy).toBeCalledWith(
967967
new SentryError('`beforeSend` method has to return `null` or a valid event.'),
968968
);
969969
}
@@ -1091,15 +1091,15 @@ describe('BaseClient', () => {
10911091

10921092
const client = new TestClient(getDefaultTestClientOptions({ dsn: PUBLIC_DSN }));
10931093
const captureExceptionSpy = jest.spyOn(client, 'captureException');
1094-
const loggerErrorSpy = jest.spyOn(logger, 'error');
1094+
const loggerWarnSpy = jest.spyOn(logger, 'warn');
10951095
const scope = new Scope();
10961096
scope.addEventProcessor(() => null);
10971097

10981098
client.captureEvent({ message: 'hello' }, {}, scope);
10991099

11001100
expect(TestClient.instance!.event).toBeUndefined();
11011101
expect(captureExceptionSpy).not.toBeCalled();
1102-
expect(loggerErrorSpy).toBeCalledWith(new SentryError('An event processor returned null, will not send event.'));
1102+
expect(loggerWarnSpy).toBeCalledWith(new SentryError('An event processor returned null, will not send event.'));
11031103
});
11041104

11051105
// TODO(v7): Add back tests with client reports
@@ -1131,7 +1131,7 @@ describe('BaseClient', () => {
11311131
const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN });
11321132
const client = new TestClient(options);
11331133
const captureExceptionSpy = jest.spyOn(client, 'captureException');
1134-
const loggerErrorSpy = jest.spyOn(logger, 'error');
1134+
const loggerWarnSpy = jest.spyOn(logger, 'warn');
11351135
const scope = new Scope();
11361136
const exception = new Error('sorry');
11371137
scope.addEventProcessor(() => {
@@ -1147,7 +1147,7 @@ describe('BaseClient', () => {
11471147
},
11481148
originalException: exception,
11491149
});
1150-
expect(loggerErrorSpy).toBeCalledWith(
1150+
expect(loggerWarnSpy).toBeCalledWith(
11511151
new SentryError(
11521152
`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${exception}`,
11531153
),

0 commit comments

Comments
 (0)