Closed jarod-legault closed 4 years ago
+1
Hi @jarod-legault , @jcurlier
We have separate documentation for React Native and Javascript. The link to the documentation and examples above are from our Javascript docs.
Information for adding diagnostic data in React Native is available here: https://docs.bugsnag.com/platforms/react-native/react-native/#sending-diagnostic-data
The example looks like this:
bugsnag.notify(error, function(report) {
report.metadata = { "account": {
"company": "Acme Co",
"id": 123
}
}
});
Additional information on customising error reports for React Native is available here: https://docs.bugsnag.com/platforms/react-native/react-native/customizing-error-reports/#adding-custom-diagnostics
With this as an example:
bugsnag.notify(error, (report) => {
report.metadata.account = {"name": "Acme Co."};
});
Hi @jarod-legault , @jcurlier
We have separate documentation for React Native and Javascript. The link to the documentation and examples above are from our Javascript docs.
Information for adding diagnostic data in React Native is available here: https://docs.bugsnag.com/platforms/react-native/react-native/#sending-diagnostic-data
The example looks like this:
bugsnag.notify(error, function(report) { report.metadata = { "account": { "company": "Acme Co", "id": 123 } } });
Additional information on customising error reports for React Native is available here: https://docs.bugsnag.com/platforms/react-native/react-native/customizing-error-reports/#adding-custom-diagnostics
With this as an example:
bugsnag.notify(error, (report) => { report.metadata.account = {"name": "Acme Co."}; });
Wow, I can't believe I missed that. Thanks so much, @phillipsam!
Description
I am trying to create a Bugsnag report in a React Native project with extra data (metadata).
Issue
I followed the Bugsnag docs and tried both methods under "Customizing Diagnostic Data":
and I was getting this error:
When I check the
index.d.ts
file in the Bugsnag directory, I see that the second parameter in thenotify
method isbeforeSendCallback
(notopts
as the docs say). I also see that there is noreport.updateMetaData
method, but there is areport.addMetadata
method. Based on what I found inindex.d.ts
, I was able to get my code working this way:Are the docs inaccurate? Or am I not understanding how to use the
notify
method properly?Environment
Library versions:
pod -v
): N/AExample code snippet
Error messages:
``` TypeError n is not a function. (In 'n(f)', 'n' is an instance of Object) node_modules/bugsnag-react-native/lib/Bugsnag.js:107:19 node_modules/regenerator-runtime/runtime.js:62:44 tryCatch node_modules/regenerator-runtime/runtime.js:296:30 node_modules/regenerator-runtime/runtime.js:62:44 tryCatch node_modules/regenerator-runtime/runtime.js:152:28 invoke node_modules/regenerator-runtime/runtime.js:195:17 node_modules/promise/setimmediate/core.js:45:7 tryCallTwo node_modules/promise/setimmediate/core.js:200:23 doResolve node_modules/promise/setimmediate/core.js:66:12 Promise node_modules/regenerator-runtime/runtime.js:194:27 callInvokeWithMethodAndArg node_modules/regenerator-runtime/runtime.js:217:12 _invoke node_modules/regenerator-runtime/runtime.js:241:13 async node_modules/bugsnag-react-native/lib/Bugsnag.js:86:177 notify ```