Skip to content
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

revert: Moved message stack trace back to exception (fixes symbolication) #3635

Merged
merged 3 commits into from
Mar 19, 2024
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- CaptureMessage stack-trace is now symbolicated ([#3635](https://github.com/getsentry/sentry-react-native/pull/3635))

## 5.20.0

### Features
19 changes: 1 addition & 18 deletions src/js/client.ts
Original file line number Diff line number Diff line change
@@ -6,10 +6,8 @@ import type {
Envelope,
Event,
EventHint,
Exception,
Outcome,
SeverityLevel,
Thread,
UserFeedback,
} from '@sentry/types';
import { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';
@@ -58,22 +56,7 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
* @inheritDoc
*/
public eventFromMessage(message: string, level?: SeverityLevel, hint?: EventHint): PromiseLike<Event> {
return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace).then(
(event: Event) => {
// TMP! Remove this function once JS SDK uses threads for messages
if (!event.exception?.values || event.exception.values.length <= 0) {
return event;
}
const values = event.exception.values.map(
(exception: Exception): Thread => ({
stacktrace: exception.stacktrace,
}),
);
(event as { threads?: { values: Thread[] } }).threads = { values };
delete event.exception;
return event;
},
);
return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);
}

/**
1 change: 0 additions & 1 deletion src/js/integrations/debugsymbolicator.ts
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@ export class DebugSymbolicator implements Integration {
symbolicatedFrames && this._replaceExceptionFramesInEvent(event, symbolicatedFrames);
} else if (event.threads) {
// RN JS doesn't have threads
// syntheticException is used for Sentry.captureMessage() threads
symbolicatedFrames && this._replaceThreadFramesInEvent(event, symbolicatedFrames);
}
}
7 changes: 4 additions & 3 deletions test/client.test.ts
Original file line number Diff line number Diff line change
@@ -368,11 +368,12 @@ describe('Tests ReactNativeClient', () => {
const getMessageEventFrom = (func: jest.Mock) =>
func.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload];

test('captureMessage contains stack trace in threads', async () => {
test('captureMessage contains stack trace in exception', async () => {
const mockSyntheticExceptionFromHub = new Error();
client.captureMessage('test message', 'error', { syntheticException: mockSyntheticExceptionFromHub });
expect(getMessageEventFrom(mockTransportSend).threads.values.length).toBeGreaterThan(0);
expect(getMessageEventFrom(mockTransportSend).exception).toBeUndefined();
expect(getMessageEventFrom(mockTransportSend).exception.values.length).toBeGreaterThan(0);
expect(getMessageEventFrom(mockTransportSend).exception).toBeDefined();
expect(getMessageEventFrom(mockTransportSend).threads).toBeUndefined();
});
});