import {serializeLongValue} from '../utils/instrumentation-helpers'; import InstrumentationModule from '../../native/InstrumentationModule'; // @ts-ignore // eslint-disable-next-line @typescript-eslint/no-unused-vars const {MAX_USER_DATA_STRING_LENGTH} = InstrumentationModule.getConstants(); /** * Sets a key-value pair identifier that will be included in all snapshots. * The identifier can be used to add any data you wish. * * The `key` must be unique across your application. * The `key` namespace is distinct for each user data type. * Re-using the same `key` overwrites the previous `value`. * The `key` is limited to @constant {MAX_USER_DATA_STRING_LENGTH} characters. * * A `value` of `null` will clear the data. * * This information is not persisted across application runs. Once the application is destroyed, * the user data is cleared. * * @param {string} key Key for value. * @param {Date} value Date value. */ async function setUserDataDate(key: string, value: Date | null): Promise { if (!value) { return removeUserDataDate(key); } await InstrumentationModule.setUserDataDate( key, serializeLongValue(value!.getTime()), ); } /** * Removes a key-value pair set with {@link setUserDataDate}. * The identifier can be used to add any data you wish. * * @param {string} key Key of the entry to remove. */ async function removeUserDataDate(key: string): Promise { await InstrumentationModule.removeUserDataDate(key); } export {setUserDataDate, removeUserDataDate};