Skip to content

Commit

Permalink
Add extra data view to RN RedBox
Browse files Browse the repository at this point in the history
Reviewed By: shergin

Differential Revision: D6382976

fbshipit-source-id: 33568a241395b085a840ac52adab3c9dc463ea4c
  • Loading branch information
Ayush Sood authored and facebook-github-bot committed Dec 14, 2017
1 parent e8eec24 commit ee521f9
Show file tree
Hide file tree
Showing 5 changed files with 652 additions and 271 deletions.
11 changes: 11 additions & 0 deletions Libraries/BugReporting/BugReporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@ class BugReporting {
static _extraSources: Map<string, SourceCallback> = new Map();
static _fileSources: Map<string, SourceCallback> = new Map();
static _subscription: ?EmitterSubscription = null;
static _redboxSubscription: ?EmitterSubscription = null;

static _maybeInit() {
if (!BugReporting._subscription) {
BugReporting._subscription = RCTDeviceEventEmitter
.addListener('collectBugExtraData', BugReporting.collectExtraData, null);
defaultExtras();
}

if (!BugReporting._redboxSubscription) {
BugReporting._redboxSubscription = RCTDeviceEventEmitter
.addListener('collectRedBoxExtraData', BugReporting.collectExtraData, null);
}
}

/**
Expand Down Expand Up @@ -98,6 +104,11 @@ class BugReporting {
BugReportingNativeModule.setExtraData &&
BugReportingNativeModule.setExtraData(extraData, fileData);

const RedBoxNativeModule = require('NativeModules').RedBox;
RedBoxNativeModule &&
RedBoxNativeModule.setExtraData &&
RedBoxNativeModule.setExtraData(extraData, 'From BugReporting.js');

return { extras: extraData, files: fileData };
}
}
Expand Down
Loading

0 comments on commit ee521f9

Please sign in to comment.