Skip to content

ref(core): Make event processing logs warnings #5010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2022
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
2 changes: 1 addition & 1 deletion packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
return finalEvent.event_id;
},
reason => {
IS_DEBUG_BUILD && logger.error(reason);
IS_DEBUG_BUILD && logger.warn(reason);
return undefined;
},
);
Expand Down
16 changes: 8 additions & 8 deletions packages/core/test/lib/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -940,13 +940,13 @@ describe('BaseClient', () => {
const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, beforeSend });
const client = new TestClient(options);
const captureExceptionSpy = jest.spyOn(client, 'captureException');
const loggerErrorSpy = jest.spyOn(logger, 'error');
const loggerWarnSpy = jest.spyOn(logger, 'warn');

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

expect(TestClient.instance!.event).toBeUndefined();
expect(captureExceptionSpy).not.toBeCalled();
expect(loggerErrorSpy).toBeCalledWith(new SentryError('`beforeSend` returned `null`, will not send event.'));
expect(loggerWarnSpy).toBeCalledWith(new SentryError('`beforeSend` returned `null`, will not send event.'));
});

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

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

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

const client = new TestClient(getDefaultTestClientOptions({ dsn: PUBLIC_DSN }));
const captureExceptionSpy = jest.spyOn(client, 'captureException');
const loggerErrorSpy = jest.spyOn(logger, 'error');
const loggerWarnSpy = jest.spyOn(logger, 'warn');
const scope = new Scope();
scope.addEventProcessor(() => null);

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

expect(TestClient.instance!.event).toBeUndefined();
expect(captureExceptionSpy).not.toBeCalled();
expect(loggerErrorSpy).toBeCalledWith(new SentryError('An event processor returned null, will not send event.'));
expect(loggerWarnSpy).toBeCalledWith(new SentryError('An event processor returned null, will not send event.'));
});

// TODO(v7): Add back tests with client reports
Expand Down Expand Up @@ -1131,7 +1131,7 @@ describe('BaseClient', () => {
const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN });
const client = new TestClient(options);
const captureExceptionSpy = jest.spyOn(client, 'captureException');
const loggerErrorSpy = jest.spyOn(logger, 'error');
const loggerWarnSpy = jest.spyOn(logger, 'warn');
const scope = new Scope();
const exception = new Error('sorry');
scope.addEventProcessor(() => {
Expand All @@ -1147,7 +1147,7 @@ describe('BaseClient', () => {
},
originalException: exception,
});
expect(loggerErrorSpy).toBeCalledWith(
expect(loggerWarnSpy).toBeCalledWith(
new SentryError(
`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${exception}`,
),
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/test/index.client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const global = getGlobalObject();

const reactInit = jest.spyOn(SentryReact, 'init');
const captureEvent = jest.spyOn(BaseClient.prototype, 'captureEvent');
const logError = jest.spyOn(logger, 'error');
const logWarn = jest.spyOn(logger, 'warn');

describe('Client init()', () => {
afterEach(() => {
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('Client init()', () => {

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

describe('integrations', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/test/index.server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const global = getGlobalObject();
(global as typeof global & { __rewriteFramesDistDir__: string }).__rewriteFramesDistDir__ = '.next';

const nodeInit = jest.spyOn(SentryNode, 'init');
const logError = jest.spyOn(logger, 'error');
const logWarn = jest.spyOn(logger, 'warn');

describe('Server init()', () => {
afterEach(() => {
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('Server init()', () => {
await SentryNode.flush();

expect(transportSend).not.toHaveBeenCalled();
expect(logError).toHaveBeenCalledWith(new SentryError('An event processor returned null, will not send event.'));
expect(logWarn).toHaveBeenCalledWith(new SentryError('An event processor returned null, will not send event.'));
});

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