@ogcio/o11y-sdk-react
Version:
Opentelemetry standard instrumentation SDK for React based project
22 lines • 752 B
JavaScript
import { instrumentFaro, withFaroErrorBoundary, withFaroProfiler, } from "../../index.js";
import { useEffect, useRef } from "react";
export const useFaro = ({ config }) => {
const faroRef = useRef(undefined);
useEffect(() => {
if (!faroRef.current && config.collectorUrl) {
faroRef.current = instrumentFaro(config);
}
}, [config]);
};
export const FaroWrapper = ({ children, config, }) => {
useFaro({ config });
return children;
};
export const withFaro = (Component, options) => {
const enableProfiling = options?.profiling ?? false;
if (enableProfiling) {
return withFaroProfiler(Component);
}
return withFaroErrorBoundary(Component, {});
};
//# sourceMappingURL=useFaro.js.map