Skip to content

Adding the Javascript frames to the crash reports’ stack trace. #2

@shercoder

Description

@shercoder

Currently, the stacktrace we get is useless when trying to track the problem in Javascript. It makes it difficult to reproduce the problem and harder to fix when we don't have Javascript stacktrace.

Are there are any plans to support this in near future?

Currently I am trying to get the following solution working which I took from https://github.com/mikelambert/react-native-fabric-crashlytics and modified a bit to use with Instabug. But this isn't much helpful either since the stacktraces still come from the bundle file and it's useless. I am currently looking into adding sourcemap and see if that would be helpful. However, if this can supported out of the box in instabug-reactnative then that would be very helpful for Instabug users.

'use strict'; import { Platform } from 'react-native'; import StackTrace from 'stacktrace-js'; import Instabug from 'Instabug'; function init() { // if (__DEV__) { //	// Don't send exceptions from __DEV__, it's way too noisy! //	// Live reloading and hot reloading in particular lead to tons of noise... //	return; // } const originalHandler = global.ErrorUtils.getGlobalHandler(); function errorHandler(e, isFatal) { StackTrace.fromError(e, {offline: true}).then((x) => { const result = x.map((row) => { return `functionName: ${row.functionName}\nsource: ${row.source}\nfileName:${row.fileName}:${row.lineNumber || 0}:${row.columnNumber || 0}\n`; }); Instabug.log(result.join('\n')); Instabug.reportException(e.message); }); // And then re-throw the exception with the original handler if (originalHandler) { if (Platform.OS === 'ios') { originalHandler(e, isFatal); } else { // On Android, throwing the original exception immediately results in the // recordCustomExceptionName() not finishing before the app crashes and therefore not logged // Add a delay to give it time to log the custom JS exception before crashing the app. // The user facing effect of this delay is that separate JS errors will appear as separate // issues in the Crashlytics dashboard. setTimeout(() => { originalHandler(e, isFatal); }, 500); } } } global.ErrorUtils.setGlobalHandler(errorHandler); } module.exports = {	init, };

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions