ReactNative amplitude-js will not work in a non-browser environment.
The amplitude-js package warns about the environment. I am using React Native.
[Amplitude] amplitude-js will not work in a non-browser environment. If you are planning to add Amplitude to a node environment, please use @amplitude/node
But, the React Native installiation guide page, they are using amplitude-js directly. Is there any problem?
Expected Behavior
Current Behavior
Possible Solution
Steps to Reproduce
Environment
- JS SDK Version: 7.3.3
- Installation Method: Yarn, React Native
- Browser and Version or React Native and Device: React Native 0.63.3
Same issue. I found this in the code
if (!isBrowserEnv()) {
utils.log.warn('amplitude-js will not work in a non-browser environment. If you are planning to add Amplitude to a node environment, please use @amplitude/node');
}
and this
export function isBrowserEnv(): boolean {
return typeof window === 'object' && window?.document !== undefined;
}
window.document prints as undefined in React Native
looks related to #174 but not sure what the status is on this fix
warning comes from latest MR #321
Thanks for reporting this, will take a look at a fix ASAP
It's a false positive warning, amplitude-js should still work in a react-native environment in the meantime while the fix is being done
Solution will involve the BUILD_COMPAT_REACT_NATIVE flag
Any news for this bug ? I am facing the same issue.