UNPKG

@botonic/react

Version:

Build Chatbots using React

25 lines 1.15 kB
import { __rest } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import { INPUT, isBrowser } from '@botonic/core'; import { ROLES } from '../../constants'; import { Message } from '../message'; import { DebugMessage } from './debug-message'; const serialize = (props) => { const { data } = props; // Return the event data as an object, ensuring it's not stringified return typeof data === 'string' ? JSON.parse(data) : data; }; export const SystemDebugTrace = (props) => { const { data, id } = props, otherProps = __rest(props // Parse data if it's a string , ["data", "id"]); // Parse data if it's a string const parsedData = typeof data === 'string' ? JSON.parse(data) : data; if (isBrowser()) { const eventData = Object.assign({}, parsedData); return (_jsx(Message, Object.assign({ role: ROLES.SYSTEM_DEBUG_TRACE_MESSAGE, json: serialize(props) }, otherProps, { type: INPUT.SYSTEM_DEBUG_TRACE, id: id }, { children: _jsx(DebugMessage, { debugEvent: eventData, messageId: id }) }))); } return null; }; SystemDebugTrace.serialize = serialize; //# sourceMappingURL=index.js.map