Skip to content

ref: Emit transaction instead of culprit #408

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
May 15, 2018
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
60 changes: 28 additions & 32 deletions lib/raven-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,14 @@ function reactNativePlugin(Raven, options, internalDataCallback) {
Raven.setTransport(reactNativePlugin._transport);

// Check for a previously persisted payload, and report it.
reactNativePlugin
._restorePayload()
.then(function(payload) {
options.onInitialize && options.onInitialize(payload);
if (!payload) return;
Raven._sendProcessedPayload(payload, function(error) {
if (error) return; // Try again next launch.
reactNativePlugin._clearPayload();
});
})
['catch'](function() {});
reactNativePlugin._restorePayload().then(function(payload) {
options.onInitialize && options.onInitialize(payload);
if (!payload) return;
Raven._sendProcessedPayload(payload, function(error) {
if (error) return; // Try again next launch.
reactNativePlugin._clearPayload();
});
})['catch'](function() {});

Raven.setShouldSendCallback(function(data, originalCallback) {
if (!(FATAL_ERROR_KEY in data)) {
Expand All @@ -102,14 +99,11 @@ function reactNativePlugin(Raven, options, internalDataCallback) {
var origError = data[FATAL_ERROR_KEY];
delete data[FATAL_ERROR_KEY];

reactNativePlugin
._persistPayload(data)
.then(function() {
defaultHandler(origError, true);
handlingFatal = false; // In case it isn't configured to crash.
return null;
})
['catch'](function() {});
reactNativePlugin._persistPayload(data).then(function() {
defaultHandler(origError, true);
handlingFatal = false; // In case it isn't configured to crash.
return null;
})['catch'](function() {});

return false; // Do not continue.
});
Expand Down Expand Up @@ -183,11 +177,11 @@ function reactNativePlugin(Raven, options, internalDataCallback) {
*/
reactNativePlugin._persistPayload = function(payload) {
var AsyncStorage = require('react-native').AsyncStorage;
return AsyncStorage.setItem(ASYNC_STORAGE_KEY, JSON.stringify(payload))['catch'](
function() {
return null;
}
);
return AsyncStorage.setItem(ASYNC_STORAGE_KEY, JSON.stringify(payload))[
'catch'
](function() {
return null;
});
};

/**
Expand All @@ -197,13 +191,11 @@ reactNativePlugin._persistPayload = function(payload) {
*/
reactNativePlugin._restorePayload = function() {
var AsyncStorage = require('react-native').AsyncStorage;
var promise = AsyncStorage.getItem(ASYNC_STORAGE_KEY)
.then(function(payload) {
return JSON.parse(payload);
})
['catch'](function() {
return null;
});
var promise = AsyncStorage.getItem(ASYNC_STORAGE_KEY).then(function(payload) {
return JSON.parse(payload);
})['catch'](function() {
return null;
});
// Make sure that we fetch ASAP.
var RCTAsyncSQLiteStorage = NativeModules.AsyncSQLiteDBStorage;
var RCTAsyncRocksDBStorage = NativeModules.AsyncRocksDBStorage;
Expand Down Expand Up @@ -265,7 +257,7 @@ reactNativePlugin._transport = function(options) {
};

/**
* Strip device-specific IDs found in culprit and frame filenames
* Strip device-specific IDs found in transaction and frame filenames
* when running React Native applications on a physical device.
*/
reactNativePlugin._normalizeData = function(data, pathStripRe) {
Expand All @@ -277,6 +269,10 @@ reactNativePlugin._normalizeData = function(data, pathStripRe) {
data.culprit = normalizeUrl(data.culprit, pathStripRe);
}

if (data.transaction) {
data.transaction = normalizeUrl(data.transaction, pathStripRe);
}

// NOTE: if data.exception exists, exception.values and exception.values[0] are
// guaranteed to exist
var stacktrace =
Expand Down