import InstrumentationModule from '../../native/InstrumentationModule'; /** * Starts a global timer with the given name. * * The name should contain only alphanumeric characters and spaces. * * Illegal characters will be replaced by their ASCII hex value. * * @param {string} name The name of the timer. * * ```tsx * async function doCheckout() { * try { * const CHECKOUT_TIMER = "Time Spent on checkout"; * await Instrumentation.startTimer(CHECKOUT_TIMER); * * await someCheckoutService(); * await someOtherLongTask(); * catch (e) { * // capture error * } finally { * await Instrumentation.stopTimer(CHECKOUT_TIMER); * } * } * ``` */ async function startTimer(name: string): Promise { await InstrumentationModule.startTimer(name); } /** * Stops a global timer with the given name and reports it to the cloud. * * The name should contain only alphanumeric characters and spaces. * * Illegal characters will be replaced by their ASCII hex value. * * @param {string} name The name of the timer. */ async function stopTimer(name: string): Promise { await InstrumentationModule.stopTimer(name); } export {startTimer, stopTimer};