logtail-js
logtail-js copied to clipboard
React Native support
Hello,
Is there any planned support for react native? The standard node library does not currently work for react native apps due to its dependency on path
, and I couldn't find any documentation on react native integrations.
For now, we have had to resort to firing off requests via http, and while this method does work, it is messier than using the library directly.
Thanks!
Hi @TreeOfLearning,
Thanks for raising this!
I'm adding React Native support to our internal tracking. I will make sure to keep you updated here on GitHub.
Thank you for reaching out!
I hope y'all don't mind a "plus one" comment, but we could really use this as well.
@TreeOfLearning - I will say that we have been able to get the @logtail/browser
package to work with version v0.4.2
. I haven't tested what other ones do or don't work.
I've noticed some strange behavior (I'm currently debugging what might be a memory leak? I can file a separate issue if it's confirmable). But that package does compile and work basically fine.
Official support would be strongly preferred!
This patch file lets us use @logtail/browser
without hitting errors on the missing window
object. It also breaks that context, but we don't really care about those details for the app I'm working on. If you want things like screen size, you might actually be able to modify the patch to include the RN versions of that, or modify some global window
object in React Native to serve up the data you'd want.
diff --git a/node_modules/@logtail/browser/dist/cjs/browser.js b/node_modules/@logtail/browser/dist/cjs/browser.js
index db7ce15..bec7453 100644
--- a/node_modules/@logtail/browser/dist/cjs/browser.js
+++ b/node_modules/@logtail/browser/dist/cjs/browser.js
@@ -53,7 +53,7 @@ class Browser extends core_1.Base {
const wrappedContext = { error: context };
context = wrappedContext;
}
- context = Object.assign(Object.assign({}, this.getCurrentContext()), context);
+ context = Object.assign(Object.assign({}, {}), context);
return super.log(message, level, context);
}
getCurrentContext() {
diff --git a/node_modules/@logtail/browser/dist/es6/browser.js b/node_modules/@logtail/browser/dist/es6/browser.js
index d0df277..864ed04 100644
--- a/node_modules/@logtail/browser/dist/es6/browser.js
+++ b/node_modules/@logtail/browser/dist/es6/browser.js
@@ -50,7 +50,7 @@ export class Browser extends Base {
const wrappedContext = { error: context };
context = wrappedContext;
}
- context = Object.assign(Object.assign({}, this.getCurrentContext()), context);
+ context = Object.assign(Object.assign({}, {}), context);
return super.log(message, level, context);
}
getCurrentContext() {
Hello @TreeOfLearning and @coolsoftwaretyler,
Thanks for raising this and for your patience on this one 🙏
The newly released @logtail/browser
in v0.5.1
should now work even in React Native environment.
Phenomenal. We love the work you do. Thanks for the consideration and keep it up y'all. We'll evaluate the upgrade.