From 355fe969168163802f7f4295f737ecac0a99f39e Mon Sep 17 00:00:00 2001 From: AnastasiiaSvietlova Date: Tue, 14 Jan 2025 11:51:25 +0100 Subject: [PATCH] add setAppState to react-navigation-native-plugin --- .../lib/react-navigation-native-plugin.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/plugin-react-navigation/lib/react-navigation-native-plugin.ts b/packages/plugin-react-navigation/lib/react-navigation-native-plugin.ts index 68a1b47e5..4a1e35e9b 100644 --- a/packages/plugin-react-navigation/lib/react-navigation-native-plugin.ts +++ b/packages/plugin-react-navigation/lib/react-navigation-native-plugin.ts @@ -2,17 +2,20 @@ import type { Plugin, SpanFactory } from '@bugsnag/core-performance' import type { ReactNativeConfiguration } from '@bugsnag/react-native-performance' import { NavigationContainer } from '@react-navigation/native' import { createNavigationContainer } from './create-navigation-container' +import type { AppState } from '../../core/lib/core' class BugsnagPluginReactNavigationNativePerformance implements Plugin { private spanFactory?: SpanFactory + private setAppState?: (appState: AppState) => void - configure (_configuration: ReactNativeConfiguration, spanFactory: SpanFactory) { + configure (_configuration: ReactNativeConfiguration, spanFactory: SpanFactory, setAppState: (appState: AppState) => void) { this.spanFactory = spanFactory + this.setAppState = setAppState } createNavigationContainer = (Container = NavigationContainer) => { - if (!this.spanFactory) throw new Error('Bugsnag: BugsnagPluginReactNavigationNativePerformance not configured') - return createNavigationContainer(Container, this.spanFactory) as typeof Container + if (!this.spanFactory || !this.setAppState) throw new Error('Bugsnag: BugsnagPluginReactNavigationNativePerformance not configured') + return createNavigationContainer(Container, this.spanFactory, this.setAppState) as typeof Container } }