- Replaced Sentry breadcrumbs and context setting with a custom telemetry implementation across various components including Apps, WebView, CarouselBox, and ndView. - Introduced a new telemetry module to encapsulate observability logic and provide a unified API for logging events, messages, and exceptions. - Updated documentation to reflect changes in observability architecture, consolidating Sentry initialization and telemetry usage. - Enhanced error handling and logging in data fetching and application lifecycle management.
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { useEffect } from "react";
|
|
import { Platform } from "react-native";
|
|
import { telemetry } from "./telemetry";
|
|
const runtimeFlagsTelemetry = telemetry.scope("runtime.flags");
|
|
import {
|
|
startAppLifecycleCrashSentinel,
|
|
stopAppLifecycleCrashSentinel,
|
|
} from "./appLifecycleCrashSentinel";
|
|
|
|
type AppLifecycleObservabilityOptions = {
|
|
nativeScreensMode: string;
|
|
rootTabSceneMode: string;
|
|
};
|
|
|
|
/**
|
|
* Installs app-wide runtime diagnostics once at the root of the application.
|
|
* The navigation and provider tree only supplies the runtime mode values.
|
|
*/
|
|
export function useAppLifecycleObservability({
|
|
nativeScreensMode,
|
|
rootTabSceneMode,
|
|
}: AppLifecycleObservabilityOptions) {
|
|
useEffect(() => {
|
|
const platform = Platform.OS;
|
|
telemetry.tag("native_screens_mode", nativeScreensMode);
|
|
telemetry.tag("root_tab_scene_mode", rootTabSceneMode);
|
|
telemetry.context("runtime_navigation_flags", {
|
|
platform,
|
|
nativeScreensMode,
|
|
rootTabSceneMode,
|
|
});
|
|
runtimeFlagsTelemetry.breadcrumb({
|
|
message: "runtime navigation flags applied",
|
|
data: {
|
|
platform,
|
|
nativeScreensMode,
|
|
rootTabSceneMode,
|
|
},
|
|
});
|
|
void startAppLifecycleCrashSentinel({ nativeScreensMode });
|
|
return () => {
|
|
stopAppLifecycleCrashSentinel();
|
|
};
|
|
}, [nativeScreensMode, rootTabSceneMode]);
|
|
}
|