import React, { useEffect } from "react";
import { useStateManagerContext } from "~/context/stateManager";
import errorTracker from "~/utils/errorTracker";
const flattenObject = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
rawObject, parentKey = "", 
// eslint-disable-next-line @typescript-eslint/no-explicit-any
result = {}) => {
    Object.keys(rawObject).forEach((key) => {
        if (Object.prototype.hasOwnProperty.call(rawObject, key)) {
            const newKey = parentKey ? `${parentKey}.${key}` : key;
            if (typeof rawObject[key] === "object" &&
                rawObject[key] !== null &&
                !Array.isArray(rawObject[key])) {
                flattenObject(rawObject[key], newKey, result);
            }
            else {
                result[`LocalLogic.${newKey}`] = rawObject[key];
            }
        }
    });
    return Object.assign({}, result);
};
/**
 * This component wrapper handles assigning tags to Sentry errors. Note that
 * tags are appended when a Sentry exception happens; calling `setTags` will not
 * in itself trigger a request to Sentry. Therefore it is safe to call setTags
 * frequently without debouncing.
 */
const SentryTagManager = ({ children }) => {
    const { sdkState } = useStateManagerContext();
    useEffect(() => {
        errorTracker.setTags(flattenObject(sdkState || {}));
    }, [sdkState.apiKey, sdkState.globalOptions, sdkState.options]);
    return React.createElement(React.Fragment, null, children);
};
export default SentryTagManager;
//# sourceMappingURL=index.js.map