Skip to content

Commit b600a20

Browse files
committed
fix(crashlytics): disable deprecation warnings for analytics in crashlytics
also left lots of implementer notes for future necessary fix
1 parent 4f7fb2e commit b600a20

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/crashlytics/lib/handlers.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,19 @@ export const setGlobalErrorHandler = once(nativeModule => {
9494
// Flag the Crashlytics backend that we have a fatal error, they will transform it
9595
await nativeModule.setAttribute(FATAL_FLAG, fatalTime);
9696

97+
// remember our current deprecation warning state in case users
98+
// have set it to non-default
99+
const currentDeprecationWarningToggle =
100+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS;
101+
97102
// Notify analytics, if it exists - throws error if not
98103
try {
104+
// FIXME - disable warnings and use the old namespaced style,
105+
// See https://github.com/invertase/react-native-firebase/issues/8381
106+
// Unfortunately, this fails completely when using modular!
107+
// Did not matter if I did named imports above or dynamic require here.
108+
// So temporarily reverting and silencing warnings instead
109+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
99110
await firebase.app().analytics().logEvent(
100111
'app_exception', // 'app_exception' is reserved but we make an exception for JS->fatal transforms
101112
{
@@ -106,6 +117,8 @@ export const setGlobalErrorHandler = once(nativeModule => {
106117
} catch (_) {
107118
// This just means analytics was not present, so we could not log the analytics event
108119
// console.log('error logging analytics app_exception: ' + e);
120+
} finally {
121+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = currentDeprecationWarningToggle;
109122
}
110123

111124
// If we are chaining to other handlers, just record the error, otherwise we need to crash with it

0 commit comments

Comments
 (0)