Skip to content

Commit 1c5bff0

Browse files
authored
ref(core): Make event processing logs warnings (#5010)
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 f979104 commit 1c5bff0

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
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
),

packages/nextjs/test/index.client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const global = getGlobalObject();
1414

1515
const reactInit = jest.spyOn(SentryReact, 'init');
1616
const captureEvent = jest.spyOn(BaseClient.prototype, 'captureEvent');
17-
const logError = jest.spyOn(logger, 'error');
17+
const logWarn = jest.spyOn(logger, 'warn');
1818

1919
describe('Client init()', () => {
2020
afterEach(() => {
@@ -75,7 +75,7 @@ describe('Client init()', () => {
7575

7676
expect(transportSend).not.toHaveBeenCalled();
7777
expect(captureEvent.mock.results[0].value).toBeUndefined();
78-
expect(logError).toHaveBeenCalledWith(new SentryError('An event processor returned null, will not send event.'));
78+
expect(logWarn).toHaveBeenCalledWith(new SentryError('An event processor returned null, will not send event.'));
7979
});
8080

8181
describe('integrations', () => {

packages/nextjs/test/index.server.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const global = getGlobalObject();
1616
(global as typeof global & { __rewriteFramesDistDir__: string }).__rewriteFramesDistDir__ = '.next';
1717

1818
const nodeInit = jest.spyOn(SentryNode, 'init');
19-
const logError = jest.spyOn(logger, 'error');
19+
const logWarn = jest.spyOn(logger, 'warn');
2020

2121
describe('Server init()', () => {
2222
afterEach(() => {
@@ -104,7 +104,7 @@ describe('Server init()', () => {
104104
await SentryNode.flush();
105105

106106
expect(transportSend).not.toHaveBeenCalled();
107-
expect(logError).toHaveBeenCalledWith(new SentryError('An event processor returned null, will not send event.'));
107+
expect(logWarn).toHaveBeenCalledWith(new SentryError('An event processor returned null, will not send event.'));
108108
});
109109

110110
it("initializes both global hub and domain hub when there's an active domain", () => {

0 commit comments

Comments
 (0)